程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> .NET網頁編程 >> ASP.NET >> 關於ASP.NET >> 一個完整的網上追捕的源代碼

一個完整的網上追捕的源代碼

編輯:關於ASP.NET

前面講過很多的用asp+實現網長追捕的程序,現在就在這裡給大家提供這個完整應用的原程序,希望大家首先先看看
以前的文章,帶者問題來看這個程序,其實是很簡單的。同時我也給大家帶來了這個程序的下載!
這個程序現在還是 有些 小問題,比如在 處理通過IP 地址查找 主機域名的時候,如果輸入的不是合法的IP地址,則程序會
返回一個錯誤,大家 如果有興趣,可以自己修改修改這個程序的:)
<%@ Import NameSpace="System.Net" %>
<% @Import Namespace="System.Net.Sockets" %>
<%@ Import Namespace="System.IO" %>
<script language="C#" runat=server>
String strRet;
protected void doClick(Object Src, EventArgs E){

if(dropdown1.SelectedItem.Value.ToInt16()==2){

IPHostEntry hostInfo = DNS.GetHostByName(txtSearch.Text);
strRet= hostInfo.AddressList[0].ToString() + "<br>"; //域名轉換成IP地址
}
else{
IPHostEntry hostInfo = DNS.GetHostByAddr(txtSearch.Text);
strRet= hostInfo.Hostname + "<br>"; //IP地址轉換成域名
}

if(CheckBox1.Checked){
String host=txtSearch.Text;

TCPClient tcpc = new TCPClient();
strRet=strRet + "SMTP Server:" + TcpConnect(tcpc,host,25) + "<br>"; //SMTP 端口

tcpc = new TCPClient();
strRet=strRet + "WWW Server:" + TcpConnect(tcpc,host,80) + "<br>"; //WWW 端口

tcpc = new TCPClient();
strRet=strRet + "FTP Server: " + TcpConnect(tcpc,host,21) + "<br>"; //FTP 端口

tcpc = new TCPClient();
strRet=strRet + "Pop3 Server:" + TcpConnect(tcpc,host,110) + "<br>"; //Pop 端口

tcpc = new TCPClient();
strRet=strRet + "代理 Server:" + TcpConnect(tcpc,host,1080) + "<br>"; //Socket5 端口 代理服務器使用的端口

tcpc = new TCPClient();
strRet=strRet + "DNS Server:" + TcpConnect(tcpc,host,53) + "<br>"; //DNS 端口
}
showmsg.Text=strRet;
}

String TcpConnect(TCPClient tcpc,String host,int port){
//這個函數的功能是 檢查 指定的 host 的 port 是否在用?
String strRet="服務沒有找到";
if(0 == tcpc.Connect(host,port)){
//聯結服務器成功
strRet="正在運行";
}
return strRet;
}

</script>
<html>
<head>
<title>WEB追捕</title>
<SCRIPT LANGUAGE="JScript">
//這兩個函數是功能是對 剪貼板 進行存取
function doufucopy() {
textRange = txtSearch.createTextRange();
textRange.execCommand("Copy");
}
function doufupaste() {
textRange = txtSearch.createTextRange();
textRange.execCommand("Paste");
}
-->
</SCRIPT>
</head>
<body>
<form id=testForm runat=server>
<asp:DropDownList id="dropdown1" runat="server">
<asp:ListItem ID=ListItem1 Value=1>查找域名</asp:ListItem>
<asp:ListItem ID=ListItem2 Value=2>查找IP</asp:ListItem>
</asp:DropDownList>
<asp:TextBox runat=server id=txtSearch />
<br>
<asp:CheckBox id="CheckBox1" runat="server" Text="檢查對方的機器" />
<br>
<asp:Button runat=server id=do Text="查找" onClick=doClick />
</form>
<asp:Label id=showmsg runat=server />
<input type=button value="復制" onclick="doufucopy();">
<input type=button value="粘貼" onclick="doufucopy();">
</body>
</html>

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved