论坛交流
首页办公自动化| 网页制作| 平面设计| 动画制作| 数据库开发| 程序设计| 全部视频教程
应用视频: Windows | Word2007 | Excel2007 | PowerPoint2007 | Dreamweaver 8 | Fireworks 8 | Flash 8 | Photoshop cs | CorelDraw 12
编程视频: C语言视频教程 | HTML | Div+Css布局 | Javascript | Access数据库 | Asp | Sql Server数据库Asp.net  | Flash AS
当前位置 > 文字教程 > Asp.net教程
Tag:静态页面,treeview,gridview,repeater,dataset,sqldatareader,ado.net,上传,三层,ajax,xml,留言本,新闻发布,商城,注入,存储过程,分页,安全,优化,xmlhttp,fso,jmail,application,session,防盗链,stream,无组件,组件,md5,乱码,缓存,加密,验证码,算法,cookies,ubb,正则表达式,水印,索引,日志,压缩,base64,url重写,控件,Web.config,JDBC,函数,内存,PDF,迁移,结构,破解,编译,配置,进程,分词,IIS,触发器,socket,form认证,登录,视频教程

关于用ASP.Net识别远程主机服务器种类

文章类别:Asp.net | 发表日期:2008-10-5 22:12:43

这几天做ASP.Net追捕,也算是我入门吧。思路很简单,主要就是识别远程主机传回的Banner,判断远程主机服务器。这可能不够准确,因为合格的管理员可能会去修改Banner。

代码如下(从我的Web追捕里找出来的,用VB.Net)

            Dim swWriter As StreamWriter
            '用以向网络基础数据流传送数据
            Dim nsStream As NetworkStream
            '创建发送数据的网络基础数据流
            Dim tcpClient2 As TcpClient
            '通过它实现向远程主机提出TCP连接申请
            Dim sHostName As String
            Dim srRead As StreamReader
            '从网络基础数据流中读取数据
            'HTTP服务追捕
            If TcpConnect(ZSIP, 80) = "CG" Then
                OppHTTP.Text = "HTTP服务已开启!服务软件类型:未知"
                Try
                    'tcpClient = New TcpClient(IPAddress, Port)
                    tcpClient2 = New TcpClient(ZSIP.ToString(), 80)
                    tcpClient2.ReceiveTimeout = 1000000
                    tcpClient2.SendTimeout = 1000000
                    '对远程主机的8000端口提出TCP连接申请
                    nsStream = tcpClient2.GetStream()
                    '通过申请,并获取传送数据的网络基础数据流
                    swWriter = New StreamWriter(nsStream)
                    swWriter.WriteLine("Get /index.htm HTTP/1.1")
                    swWriter.WriteLine("Host:" & IP.Text)
                    swWriter.WriteLine("Accept:*/*")
                    swWriter.WriteLine("Referer:")
                    swWriter.WriteLine()
                    '刷新当前数据流中的数据
                    swWriter.Flush()
                    srRead = New StreamReader(nsStream, Encoding.Default)
                    '以得到的网络基础数据流来初始化StreamReader实例
                    Dim L As Integer = 0
                    Do While Not srRead.Peek = -1 And L < 20
                        StrHttp = StrHttp & srRead.ReadLine()
                        L = L + 1
                    Loop
                    If InStr(StrHttp, "IIS") > 0 Then
                        OppHTTP.Text = "HTTP服务已开启!服务软件类型:IIS 版本未知"
                        SystemFW = "WindowsNT/2000/XP/2003"
                    End If
                    If InStr(StrHttp, "Apache") > 0 Then
                        OppHTTP.Text = "HTTP服务已开启!服务软件类型:Apache 版本未知"
                    End If
                    If InStr(StrHttp, "Netscape-Enterprise") > 0 Then
                        OppHTTP.Text = "HTTP服务已开启!服务软件类型:Netscape-Enterprise 版本未知"
                    End If
                    If InStr(StrHttp, "Microsoft-IIS/5.0") > 0 Then
                        OppHTTP.Text = "HTTP服务已开启!服务软件类型:IIS 5.0"
                        SystemFW = "Windows2000"
                    End If
                    If InStr(StrHttp, "Microsoft-IIS/5.1") > 0 Then
                        OppHTTP.Text = "HTTP服务已开启!服务软件类型:IIS 5.1"
                        SystemFW = "Windows2000/XP"
                    End If
                    If InStr(StrHttp, "Microsoft-IIS/6.0") > 0 Then
                        OppHTTP.Text = "HTTP服务已开启!服务软件类型:IIS 6.0"
                        SystemFW = "Windows2003"
                    End If
                    If InStr(StrHttp, "Apache/2") > 0 Then
                        OppHTTP.Text = "HTTP服务已开启!服务软件类型:Apache 2.x"
                    End If
                    If InStr(StrHttp, "Apache/2.0.54") > 0 Then
                        OppHTTP.Text = "HTTP服务已开启!服务软件类型:Apache 2.0.54"
                    End If
                    If InStr(StrHttp, "Apache/2.0.52") > 0 Then
                        OppHTTP.Text = "HTTP服务已开启!服务软件类型:Apache 2.0.52"
                    End If
                    If InStr(StrHttp, "Apache/2.1.6") > 0 Then
                        OppHTTP.Text = "HTTP服务已开启!服务软件类型:Apache 2.1.6"
                    End If
                    If InStr(StrHttp, "Apache/1.3.2") > 0 Then
                        OppHTTP.Text = "HTTP服务已开启!服务软件类型:Apache 1.3.x"
                    End If
                    If InStr(StrHttp, "Apache/1.3.20") > 0 Then
                        OppHTTP.Text = "HTTP服务已开启!服务软件类型:Apache 1.3.20"
                    End If
                    If InStr(StrHttp, "Apache/1.3.23") > 0 Then
                        OppHTTP.Text = "HTTP服务已开启!服务软件类型:Apache 1.3.23"
                    End If
                    If InStr(StrHttp, "Apache/1.3.26") > 0 Then
                        OppHTTP.Text = "HTTP服务已开启!服务软件类型:Apache 1.3.26"
                    End If
                    If InStr(StrHttp, "Apache/1.3.27") > 0 Then
                        OppHTTP.Text = "HTTP服务已开启!服务软件类型:Apache 1.3.27"
                    End If
                    If InStr(StrHttp, "Apache/1.3.33") > 0 Then
                        OppHTTP.Text = "HTTP服务已开启!服务软件类型:Apache 1.3.33"
                    End If
                    If InStr(StrHttp, "Netscape-Enterprise/4.1") > 0 Then
                        OppHTTP.Text = "HTTP服务已开启!服务软件类型:Netscape-Enterprise 4.1"
                    End If
                    If InStr(StrHttp, "Unix") > 0 Then
                        SystemFW = "类Unix/Linux系统"
                    End If
                Catch
                End Try

因为是摘出来的,所以有的变量没有定义,大家自己去琢磨吧。
ZSIP:分析出的真实IP

视频教程列表
文章教程搜索
 
Asp.net推荐教程
Asp.net热门教程
看全部视频教程
购买方式/价格
购买视频教程: 咨询客服
tel:15972130058