From 47ee46d7e201d365606555f3578bfb40aa469329 Mon Sep 17 00:00:00 2001 From: albocc Date: Tue, 29 Nov 2016 19:26:54 +0100 Subject: [PATCH] Added SOCKS5 proxy support via `socks` library Added SOCKS5 proxy support via `socks` library. For further information see changes in `README.md`. --- README.md | 8 ++++++++ slowloris.py | 10 ++++++++++ 2 files changed, 18 insertions(+) diff --git a/README.md b/README.md index e95bb06..cbb7b79 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,14 @@ If you want to clone using git instead of pip, here's how you do it. * `cd slowloris` * `python3 slowloris.py example.com` +### SOCKS5 proxy support + +However, if you plan on using the `-x` option in order to use a SOCKS5 proxy for connecting instead of a direct connection over your IP address, you will need to install the `PySocks` library (or any other implementation of the `socks` library) as well. [`PySocks`](https://github.com/Anorov/PySocks) is a fork from [`SocksiPy`](http://socksipy.sourceforge.net/) by GitHub user @Anorov and can easily be installed by adding `PySocks` to the `pip` command above or running it again like so: + +* `sudo pip3 install PySocks` + +You can then use the `-x` option to activate SOCKS5 support and the `--proxy-host` and `--proxy-port` option to specify the SOCKS5 proxy host and its port, if they are different from the standard `127.0.0.1:8080`. + ## Configuration options It is possible to modify the behaviour of slowloris with command-line arguments. diff --git a/slowloris.py b/slowloris.py index 9484ff8..8a24809 100644 --- a/slowloris.py +++ b/slowloris.py @@ -6,8 +6,12 @@ parser.add_argument('-p', '--port', default=80, help="Port of webserver, usually parser.add_argument('-s', '--sockets', 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.set_defaults(verbose=False) parser.set_defaults(randuseragent=False) +parser.set_defaults(useproxy=False) args = parser.parse_args() if len(sys.argv)<=1: @@ -19,6 +23,12 @@ if not args.host: parser.print_help() sys.exit(1) +if args.useproxy: + print("Using SOCKS5 proxy for connecting...") + import socks + socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5, args.proxy_host, args.proxy_port) + socket.socket = socks.socksocket + if args.verbose == True: logging.basicConfig(format="[%(asctime)s] %(message)s", datefmt="%d-%m-%Y %H:%M:%S", level=logging.DEBUG) else: