Skip to main content

Transparent proxy in python

Project description


python script to transparently forward all TCP traffic through a socks (like ssh -D option) or HTTPS (CONNECT) proxy using iptables -j REDIRECT target. Only works on linux for now.

Features :

  • set up a local transparent proxy compatible with socks4 socks5 and HTTP CONNECT proxies allowing to forward any TCP traffic transparently using iptables

Usage example: let's rock

As an example we will use the socks5 proxy of openssh (the option -D)

$ ssh -D 1080 user@sshserver

then you can add some iptables rules :

$ iptables -t nat -A OUTPUT ! -d <my_ssh_server_IP>/32 -o eth0 -p tcp -m tcp -j REDIRECT --to-ports 10080

then start pr0cks :

$ pr0cks --proxy SOCKS5:

All your TCP traffic and DNS traffic should now pass through the ssh server kinda like if you had setup a tun VPN through ssh but without admin rights on the server ! #help

pr0cks -h
usage: procks [-h] [--type {HTTP,SOCKS4,SOCKS5}] [-p PORT] [-n] [-v] [-c]
              [--username USERNAME] [--password PASSWORD]
              proxy_addr proxy_port


positional arguments:

optional arguments:
  -h, --help            show this help message and exit
  --type {HTTP,SOCKS4,SOCKS5}
                        The type of proxy to forward the traffic to
  -p PORT, --port PORT  port to bind the transparent proxy on the local socket
                        (default 10080)
  -n, --nat             set bind address to to make pr0cks work from a
                        netfilter FORWARD rule instead of OUTPUT
  -v, --verbose         print all the connections requested through the proxy
  -c, --no-cache        don't cache dns requests
  --username USERNAME   Username to authenticate with to the server. The
                        default is no authentication.
  --password PASSWORD   Only relevant when a username has been provided


  • tested with Python 3.6


  • support UDP (with socks5)
  • support proxy chaining

Don't hesitate to send me your feedback or any issue you may find

I hope it will be useful to someone ! Have fun :)

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pr0cks-0.2.1.tar.gz (18.2 kB view hashes)

Uploaded Source

Built Distribution

pr0cks-0.2.1-py3-none-any.whl (19.9 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page