国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > .NET > 正文

ASP.NET追捕休整版

2024-07-10 13:07:56
字體:
供稿:網(wǎng)友
中國最大的web開發(fā)資源網(wǎng)站及技術(shù)社區(qū),
c#第一個(gè)正式應(yīng)用,asp.net追捕休整版!
 這個(gè)程序,是前天我買到visual studio.net beta 2 中文版后編寫的第一個(gè)正式程序,感覺只真是好極了!!
 
 這個(gè)追捕的代碼參考過飛刀的asp.net 追捕的文章,但他文章中是針對(duì).net 框架beta1的,而beta2中好多的地方都修改調(diào)整了,順便也給程序增加了列表ip的功能,也就是說主機(jī)的多個(gè)ip地址都可以列出來的.只是那個(gè)根據(jù)ip查到ip所在地的功能暫時(shí)沒做,因?yàn)楫?dāng)時(shí)我用的機(jī)器是朋友的,而手頭沒有ip數(shù)據(jù)庫:~(
 
 static void main()
 {
 application.run(new form1());
 }
 
 private void form1_load(object sender, system.eventargs e)
 {
 string localhost = system.net.dns.gethostname();
 int i = 0;
 int n = dns.resolve(localhost.tostring()).addresslist.getlength(0);
 lblipinfo.text = localhost.tostring()+",就是你啊!";
 txthostname.text = dns.resolve(localhost.tostring()).addresslist.getvalue(0).tostring();
 lblsystem.text = "待命中...";
 lblhttp.text = "待命中...";
 lblftp.text = "待命中...";
 lbldns.text = "待命中...";
 lbltelnet.text = "待命中...";
 lblsmtp.text = "待命中...";
 lblpop.text = "待命中...";
 for(;i<n;i++)
 {
 iplistbox.items.add(dns.resolve(localhost.tostring()).addresslist.getvalue(i).tostring());
 }
 }
 
 private void cmdexec_click(object sender, system.eventargs e)
 {
 ipaddress theip;
 txthostname.focus();
 if(txthostname.text.length==0)
 {
 messagebox.show("您可以輸入要追捕的ip或者主機(jī)名稱!但不能為空","系統(tǒng)提示");
 return; //false
 }
 try
 {
 int i = 0;
 int n = dns.resolve(txthostname.text.tostring()).addresslist.getlength(0);
 iplistbox.items.clear();
 for(;i<n;i++)
 {
 iplistbox.items.add(dns.resolve(txthostname.text.tostring()).addresslist.getvalue(i).tostring());
 }
 theip = (ipaddress)dns.resolve(txthostname.text.tostring()).addresslist.getvalue(0);
 lblipinfo.text = theip.tostring();
 if(check1.checked==true)
 {//
 lblsystem.text = "檢測(cè)中...";
 lblhttp.text = "檢測(cè)中...";
 lblftp.text = "檢測(cè)中...";
 lbldns.text = "檢測(cè)中...";
 lbltelnet.text = "檢測(cè)中...";
 lblsmtp.text = "檢測(cè)中...";
 lblpop.text = "檢測(cè)中...";
 //檢查服務(wù)
 detectservice(theip);
 detectport(theip);
 lblsystem.text = strsystem.tostring();
 lblhttp.text = strhttp.tostring();
 lblftp.text = strftp.tostring();
 lbldns.text = strdns.tostring();
 lbltelnet.text = strtelnet.tostring();
 lblsmtp.text = strsmtp.tostring();
 lblpop.text = strpop.tostring();
 }
 
 if(check2.checked==true)
 {
 //查ip 所在地區(qū),未實(shí)現(xiàn)
 }
 }
 catch
 {
 messagebox.show("這個(gè)主機(jī)無法連接哦!/r/n請(qǐng)重新輸入一個(gè)正確的吧!","系統(tǒng)提示");
 txthostname.text = "";
 txthostname.focus();
 lblipinfo.text = "無法連接或轉(zhuǎn)換ip,所在地大概是外星球!";
 lblsystem.text = "待命中...";
 lblhttp.text = "待命中...";
 lblftp.text = "待命中...";
 lbldns.text = "待命中...";
 lbltelnet.text = "待命中...";
 lblsmtp.text = "待命中...";
 lblpop.text = "待命中...";
 }
 return;
 }
 
 private void detectservice(ipaddress theip)
 {
 string tftp = tcpconnect(theip,21); //is ftp service
 string ttelnet = tcpconnect(theip,23); //is telnet service
 string tdns = tcpconnect(theip,43); //is dns service
 string tpop = tcpconnect(theip,110); //is pop3 service
 string tsmtp = tcpconnect(theip,25); //is mail smtp service
 if(tftp!="none")strftp = tftp;
 if(ttelnet!="none")strtelnet = ttelnet;
 if(tdns!="none")strdns = tdns;
 if(tpop!="none")strpop = tpop;
 if(tsmtp!="none")strsmtp = tsmtp;
 
 tcpclient tcp = new tcpclient();
 tcp.connect(theip,80);
 int thttpstart;
 string thttp;
 string tmsg = "post /index.htm http/1.1/r/n" +
  "connection: keep-alive/r/n/r/n";
 stream sm = tcp.getstream();
 sm.write(encoding.default.getbytes(tmsg.tochararray()),0,tmsg.length);
 streamreader sr = new streamreader(tcp.getstream(),encoding.default);
 while(sr.peek()!=-1)
 {
 thttp= sr.readline();
 thttpstart = thttp.indexof("server");
 if(thttpstart!=-1)
 {
 strhttp = thttp;
 break;
 }
 }
 tcp.close();
 }
 
 private string tcpconnect(ipaddress theip,int port)
 {
 tcpclient tcp = new tcpclient();
 streamreader sr;
 string result;
 try
 {
 checked
 {
 tcp.connect(theip,port);
 sr = new streamreader(tcp.getstream().tostring(),encoding.default);
 result = sr.readline().tostring();
 tcp.close();
 }
 }
 catch
 {
 result = "none";
 }
 return result;
 }
 
 private void detectport(ipaddress theip)
 {
 //is
 if(strhttp.indexof("microsoft")!=-1)
 {
 strsystem = "windows";
 if(strhttp.indexof("iis")!=-1)
 {
 strsystem="windows nt/2000";
 if(strhttp.indexof("5.0")!=-1)
 strsystem="windows 2000";
 else
 strsystem="windows nt";
 }
 }
 else if(strhttp.indexof("apache")!=-1)
 {
 strsystem = "unix/linux";
 if(strhttp.indexof("unix")!=-1)
 strsystem="unix";
 }
 else
 {
 if(tcpconnect(theip,139)!="none")
 strsystem="windows 98/me";
 else if(tcpconnect(theip,1433)!="none")
 strsystem="windows nt/2000";
 else
 strsystem="windows/linux/unix";
 }
 }
 
 private void iplistbox_selectedindexchanged(object sender, system.eventargs e)
 {
 lblipinfo.text = iplistbox.text.tostring()+",所在地查詢未實(shí)現(xiàn)!";
 txthostname.text = iplistbox.text.tostring();
 }
 
 private void button1_click(object sender, system.eventargs e)
 {
 application.exit();
 }
 
 private void linklabel1_linkclicked(object sender, system.windows.forms.linklabellinkclickedeventargs e)
 {
 linklabel1.show();
 }
 
 
 完整的代碼和編譯過的程序:http://202.103.224.224/icools/bbs/non-cgi/usr/5_2.zip
 
 記得一定要裝 .net frameworksdk beta2
 
 我是初學(xué)者,有問題一起研究!
 
 by 蕭寒雪(s.f.)
發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 乌审旗| 永城市| 增城市| 石棉县| 河津市| 孟津县| 武安市| 桂林市| 阿巴嘎旗| 舞阳县| 防城港市| 贺兰县| 太白县| 延安市| 永靖县| 五指山市| 内黄县| 阿鲁科尔沁旗| 英超| 伊川县| 田阳县| 汾阳市| 柘城县| 防城港市| 鲁山县| 余江县| 梁河县| 万山特区| 格尔木市| 西吉县| 卫辉市| 霸州市| 康保县| 平武县| 中牟县| 海兴县| 泰来县| 新宁县| 蓬安县| 北流市| 惠来县|