All Projects → Snawoot → ptw

Snawoot / ptw

Licence: MIT license
Pooling TLS Wrapper

Programming Languages

python
139335 projects - #7 most used programming language
Makefile
30231 projects
Dockerfile
14818 projects

Projects that are alternatives of or similar to ptw

steady-tun
Secure TLS tunnel with pool of prepared upstream connections
Stars: ✭ 37 (+85%)
Mutual labels:  tls, ssl, tcp-proxy, pool-server, tls-tunnel, network-wrapper, tls-proxy, pooling, pooling-utility, ssl-pool
docker-ssl-reverse-proxy
Easy-to-use auto-SSL reverse proxy as a Docker container based on Caddy and Let’s Encrypt
Stars: ✭ 22 (+10%)
Mutual labels:  tls, ssl, tls-proxy
Goproxy
🔥 Proxy is a high performance HTTP(S) proxies, SOCKS5 proxies,WEBSOCKET, TCP, UDP proxy server implemented by golang. Now, it supports chain-style proxies,nat forwarding in different lan,TCP/UDP port forwarding, SSH forwarding.Proxy是golang实现的高性能http,https,websocket,tcp,socks5代理服务器,支持内网穿透,链式代理,通讯加密,智能HTTP,SOCKS5代理,黑白名单,限速,限流量,限连接数,跨平台,KCP支持,认证API。
Stars: ✭ 11,334 (+56570%)
Mutual labels:  tls, tcp-proxy, tls-proxy
Gobetween
☁️ Modern & minimalistic load balancer for the Сloud era
Stars: ✭ 1,631 (+8055%)
Mutual labels:  tls, tcp-proxy, tls-proxy
cryptonice
CryptoNice is both a command line tool and library which provides the ability to scan and report on the configuration of SSL/TLS for your internet or internal facing web services. Built using the sslyze API and ssl, http-client and dns libraries, cryptonice collects data on a given domain and performs a series of tests to check TLS configuration…
Stars: ✭ 91 (+355%)
Mutual labels:  tls, ssl
tipi
Tipi - the All-in-one Web Server for Ruby Apps
Stars: ✭ 214 (+970%)
Mutual labels:  tls, ssl
SimpleSockets
Asynchronous TCP .NET library with reliable transmission and receipt of data, with an ssl implementation.
Stars: ✭ 74 (+270%)
Mutual labels:  tls, ssl
terraform-aws-acm-request-certificate
Terraform module to request an ACM certificate for a domain name and create a CNAME record in the DNS zone to complete certificate validation
Stars: ✭ 83 (+315%)
Mutual labels:  tls, ssl
Chromium-Gost
Chromium с поддержкой алгоритмов ГОСТ
Stars: ✭ 286 (+1330%)
Mutual labels:  tls, ssl
jruby-openssl
JRuby's OpenSSL gem
Stars: ✭ 39 (+95%)
Mutual labels:  tls, ssl
XAsyncSockets
XAsyncSockets is an efficient Python/MicroPython library of managed asynchronous sockets.
Stars: ✭ 28 (+40%)
Mutual labels:  tls, ssl
python-mbedtls
Cryptographic library with an mbed TLS back end
Stars: ✭ 64 (+220%)
Mutual labels:  tls, ssl
safeminer
全网第一款本地连接矿池加密软件,隐藏本地ip、加密数据包、流量混淆,可实现防止被监管的目的
Stars: ✭ 8 (-60%)
Mutual labels:  tls, ssl
Swiddler
TCP/UDP debugging tool.
Stars: ✭ 56 (+180%)
Mutual labels:  tls, ssl
RabbitSSL
Example Java, Spring-Boot and Python RabbitMQ SSL configuration
Stars: ✭ 21 (+5%)
Mutual labels:  tls, ssl
dheater
D(HE)ater is a proof of concept implementation of the D(HE)at attack (CVE-2002-20001) through which denial-of-service can be performed by enforcing the Diffie-Hellman key exchange.
Stars: ✭ 142 (+610%)
Mutual labels:  tls, ssl
vault-pki-monitor-venafi
Venafi PKI Monitoring Secrets Engine for HashiCorp Vault that enforces security policy and provides certificate visiblity to the enterprise.
Stars: ✭ 18 (-10%)
Mutual labels:  tls, ssl
p3y
A single binary reverse proxy written in go. It was developed for use in Kubernetes, to wrap services like Prometheus with simple BasicAuth and TLS encryption.
Stars: ✭ 15 (-25%)
Mutual labels:  tls, tls-proxy
Openssl
TLS/SSL and crypto library
Stars: ✭ 17,157 (+85685%)
Mutual labels:  tls, ssl
hudsucker
Intercepting HTTP/S proxy
Stars: ✭ 114 (+470%)
Mutual labels:  tls, ssl

