Irrigation applet (aspx)

Source: Internet
Author: User

The remote submission form and irrigation process are simple. If the message board has a verification code, it will be over.

 

Core code block

String url = "http: // localhost: 3359/web/message. aspx ";

# Region // accept the returned page
// Method 1
// Httpwebrequest request = webrequest. Create (URL) as httpwebrequest;
// Request. method = "get ";
// Request. keepalive = false;
// Httpwebresponse response = request. getresponse () as httpwebresponse;
// Stream = response. getresponsestream ();
// Streamreader reader = new streamreader (stream, encoding. utf8 );
// String srcstring = reader. readtoend ();

// Method 2
WebClient = new WebClient ();
Byte [] responsebytes = WebClient. downloaddata (URL );
String srcstring = encoding. utf8.getstring (responsebytes );

# Endregion

// Obtain the veiwstate of the page
String regviewstate = "<input type = \" Hidden \ "name = \" _ viewstate \ "id = \" _ viewstate \ "value = \"(? <Viewstate> [^ \ s \ t \ r \ n \ "\" '<>] *) \ "/> ";
Match mathview = RegEx. Match (srcstring, regviewstate, regexoptions. ignorecase | regexoptions. multiline );
String viewstate = mathview. Groups [1]. value;

// Obtain eventvalidation of the page
String regevent = "<input type = \" Hidden \ "name = \" _ eventvalidation \ "id = \" _ eventvalidation \ "value = \"(? <Viewstate> [^ \ s \ t \ r \ n \ "\" '<>] *) \ "/> ";
Match matchevent = RegEx. Match (srcstring, regevent, regexoptions. ignorecase | regexoptions. multiline );
String eventvalidation = matchevent. Groups [1]. value;

// Automatically submit
String submitbutton = "message ";
String txttitle = this.txt content. Text; // Title
String txtcontent = this.txt title. Text; // message content

// Convert the text into a URL encoded string
Viewstate = system. Web. httputility. urlencode (viewstate );
Eventvalidation = system. Web. httputility. urlencode (eventvalidation );
Submitbutton = system. Web. httputility. urlencode (submitbutton );

// String data to be submitted. Format: User = uesr1 & Password = 123
String poststring = string. format ("txttitle = {0} & txtcontent = {1}" + "& btnsave =" + submitbutton + "& __ viewstate =" + viewstate + "& __ eventvalidation =" + eventvalidation, txttitle, txtcontent );
Byte [] postdata = encoding. utf8.getbytes (poststring); // converts a string to a byte array

// Submit cyclically
Int num = convert. toint32 (txtnum. Text );
For (INT I = 0; I <= num; I ++)
{
WebClient = new WebClient ();
WebClient. headers. Add ("Content-Type", "application/X-WWW-form-urlencoded ");
WebClient. uploaddata (URL, "Post", postdata); // uploads data and returns the byte array of the page.
}
Clientscriptmanager cs = page. clientscript;
CS. registerclientscriptblock (typeof (PAGE), "", "<SCRIPT> alert ('execution completed '); </SCRIPT> ");

 

Download source file

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.