域名城

标题: 公布 whois 查询源码 [打印本页]

作者: 四川旅游网    时间: 2014-8-5 02:04
标题: 公布 whois 查询源码
本帖最后由 四川旅游网 于 2014-8-5 02:21 编辑

你是否想拥有自己的whois查询网站,是否还在担心其他 whois查询系统会 偷偷记录你的查询记录,那就快来下载可DIV的纯净版 whois 小系统吧。

米友[四川旅游网] 免费分享 whois 查询源码

演示地址: http://whois.witbird.com
下载地址: www.witbird.com/whois.rar

运行条件:直接将源码放入网站根目录即可,网站必须支持asp.net

修改信息:用记事本打开 Views\Whois\Search.cshtml
修改以下信息即可:
    <title>智鸟 域名 whois 查询</title>
    <meta name="keywords" content="智鸟whois,智鸟whois查询,智鸟科技,witbird,witbird.com,115771999">
    <meta name="description" content="智鸟whois, 智鸟科技,专注于软件开发、网站建设、推广优化、移动APP开发.">

发布版源码无统计代码,需要统计功能的请自行添加统计代码。

不会安装的,直接call me。

效果图

[attach]164052[/attach]

@{
    Layout = null;
}
@model WitBird.Whois.Web.Models.Domain
<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>智鸟 域名 whois 查询</title>
    <meta name="keywords" content="智鸟whois,智鸟whois查询,智鸟科技,witbird,witbird.com,115771999">
    <meta name="description" content="智鸟whois, 智鸟科技,专注于软件开发、网站建设、推广优化、移动APP开发.">
    <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <style type="text/css">
        *
        {
            margin:0;
            padding:0;
            font-family:'Microsoft YaHei';
            font-size:12px;
        }
        table
        {
            border:1px solid #cdcdcd;
            border-collapse: collapse;
            border-spacing: 0;
        }
        p
        {
            height:20px;
        }
        .search:hover
        {
            cursor:pointer;
            background:#E0E9E9;
        }
    </style>
</head>
<body>
    <div style="width: 480px; margin: 0 auto; text-align:center;">
        <div style="width:100%; height:60px; line-height:60px; font-size:26px; color:#0C8F5A;" >
            智鸟 whois 查询
        </div>
        <div style="width:100%; height:50px;" >
            <form action="/whois/search" method="get">
                <table style="margin: 0 auto;">
                    <tr>
                        <td><input type="text" name="domain" value="@Model.Name" style="width:369px; height:40px; line-height:40px; border:none; font-size:24px; padding-left:10px; color:#1A73C5;" /></td>
                        <td><input type="submit" class="search" value="查 询" style="width:100px; height:40px; line-height:40px; border:none; color:#2C996D; background:#EEF1F1; font-size:20px; border-left: 1px solid #cdcdcd;" /></td>
                    </tr>
                </table>              
            </form>
        </div>
        <div style="width:100%; height:30px; text-align:left; color:#2C996D; " >
            支持:  .com .net .cn .wang .org .cc .de .me .biz .info .io
        </div>
        <div style="width:100%; min-height:30px; text-align:left; color:#1A73C5; line-height:22px; padding: 10px 0 20px 0; " >
            @if (!string.IsNullOrEmpty(Model.Name))
            {
                string url = "http://www." + Model.Name;
                <span>域名 :          @Model.Name      <a target="_blank" href="@url" style="color:#0C8F5A;">访问</a></span><br />
            }
            @if (!string.IsNullOrEmpty(Model.Registrant))
            {
                <span>注册人 :      @Model.Registrant</span><br />
            }
            @if (!string.IsNullOrEmpty(Model.Email))
            {
                <span>注册邮箱 :   @Model.Email</span><br />
            }
            @if (!string.IsNullOrEmpty(Model.CreationDate))
            {
                <span>注册时间 :   @Model.CreationDate</span><br />
            }
            @if (!string.IsNullOrEmpty(Model.ExpirationDate))
            {
                <span>到期时间 :   @Model.ExpirationDate</span><br />
            }
            @if (!string.IsNullOrEmpty(Model.UpdatedDate))
            {
                <span>更新时间 :   @Model.UpdatedDate</span><br />
            }
            @if (!string.IsNullOrEmpty(Model.ReferralURL))
            {
                <span>注册商 :      @Model.ReferralURL</span><br />
            }
        </div>
        <div style="width:100%; min-height:50px; text-align:left;" >
            @if (Model.Detail != null)
            {
                if (Model.Detail.Count() > 0)
                {
                    foreach (var item in Model.Detail)
                    {
                        <p>@item.ToString()</p>
                    }
                }
            }
        </div>
        <div style="width:100%; height:30px; color:#2C996D; " >
             Copyright © www.WitBird.com
        </div>
    </div>
