选择显示字体大小

关于用asp.net识别远程主机服务器种类

          这几天做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

因为是摘出来的,所以有的变量没有定义,大家自己去琢磨吧。


 


关键字 本文所属关键字

相关 与本文相关文章

分类 所有文章关键字导航

源码编程相关

Java   Asp   PHP   .Net   XML   C/C++   CGI   VB   Jsp   J2ee   J2se   J2me   EJB   Servlet   Tomcat   Resin   Struts   Weblogic   Eclipse   ANT   GUI   JMS   Web servise   IDEA   Webphere   Hibernate   Spring   Jboss   Applet   Swing   Socket   Javamail   Perl   Ajax   P2P   安全   模式   框架   测试   开源   游戏

SQL数据库相关

My-SQL   Ms-SQL   Access   DB2   Oracle   Sybase   SQLserver   索引   存储过程   加密   数据库   分页   视图  

手机无线相关

3G   Wap   CDMA   GRPS   GSM   IVR   彩信   短信   无线   增值业务

网页设计制作相关

HTML   CSS   网页配色   网页特效   Javascript   VBscript   Dreamweaver   Frontpage   JS   Web   网站设计

网站建设推广相关

建站经验   网站优化   网站排名   推广   Alexa

操作系统/服务器相关

Windows XP   Windows 2000   Windows 2003   Windows Me   Windows 9.x   Linux   UNIX   注册表   操作系统   服务器   应用服务器

图形图像多媒体相关

Photoshop   Fireworks   Flash   Coreldraw   Illustrator   Freehand   Photoimpact   多媒体   图形图像

标准 网站致力的规范

Valid CSS!

无不良内容,无不良广告,无恶意代码

Valid XHTML 1.0 Transitional

creativecommons