ptw

ptw

Pooling TLS Wrapper

Accepts TCP connections on listen port and forwards them, wrapped in TLS, to destination port. ptw maintains pool of fresh established TLS connections effectively cancelling delay caused by TLS handshake.

ptw may serve as drop-in replacement for stunnel or haproxy for purpose of secure tunneling of TCP connections. Thus, it is intended for use with stunnel or haproxy on server side, accepting TLS connections and forwarding them, for example, to SOCKS proxy. In such configuration make sure your server timeouts long enough to allow fit lifetime of idle client TLS sessions (-T option).

ptw can be used with custom CAs and/or mutual TLS auth with certificates.


❤️ ❤️ ❤️

You can say thanks to the author by donations to these wallets:

  • ETH: 0xB71250010e8beC90C5f9ddF408251eBA9dD7320e
  • BTC:
    • Legacy: 1N89PRvG1CSsUk9sxKwBwudN6TjTPQ1N8a
    • Segwit: bc1qc0hcyxc000qf0ketv4r44ld7dlgmmu73rtlntw

Features

  • Based on proven TLS security and works with well-known server side daemons for TLS termination like haproxy and stunnel.
  • Firewall- and DPI-proof: connections are indistinguishable from HTTPS traffic. See haproxy.cfg in config_examples directory for complete example of webserver masquerading proxy.
  • Greater practical performance comparing to other TCP traffic forwading solutions thanks to separate TLS session for each TCP connection.
  • Hides TLS connection delay with connection pooling.
  • Supports transparent proxy mode.
  • Supports TLS SNI (server name indication) spoof - it may be useful to bypass SNI based filters in firewalls.
  • Cross-plaform: runs on Linux, macOS, Windows and other Unix-like systems.

Requirements

  • Python 3.5.3+

Installation

From source

Run within source directory:

pip3 install .

From PyPI

pip3 install ptw

Docker

ptw is also provided as docker image. You may run it like this:

docker run -it --rm yarmak/ptw --help

In addition, there are docker-compose recipes for deployment of client (ptw) and server suite (haproxy with mutual TLS auth, Dante SOCKS proxy and decoy HTTP-server). See docker_deploy directory for complete docker deployment guide.

Snap Store

Get it from the Snap Store

sudo snap install ptw

Usage

See quickcerts for easy TLS certificate generator.

Wrapper for SOCKS/HTTP proxy

ptw -c mycert.pem -k mykey.pem -C ca.pem -n 50 -T 300 example.com 1443

Corresponding minimal haproxy configuration on server:

...

defaults
    log       global
    mode      tcp
    option    tcplog
    option    dontlognull
    timeout connect 5000
    timeout check   5000
    timeout client  600000
    timeout server  600000
    timeout tunnel  0

frontend socks-proxy
    bind *:1443 ssl crt /etc/haproxy/server.combined.pem ca-file /etc/haproxy/ca.pem verify required
    default_backend socks-proxy

backend socks-proxy
    server localsocks 127.0.0.1:1080

