Added SOCKS5 proxy support via `socks` library

Added SOCKS5 proxy support via `socks` library. For further information see
changes in `README.md`.
This commit is contained in:
albocc 2016-11-29 19:26:54 +01:00
parent db4c9b19d9
commit 47ee46d7e2
2 changed files with 18 additions and 0 deletions

View File

@ -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.

View File

@ -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: