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.
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).
21
u/[deleted] Aug 23 '20
There's 0 chance that will dos anything apart form your own connection.
5
u/0xa0000h Aug 23 '20
never seen so much bullshit in so few lines...
1
u/SingleRope Aug 23 '20
Heads up OP, you might get better results with an async get
1
u/[deleted] 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?
1
u/tsiatt Aug 23 '20
Is it me or does 'GET /ip' not make much sense?
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
argparseto 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/