This command will accept TCP connections on port 57800, wrap them in TLS and forward them to port 1443 of example.com host, maintaining pool of at least 50 TLS connections no older than 300 seconds. For client TLS authentication see also -c and -k options.

See also config_examples directory for full configuration files for haproxy and danted.

Transparent proxy for TCP connections

Run on your router:

ptw -a 0.0.0.0 -c mycert.pem -k mykey.pem -C ca.pem -n 50 -T 300 -P v1 example.com 2443

Add following rule to iptables:

iptables -I PREROUTING 1 -t nat -p tcp -s 192.168.0.0/16 '!' -d 192.168.0.0/16 -j REDIRECT --to 57800

Assuming your local network is covered by prefix 192.168.0.0/16.

Corresponding haproxy config sections:

frontend tls-wrapper
    bind *:2443 ssl crt /etc/haproxy/server.combined.pem ca-file /etc/haproxy/ca.pem verify required
    default_backend strip-proxy

backend strip-proxy
    server strip-proxy 127.0.0.1:41718

frontend strip-proxy
    bind 127.0.0.1:41718 accept-proxy
    default_backend passthrough

backend passthrough
    server direct *

This setup will redirect all TCP connections in your network. If your server supports proxy protocol version 2, you may use it as well (option -P v2).

Universal haproxy configuration

Also you may share PROXY protocol, SOCKS protocol listener and decoy webserver on single external port. See haproxy.cfg in config_examples directory.

Synopsis

$ ptw --help
usage: ptw [-h] [-v {debug,info,warn,error,fatal}] [-l FILE]
           [--disable-uvloop] [-a BIND_ADDRESS] [-p BIND_PORT]
           [-W POOL_WAIT_TIMEOUT] [-P {none,v1,v2}] [-n POOL_SIZE]
           [-B BACKOFF] [-T TTL] [-w TIMEOUT] [-c CERT] [-k KEY] [-C CAFILE]
           [--no-hostname-check | --tls-servername TLS_SERVERNAME]
           dst_address dst_port

Pooling TLS wrapper

positional arguments:
  dst_address           target hostname
  dst_port              target port

optional arguments:
  -h, --help            show this help message and exit
  -v {debug,info,warn,error,fatal}, --verbosity {debug,info,warn,error,fatal}
                        logging verbosity (default: info)
  -l FILE, --logfile FILE
                        log file location (default: None)
  --disable-uvloop      do not use uvloop even if it is available (default:
                        False)

listen options:
  -a BIND_ADDRESS, --bind-address BIND_ADDRESS
                        bind address (default: 127.0.0.1)
  -p BIND_PORT, --bind-port BIND_PORT
                        bind port (default: 57800)
  -W POOL_WAIT_TIMEOUT, --pool-wait-timeout POOL_WAIT_TIMEOUT
                        timeout for pool await state of client connection
                        (default: 15)
  -P {none,v1,v2}, --proxy-protocol {none,v1,v2}
                        transparent mode: prepend all connections with proxy-
                        protocol data (default: none)

pool options:
  -n POOL_SIZE, --pool-size POOL_SIZE
                        connection pool size (default: 25)
  -B BACKOFF, --backoff BACKOFF
                        delay after connection attempt failure in seconds
                        (default: 5)
  -T TTL, --ttl TTL     lifetime of idle pool connection in seconds (default:
                        30)
  -w TIMEOUT, --timeout TIMEOUT
                        server connect timeout (default: 4)

TLS options:
  -c CERT, --cert CERT  use certificate for client TLS auth (default: None)
  -k KEY, --key KEY     key for TLS certificate (default: None)
  -C CAFILE, --cafile CAFILE
                        override default CA certs by set specified in file
                        (default: None)
  --no-hostname-check   do not check hostname in cert subject. This option is
                        useful for private PKI and available only together
                        with "--cafile" (default: False)
  --tls-servername TLS_SERVERNAME
                        specifies hostname to expect in server TLS certificate
                        (default: None)
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].