這幾天做asp.net追捕,也算是我入門吧。思路很簡單,主要就是識别遠端主機傳回的banner,判斷遠端主機伺服器。這可能不夠準确,因為合格的管理者可能會去修改banner。
代碼如下(從我的web追捕裡找出來的,用vb.net)
dimswwriterasstreamwriter
'用以向網絡基礎資料流傳送資料
dimnsstreamasnetworkstream
'建立發送資料的網絡基礎資料流
dimtcpclient2astcpclient
'通過它實作向遠端主機提出tcp連接配接申請
dimshostnameasstring
dimsrreadasstreamreader
'從網絡基礎資料流中讀取資料
'http服務追捕
iftcpconnect(zsip,80)="cg"then
opphttp.text="http服務已開啟!服務軟體類型:未知"
try
'tcpclient=newtcpclient(ipaddress,port)
tcpclient2=newtcpclient(zsip.tostring(),80)
tcpclient2.receivetimeout=1000000
tcpclient2.sendtimeout=1000000
'對遠端主機的8000端口提出tcp連接配接申請
nsstream=tcpclient2.getstream()
'通過申請,并擷取傳送資料的網絡基礎資料流
swwriter=newstreamwriter(nsstream)
swwriter.writeline("get/index.htmhttp/1.1")
swwriter.writeline("host:"&ip.text)
swwriter.writeline("accept:*/*")
swwriter.writeline("referer:")
swwriter.writeline()
'重新整理目前資料流中的資料
swwriter.flush()
srread=newstreamreader(nsstream,encoding.default)
'以得到的網絡基礎資料流來初始化streamreader執行個體
dimlasinteger=0
dowhilenotsrread.peek=-1andl<20
strhttp=strhttp&srread.readline()
l=l+1
loop
ifinstr(strhttp,"iis")>0then
opphttp.text="http服務已開啟!服務軟體類型:iis版本未知"
systemfw="windowsnt/2000/xp/2003"
endif
ifinstr(strhttp,"apache")>0then
opphttp.text="http服務已開啟!服務軟體類型:apache版本未知"
ifinstr(strhttp,"netscape-enterprise")>0then
opphttp.text="http服務已開啟!服務軟體類型:netscape-enterprise版本未知"
ifinstr(strhttp,"microsoft-iis/5.0")>0then
opphttp.text="http服務已開啟!服務軟體類型:iis5.0"
systemfw="windows2000"
ifinstr(strhttp,"microsoft-iis/5.1")>0then
opphttp.text="http服務已開啟!服務軟體類型:iis5.1"
systemfw="windows2000/xp"
ifinstr(strhttp,"microsoft-iis/6.0")>0then
opphttp.text="http服務已開啟!服務軟體類型:iis6.0"
systemfw="windows2003"
ifinstr(strhttp,"apache/2")>0then
opphttp.text="http服務已開啟!服務軟體類型:apache2.x"
ifinstr(strhttp,"apache/2.0.54")>0then
opphttp.text="http服務已開啟!服務軟體類型:apache2.0.54"
ifinstr(strhttp,"apache/2.0.52")>0then
opphttp.text="http服務已開啟!服務軟體類型:apache2.0.52"
ifinstr(strhttp,"apache/2.1.6")>0then
opphttp.text="http服務已開啟!服務軟體類型:apache2.1.6"
ifinstr(strhttp,"apache/1.3.2")>0then
opphttp.text="http服務已開啟!服務軟體類型:apache1.3.x"
ifinstr(strhttp,"apache/1.3.20")>0then
opphttp.text="http服務已開啟!服務軟體類型:apache1.3.20"
ifinstr(strhttp,"apache/1.3.23")>0then
opphttp.text="http服務已開啟!服務軟體類型:apache1.3.23"
ifinstr(strhttp,"apache/1.3.26")>0then
opphttp.text="http服務已開啟!服務軟體類型:apache1.3.26"
ifinstr(strhttp,"apache/1.3.27")>0then
opphttp.text="http服務已開啟!服務軟體類型:apache1.3.27"
ifinstr(strhttp,"apache/1.3.33")>0then
opphttp.text="http服務已開啟!服務軟體類型:apache1.3.33"
ifinstr(strhttp,"netscape-enterprise/4.1")>0then
opphttp.text="http服務已開啟!服務軟體類型:netscape-enterprise4.1"
ifinstr(strhttp,"unix")>0then
systemfw="類unix/linux系統"
catch
endtry