using System;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading;
class Program
{
static void Main(string[] args)
{
if (args.Length < 3)
{
Console.WriteLine("Usage: Fuzzer.exe <host> <port> <duration>");
return;
}
string host = args[0];
int port = int.Parse(args[1]);
int duration = int.Parse(args[2]);
try
{
using (TcpClient client = new TcpClient())
{
client.Connect(host, port);
NetworkStream stream = client.GetStream();
DateTime startTime = DateTime.Now;
while ((DateTime.Now - startTime).TotalSeconds < duration)
{
string fuzzData = GenerateFuzzData();
byte[] buffer = Encoding.ASCII.GetBytes(fuzzData);
stream.Write(buffer, 0, buffer.Length);
Thread.Sleep(100); // Attendre un peu avant de réessayer
}
}
}
catch (Exception ex)
{
Console.WriteLine("Error: " + ex.Message);
}
}
static string GenerateFuzzData()
{
StringBuilder sb = new StringBuilder();
Random rand = new Random();
int length = rand.Next(10, 100); // Génère une chaîne aléatoire de 10 à 100 caractères
for (int i = 0; i < length; i++)
{
sb.Append((char)rand.Next(32, 126)); // Caractères aléatoires ASCII imprimables
}
return sb.ToString();
}
}