r/Python • u/progsNyx • Aug 23 '20
Beginner Showcase A DoS attack in 15 lines of code.
Hi, I have tried to create the simplest possible denial of service attack; for this script, I have not used more than 15 lines of code, and it is a fully functional attack setting the values of the variables "ip", "port" and "threads". For example:
ip, port, threads = "192.13.451.153", 8080, 1000
I have tried to follow the PEP8 standards as much as possible; I hope you like it.
Post data: I have only done this to practice my knowledge with Python, I am not responsible for the use you make with this.
Edit: I know the attack will not work in almost all of the cases, most of servers are fully prepared to avoid a dos attack, the attack will just ban your IP in 99% of the times.
21
5
1
1
Aug 23 '20
How is this working when your first line in main is assigning 3 string into 3 variables but then you did a range on threads variable which is a string when range expects a number?
2
u/poltoid Aug 23 '20
The 3 strings on the right of the assignment are placeholders for real values, whose types are indicated in the strings
-3
Aug 23 '20
Why hide those values? You can easily replace them with random correct values instead of making the code confusing.
0
Aug 23 '20
[removed] — view removed comment
1
u/notadoctororacake Aug 23 '20
Don't DoS anyone, but just replace those strings with the correct info in the variable types within the square brackets
1
1
u/Trdp8737 Aug 23 '20
It's only going to work in a limited number of outdated servers having the CRLF vulnerability.
1
u/qckpckt Aug 23 '20
I’m not sure you can really do much with a single client DOS attack.
WRT the code I would recommend using argparse to make those parameters command line arguments and also perform type validation.
-1
u/For15min Aug 23 '20
The DDOS script in this course is more efficient, sure, not in 15 lines.
https://www.freecodecamp.org/news/python-networking-course/
9
u/[deleted] Aug 23 '20
> I have tried to follow the PEP8 standards as much as possible
Maybe you are aware of it, but if you are not (or if someone else that doesn't know read this) here is a useful information, most IDE have an auto-format function that do it automatically (I personaly use PyCharm - command: ctrl + alt + L).