</body>
</html>




using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Sockets;
using System.Text;
using System.Text.RegularExpressions;
using System.Web;
using System.Web.Mvc;

namespace WitBird.Whois.Web.Controllers
{
    public class WhoisController : Controller
    {
        //域名查询端口
        private const int Port = 43;

        [HttpGet]
        public ActionResult Search(string domain)
        {
            Models.Domain model = new Models.Domain();
            //域名为空直接返回
            if (string.IsNullOrEmpty(domain))
            {
                model.Name = "";
                return View(model);
            }
            else
            {
                //不包含“.”刚默认查询com
                if (!domain.Contains("."))
                {
                    domain = domain + ".com";
                }
                model.Name = domain;
            }

            //去掉空格,转换成小写
            domain = domain.Trim().ToLower();

            //检测域名格式
            Regex regex = new Regex(DomainServer.RegexValue, RegexOptions.IgnoreCase);

            Match match = regex.Match(domain);

            if (match.Success)
            {
                //检测域名后缀
                string suffix = match.Groups["root"].Value;

                byte[] bytes = Encoding.ASCII.GetBytes(string.Format("{0}\r\n", domain));

                byte[] buffer = new byte[4096];

                try
                {
                    using (Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
                    {
                        socket.Connect(DomainServer.DomainIPDictionary[suffix], Port);

                        socket.Send(bytes);

                        socket.Receive(buffer);

                        string content = Encoding.UTF8.GetString(buffer);

                        model.Detail = content.Split(new string[] { "\r", "\n" }, StringSplitOptions.RemoveEmptyEntries);

                        FomartDomain(suffix, model.Detail, model);
                    }
                }
                catch (Exception e)
                {
                    model.Detail = new string[] { e.Message.ToString() };
                    model.Suffix = "";
                    model.CreationDate = "";
                    model.ExpirationDate = "";
                    model.UpdatedDate = "";
                    model.ReferralURL = "";
                }
            }
            else
            {
                model.Detail = new string[] { @"输入有误 或 不支持该后缀" };
            }

            return View(model);
        }

        /// <summary>
        /// 提取域名基本信息
        /// </summary>
        /// <param name="suffix">后缀</param>
        /// <param name="Detail">域名详细信息</param>
        /// <param name="model">域名对象</param>
        public void FomartDomain(string suffix, IEnumerable<string> Detail, Models.Domain model)
        {
            if (model.Detail != null && model.Detail.Count() > 0)
            {
                foreach (var item in model.Detail)
                {
                    if (suffix == ".com" || suffix == ".net" || suffix == ".org")
                    {
                        if (item.Contains("Updated Date"))
                        {
                            model.UpdatedDate = FomartMonth(item.Substring(16, item.Length - 16));
                        }
                        if (item.Contains("Creation Date"))
                        {
                            model.CreationDate = FomartMonth(item.Substring(17, item.Length - 17));
                        }
                        if (item.Contains("Expiration Date"))
                        {
                            model.ExpirationDate = FomartMonth(item.Substring(19, item.Length - 19));
                        }
                        if (item.Contains("Referral URL"))
                        {
                            model.ReferralURL = item.Substring(16, item.Length - 16);
                        }
                    }
                    if (suffix == ".cn" || suffix == ".com.cn" || suffix == ".net.cn" || suffix == ".org.cn" || suffix == ".gov.cn")
                    {
                        if (item.Contains("Updated Date"))
                        {
                            model.UpdatedDate = FomartMonth(item.Substring(16, item.Length - 16));
                        }
                        if (item.Contains("Registration Date"))
                        {
                            model.CreationDate = FomartMonth(item.Substring(18, item.Length - 18));
                        }
                        if (item.Contains("Expiration Date"))
                        {
                            model.ExpirationDate = FomartMonth(item.Substring(17, item.Length - 17));
                        }
                        if (item.Contains("Registrant:"))
                        {
                            model.Registrant = item.Substring(11, item.Length - 11);
                        }
                        if (item.Contains("Registrant Contact Email"))
                        {
                            model.Email = item.Substring(25, item.Length - 25);
                        }
                    }
                    if (suffix == ".wang")
                    {
                        
                        if (item.Contains("Creation Date"))
                        {
                            model.CreationDate = FomartMonth(item.Substring(14, item.Length - 14));
                        }
                        if (item.Contains("Registry Expiry Date"))
                        {
                            model.ExpirationDate = FomartMonth(item.Substring(21, item.Length - 21));
                        }
                        if (item.Contains("Registrant Name"))
                        {
                            model.Registrant = item.Substring(16, item.Length - 16);
                        }
                        if (item.Contains("Registrant Email"))
                        {
                            model.Email = item.Substring(17, item.Length - 17);
                        }
                    }
                    if (suffix == ".cc")
                    {
                        if (item.Contains("Updated Date"))
                        {
                            model.UpdatedDate = FomartMonth(item.Substring(16, item.Length - 16));
                        }
                        if (item.Contains("Creation Date"))
                        {
                            model.CreationDate = FomartMonth(item.Substring(17, item.Length - 17));
                        }
                        if (item.Contains("Registry Expiry Date"))
                        {
                            model.ExpirationDate = FomartMonth(item.Substring(24, item.Length - 24));
                        }
                        if (item.Contains("Referral URL"))
                        {
                            model.ReferralURL = item.Substring(16, item.Length - 16);
                        }
                    }
                }
            }
        }

        public string FomartMonth(string datetime)
        {
            if (datetime.Contains("jan"))
            {
                datetime = datetime.Replace("jan", "1月");
            }
            if (datetime.Contains("feb"))
            {
                datetime = datetime.Replace("feb", "2月");
            }
            if (datetime.Contains("mar"))
            {
                datetime = datetime.Replace("mar", "3月");
            }
            if (datetime.Contains("apr"))
            {
                datetime = datetime.Replace("apr", "4月");
            }
            if (datetime.Contains("may"))
            {
                datetime = datetime.Replace("may", "5月");
            }
            if (datetime.Contains("jun"))
            {
                datetime = datetime.Replace("jun", "6月");
            }
            if (datetime.Contains("jul"))
            {
                datetime = datetime.Replace("jul", "7月");
            } if (datetime.Contains("aug"))
            {
                datetime = datetime.Replace("aug", "8月");
            }
            if (datetime.Contains("sep"))
            {
                datetime = datetime.Replace("sep", "9月");
            }
            if (datetime.Contains("oct"))
            {
                datetime = datetime.Replace("oct", "10月");
            }
            if (datetime.Contains("nov"))
            {
                datetime = datetime.Replace("nov", "11月");
            }
            if (datetime.Contains("dec"))
            {
                datetime = datetime.Replace("dec", "12月");
            }
            return datetime;
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace WitBird.Whois.Web.Controllers
{
    public class DomainServer
    {
        public const string RegexValue = @"^[a-zA-Z0-9\-]+(?<root>\.(cn|com.cn|net.cn|org.cn|gov.cn|de|com|net|org|cc|me|biz|info|io|wang)?)$";

        static DomainServer()
        {
            _domainIPDictionary.Add(".cn", "whois.cnnic.net.cn");
            _domainIPDictionary.Add(".com.cn", "whois.cnnic.net.cn");
            _domainIPDictionary.Add(".net.cn", "whois.cnnic.net.cn");
            _domainIPDictionary.Add(".org.cn", "whois.cnnic.net.cn");
            _domainIPDictionary.Add(".gov.cn", "whois.cnnic.net.cn");
            _domainIPDictionary.Add(".de", "whois.denic.de");
            _domainIPDictionary.Add(".com", "whois.crsnic.net");
            _domainIPDictionary.Add(".net", "whois.crsnic.net");
            _domainIPDictionary.Add(".org", "whois.crsnic.net");
            _domainIPDictionary.Add(".cc", "whois.nic.cc");
            _domainIPDictionary.Add(".me", "whois.nic.me");
            _domainIPDictionary.Add(".biz", "whois.neulevel.biz");
            _domainIPDictionary.Add(".info", "whois.afilias.info");
            _domainIPDictionary.Add(".io", "whois.nic.io");
            _domainIPDictionary.Add(".wang", "whois.nic.wang");
        }

        private static Dictionary<string, string> _domainIPDictionary = new Dictionary<string, string>();

        public static Dictionary<string, string> DomainIPDictionary
        {
            get
            {
                return _domainIPDictionary;
            }
        }
    }
}


































































































作者: 姬米    时间: 2014-8-5 09:28
好贴要顶啊,感谢分享哦
作者: 四川旅游网    时间: 2014-8-5 09:56
姬米 发表于 2014-8-5 09:28
好贴要顶啊,感谢分享哦

欢迎使用
作者: mysdibt    时间: 2014-8-5 09:56
分享伟大,支持
作者: 胡永同    时间: 2014-8-5 10:24
OKWHOIS.COM
作者: xiaosage    时间: 2014-8-5 10:36
有没有php的?@四川旅游网
作者: sswolf    时间: 2014-8-5 10:37
还没有开源!  WitBird.Whois.Web.dll  
作者: 四川旅游网    时间: 2014-8-5 11:57
sswolf 发表于 2014-8-5 10:37
还没有开源!  WitBird.Whois.Web.dll

需要没编译的代码也可以给你,其实上面已经把全部代码发布出来了。
作者: 四川旅游网    时间: 2014-8-5 11:59
xiaosage 发表于 2014-8-5 10:36
有没有php的?@四川旅游网

晚上回去研究一下,试试转换成PHP的,成功了,给你发一分
作者: sswolf    时间: 2014-8-5 12:15
四川旅游网 发表于 2014-8-5 11:59
晚上回去研究一下,试试转换成PHP的,成功了,给你发一分

好人
作者: sswolf    时间: 2014-8-5 12:16
四川旅游网 发表于 2014-8-5 11:57
需要没编译的代码也可以给你,其实上面已经把全部代码发布出来了。

开源的含义,就是源代码,未编译的必须的。 建议标题去掉开源更好些,比较严谨些!
作者: netcfo    时间: 2014-8-5 12:29
看看
作者: xiaosage    时间: 2014-8-5 13:57
四川旅游网 发表于 2014-8-5 11:59
晚上回去研究一下,试试转换成PHP的,成功了,给你发一分

好人啊。祝发财!
作者: 蓝色天际    时间: 2014-8-5 16:55
好东西  
作者: 326081657    时间: 2014-8-5 19:51
不错不错,看了下
作者: 庄永石    时间: 2014-8-5 22:09
不错
作者: fuxu    时间: 2015-1-3 15:15
php的有了没?
作者: aheiven    时间: 2015-1-6 16:57
关注
作者: 白云天    时间: 2015-1-7 10:37
谢分享
作者: 白云天    时间: 2015-1-7 11:10
花了我10分钟 搞好了
http://www.huangnao.com

皇脑 whois 查询
作者: zhuxingxing    时间: 2015-3-25 20:40
求php的975329562#qq.com
作者: xiaohu1989    时间: 2015-6-2 13:04
MVC啊?吊,期待完全开源,把DLL代码放出来吧!
作者: Web3.0博士    时间: 2015-6-12 07:08
没有完全开源是不是说明不清楚程序安全性,有漏洞黑客进来就麻烦了?

是不是这样可以:独立设置网站用户名,该用户名只能访问本目录,退出所有用户组。。。




欢迎光临 域名城 (https://club.domain.cn/) Powered by Discuz! X3.2