明輝手游網(wǎng)中心:是一個(gè)免費(fèi)提供流行視頻軟件教程、在線學(xué)習(xí)分享的學(xué)習(xí)平臺(tái)!

對(duì)于用ASP.Net識(shí)別遠(yuǎn)程主機(jī)服務(wù)器種類

[摘要]這幾天做ASP.Net追捕,也算是我入門(mén)吧。思路很簡(jiǎn)單,主要就是識(shí)別遠(yuǎn)程主機(jī)傳回的Banner,判斷遠(yuǎn)程主機(jī)服務(wù)器。這可能不夠準(zhǔn)確,因?yàn)楹细竦墓芾韱T可能會(huì)去修改Banner。 代碼如下(從我的Web追捕里找出來(lái)的,用VB.Net) Dim swWriter As Stream...
          這幾天做ASP.Net追捕,也算是我入門(mén)吧。思路很簡(jiǎn)單,主要就是識(shí)別遠(yuǎn)程主機(jī)傳回的Banner,
判斷遠(yuǎn)程主機(jī)服務(wù)器。這可能不夠準(zhǔn)確,因?yàn)楹细竦墓芾韱T可能會(huì)去修改Banner。

代碼如下(從我的Web追捕里找出來(lái)的,用VB.Net)

            Dim swWriter As StreamWriter
            '用以向網(wǎng)絡(luò)基礎(chǔ)數(shù)據(jù)流傳送數(shù)據(jù)
            Dim nsStream As NetworkStream
            '創(chuàng)建發(fā)送數(shù)據(jù)的網(wǎng)絡(luò)基礎(chǔ)數(shù)據(jù)流
            Dim tcpClient2 As TcpClient
            '通過(guò)它實(shí)現(xiàn)向遠(yuǎn)程主機(jī)提出TCP連接申請(qǐng)
            Dim sHostName As String
            Dim srRead As StreamReader
            '從網(wǎng)絡(luò)基礎(chǔ)數(shù)據(jù)流中讀取數(shù)據(jù)
            'HTTP服務(wù)追捕
            If TcpConnect(ZSIP, 80) = "CG" Then
                OppHTTP.Text = "HTTP服務(wù)已開(kāi)啟!服務(wù)軟件類型:未知"
                Try
                    'tcpClient = New TcpClient(IPAddress, Port)
                    tcpClient2 = New TcpClient(ZSIP.ToString(), 80)
                    tcpClient2.ReceiveTimeout = 1000000
                    tcpClient2.SendTimeout = 1000000
                    '對(duì)遠(yuǎn)程主機(jī)的8000端口提出TCP連接申請(qǐng)
                    nsStream = tcpClient2.GetStream()
                    '通過(guò)申請(qǐng),并獲取傳送數(shù)據(jù)的網(wǎng)絡(luò)基礎(chǔ)數(shù)據(jù)流
                    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()
                    '刷新當(dāng)前數(shù)據(jù)流中的數(shù)據(jù)
                    swWriter.Flush()
                    srRead = New StreamReader(nsStream, Encoding.Default)
                    '以得到的網(wǎng)絡(luò)基礎(chǔ)數(shù)據(jù)流來(lái)初始化StreamReader實(shí)例
                    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服務(wù)已開(kāi)啟!服務(wù)軟件類型:IIS 版本未知"
                        SystemFW = "WindowsNT/2000/XP/2003"
                    End If
                    If InStr(StrHttp, "Apache") > 0 Then
                        OppHTTP.Text = "HTTP服務(wù)已開(kāi)啟!服務(wù)軟件類型:Apache 版本未知"
                    End If
                    If InStr(StrHttp, "Netscape-Enterprise") > 0 Then
                        OppHTTP.Text = "HTTP服務(wù)已開(kāi)啟!服務(wù)軟件類型:Netscape-Enterprise 版本未知"
                    End If
                    If InStr(StrHttp, "Microsoft-IIS/5.0") > 0 Then
                        OppHTTP.Text = "HTTP服務(wù)已開(kāi)啟!服務(wù)軟件類型:IIS 5.0"
                        SystemFW = "Windows2000"
                    End If
                    If InStr(StrHttp, "Microsoft-IIS/5.1") > 0 Then
                        OppHTTP.Text = "HTTP服務(wù)已開(kāi)啟!服務(wù)軟件類型:IIS 5.1"
                        SystemFW = "Windows2000/XP"
                    End If
                    If InStr(StrHttp, "Microsoft-IIS/6.0") > 0 Then
                        OppHTTP.Text = "HTTP服務(wù)已開(kāi)啟!服務(wù)軟件類型:IIS 6.0"
                        SystemFW = "Windows2003"
                    End If
                    If InStr(StrHttp, "Apache/2") > 0 Then
                        OppHTTP.Text = "HTTP服務(wù)已開(kāi)啟!服務(wù)軟件類型:Apache 2.x"
                    End If
                    If InStr(StrHttp, "Apache/2.0.54") > 0 Then
                        OppHTTP.Text = "HTTP服務(wù)已開(kāi)啟!服務(wù)軟件類型:Apache 2.0.54"
                    End If
                    If InStr(StrHttp, "Apache/2.0.52") > 0 Then
                        OppHTTP.Text = "HTTP服務(wù)已開(kāi)啟!服務(wù)軟件類型:Apache 2.0.52"
                    End If
                    If InStr(StrHttp, "Apache/2.1.6") > 0 Then
                        OppHTTP.Text = "HTTP服務(wù)已開(kāi)啟!服務(wù)軟件類型:Apache 2.1.6"
                    End If
                    If InStr(StrHttp, "Apache/1.3.2") > 0 Then
                        OppHTTP.Text = "HTTP服務(wù)已開(kāi)啟!服務(wù)軟件類型:Apache 1.3.x"
                    End If
                    If InStr(StrHttp, "Apache/1.3.20") > 0 Then
                        OppHTTP.Text = "HTTP服務(wù)已開(kāi)啟!服務(wù)軟件類型:Apache 1.3.20"
                    End If
                    If InStr(StrHttp, "Apache/1.3.23") > 0 Then
                        OppHTTP.Text = "HTTP服務(wù)已開(kāi)啟!服務(wù)軟件類型:Apache 1.3.23"
                    End If
                    If InStr(StrHttp, "Apache/1.3.26") > 0 Then
                        OppHTTP.Text = "HTTP服務(wù)已開(kāi)啟!服務(wù)軟件類型:Apache 1.3.26"
                    End If
                    If InStr(StrHttp, "Apache/1.3.27") > 0 Then
                        OppHTTP.Text = "HTTP服務(wù)已開(kāi)啟!服務(wù)軟件類型:Apache 1.3.27"
                    End If
                    If InStr(StrHttp, "Apache/1.3.33") > 0 Then
                        OppHTTP.Text = "HTTP服務(wù)已開(kāi)啟!服務(wù)軟件類型:Apache 1.3.33"
                    End If
                    If InStr(StrHttp, "Netscape-Enterprise/4.1") > 0 Then
                        OppHTTP.Text = "HTTP服務(wù)已開(kāi)啟!服務(wù)軟件類型:Netscape-Enterprise 4.1"
                    End If
                    If InStr(StrHttp, "Unix") > 0 Then
                        SystemFW = "類Unix/Linux系統(tǒng)"
                    End If
                Catch
                End Try

因?yàn)槭钦鰜?lái)的,所以有的變量沒(méi)有定義,大家自己去琢磨吧。