Java writes a small fuzz program.

Source: Internet
Author: User

I am not busy this week, I have nothing to do, and I have nothing to do.

CrackVote. java

Package crack;

Import java. io. OutputStreamWriter;
Import java.net. HttpURLConnection;
Import java.net. URL;
Import java. util. Iterator;
Import java. util. Map;
Import java. util. Map. Entry;
Public class CrackVote implements Runnable {

Private HttpURLConnection conn = null;
String urlAddr;
Map map;
Int num;
Public CrackVote (String urlAddrTest, Map mapTest, int num ){
UrlAddr = urlAddrTest;
Map = mapTest;
Num = num;
}
@ Override
Public void run (){
While (true ){
Boolean isSuccess = false;
StringBuffer params = new StringBuffer ();
Iterator it = map. entrySet (). iterator ();
While (it. hasNext ()){
Entry element = (Entry) it. next ();
Params. append (element. getKey ());
Params. append ("= ");
Params. append (element. getValue ());
Params. append ("&");
}
If (params. length ()> 0 ){
Params. deleteCharAt (params. length ()-1 );
}
Try {
URL url = new URL (urlAddr );
Conn = (HttpURLConnection) url. openConnection ();

Conn. setDoOutput (true );
Conn. setRequestMethod ("POST ");
Conn. setUseCaches (false );
Conn. setRequestProperty ("Content-Type", "application/x-www-form-urlencoded ");
Conn. setRequestProperty ("User-Agent", "Mozilla/5.0 (Windows; U; Windows NT 5.2; zh-CN; rv: 1.9) Gecko/2008052906 Firefox/3.0 ");
Conn. setRequestProperty ("Accept", "text/html, application/xhtml + xml, application/xml; q = 0.9, */*; q = 0.8 ");
Conn. setRequestProperty ("Accept-Language", "zh-cn, zh; q = 0.5 ");
Conn. setRequestProperty ("Referer", "xxx ");
Conn. setRequestProperty ("Content-Length", String. valueOf (params. length ()));
Conn. setDoInput (true );
Conn. connect ();

OutputStreamWriter out = new OutputStreamWriter (conn. getOutputStream (), "UTF-8 ");
Out. write (params. toString ());
Out. flush ();
Out. close ();

Int code = conn. getResponseCode ();
If (code! = 200 ){
System. out. println ("ERROR =" + code );
} Else {
IsSuccess = true;
System. out. println ("Success! ");
}
} Catch (Exception ex ){
Ex. printStackTrace ();
} Finally {
Conn. disconnect ();
}
}
}

}

 

Crack. java

Package crack;
Import java. util. HashMap;
Import java. util. Map;

Import crack. CrackVote;

Public class Crack {

Public static void main (String args []) {
Map hash = new HashMap ();
Hash. put ("id", "25 ");
Hash. put ("button", "% CD % B6 % D2 % BB % C6 % B1 ");
String addstr = "asp"> http://www.xxx.com/xxx/6/vote_pass.asp ";
For (int I = 0; I <20; I ++ ){
// CrackVote crackvote = new CrackVote (addstr, hash, I );
// New Thread (crackvote). start ();
New Thread (new CrackVote (addstr, hash, I). start ();
}

}
 
}

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.