Tunnel all your traffic over Websocket or HTTP2 - Bypass firewalls/DPI - Static binary available
Tunnel all your traffic over Websocket or HTTP2 - Bypass firewalls/DPI - Static binary available
Most of the time when you are using a public network, you are behind some kind of firewall or proxy. One of their purpose is to constrain you to only use certain kind of protocols and consult only a subset of the web. Nowadays, the most widespread protocol is http and is de facto allowed by third party equipment.
Wstunnel uses the websocket protocol which is compatible with http in order to bypass firewalls and proxies. Wstunnel allows you to tunnel whatever traffic you want and access whatever resources/site you need.
My inspiration came from this project but as I don't want to install npm and
nodejs to use this tool, I remade it in Haskell Rust and improved it.
What to expect:
Part of Wstunnel development has been sponsored by
v7.0.0 is a complete rewrite of wstunnel in Rust and is not compatible with previous version. Previous code in Haskell can be found on branch https://github.com/erebe/wstunnel/tree/haskell
What to expect from previous version:
If you just want to try out that you can bypass your proxy/firewall. You can give it a try with wstunnel demo server.
# In a terminal start wstunnel client
# You can set as tls-sni-override whatever domain you want. The tunnel is the only one that is going to be allowed.
wstunnel client -L 'tcp://4443:10.43.0.11:443' -P demo --tls-sni-override=google.fr wss://ws.erebe.dev
# on another terminal, run curl and it should return you this greetings
curl -k https://localhost:4443
> Memento mori !……Static binaries are available in release section
docker image are available at https://github.com/erebe/wstunnel/pkgs/container/wstunnel
docker pull ghcr.io/erebe/wstunnel:latestWstunnel command line mimic ssh tunnel syntax. You can take reference to this article, or this diagram to understand
On your remote host, start the wstunnel's server by typing this command in your terminal
wstunnel server wss://[::]:8080This will create a websocket server listening on any interface on port 8080. On the client side use this command to forward traffic through the websocket tunnel
wstunnel client -L socks5://127.0.0.1:8888 --connection-min-idle 5 wss://myRemoteHost:8080This command will create a socks5 server listening on port 8888 of the loopback interface and will forward traffic
dynamically.
connection-min-idle 10 is going an optimization to create a pool of 10 connection connected to the server, to speed-up
the establishement of new tunnels.
With firefox you can setup a proxy using this tunnel, by setting in networking preferences 127.0.0.1:8888 and selecting
socks5 proxy.
Be sure to check the option Proxy DNS when using SOCKS v5 for the server to resolve DNS name and not your local
machine.
or with curl
curl -x socks5h://127.0.0.1:8888 http://google.com/
#Please note h after the 5, it is to avoid curl resolving DNS name locallyYou can specify stdio as source port on the client side if you wish to use wstunnel as part of a proxy command for ssh
ssh -o ProxyCommand="wstunnel client --log-lvl=off -L stdio://%h:%p ws://myRemoteHost:8080" my-serverAn other useful example is when you want to bypass an http proxy (a corporate proxy for example) The most reliable way to do it is to use wstunnel as described below
Start your wstunnel server with tls activated
wstunnel server wss://[::]:443 --restrict-to 127.0.0.1:22The server will listen on any interface using port 443 (https) and restrict traffic to be forwarded only to the ssh daemon.
Be aware that the server will use self signed certificate with weak cryptographic algorithm. It was made in order to add the least possible overhead while still being compliant with tls.
Do not rely on wstunnel to protect your privacy, if it is one of your concerns, you should only forwards traffic that is already secure by design (ie: https or vpn traffic)
Now on the client side start the client with
wstunnel client -L tcp://9999:127.0.0.1:22 -p http://mycorporateproxy:8080 wss://myRemoteHost:443It will start a tcp server on port 9999 that will contact the corporate proxy, negotiate a tls connection with the remote host and forward traffic to the ssh daemon on the remote host.
You may now access your server from your local machine on ssh by using
ssh -p 9999 [email protected]You can find a full tutorial that explain how to setup wstunnel and wireguard at here
For a quick explanation see below.
You have a working wireguard client configuration called wg0.conf. Let's say
[Interface]
Address = 10.200.0.2/32, fd00:cafe::2/128
PrivateKey = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx=
[Peer]
PublicKey = 9iicV7Stdl/U0RH1BNf3VvlVjaa4Eus6QPEfEz6cR0c=
AllowedIPs = 0.0.0.0/0, ::/0
Endpoint = my.server.com:51820Start wstunnel server on my.server.com like this
wstunnel server --restrict-to localhost:51820 wss://[::]:443on your local machine start the client like this
wstunnel client -L 'udp://51820:localhost:51820?timeout_sec=0' wss://my.server.com:443change your wireguard client config to something
[Interface]
Address = 10.200.0.2/32, fd00:cafe::2/128
PrivateKey = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx=
# Replace by a dns your server has access to
dns = 8.8.8.8
# https://github.com/nitred/nr-wg-mtu-finder to find best mtu for you
MTU = 1400
[Peer]
PublicKey = 9iicV7Stdl/U0RH1BNf3VvlVjaa4Eus6QPEfEz6cR0c=
AllowedIPs = 0.0.0.0/0, ::/0
# Should target port where wstunnel client is listenning to
Endpoint = localhost:51820
# Should not be necessary if you enable wstunnel client websocket ping
PersistentKeepalive = 20Add a default route to your server, as your AllowedIps are catch-all, it is to avoid the traffic looping.
sudo ip route add ip.of.my.server.com dev eth0 via 192.168.0.1
# replace eth0 (interface) and 192.168.0.1 (router gateway) by the one given by `ip route get ip.of.my.server.com` start your wireguard, and it should be working
sudo wg-quick up wg0
ping 10.200.0.1 # ping another ip of your vpn networkFAQ
i.e: udp://1212:127.0.0.1:5201?timeout_sec=0You can use the android binary and use termux to run it on your phone.
If you want a guide regarding how to use wstunnel on Android, you can follow this guide
Transparent proxy allows to easily proxy any program. Start wstunnel with
sudo wstunnel client -L 'tproxy+tcp://1080' -L 'tproxy+udp://1080' wss://my.server.com:443use this project to route traffic seamlessly https://github.com/NOBLES5E/cproxy. It works with any program
cproxy --port 1080 --mode tproxy -- curl https://google.comYou can even start a new shell, were all your commands will be proxyfied
cproxy --port 1080 --mode tproxy -- bashStart wstunnel with
sudo wstunnel client -R 'tcp://[::]:8000:localhost:8000' wss://my.server.com:443In another terminal, start a simple webserver on your local machine
python3 -m http.serverFrom your my.server.com machine/network you can now do
curl http://localhost:8000Generate a secret, let's say h3GywpDrP6gJEdZ6xbJbZZVFmvFZDCa4KcRd
Now start you server with the following command
wstunnel server --restrict-http-upgrade-path-prefix h3GywpDrP6gJEdZ6xbJbZZVFmvFZDCa4KcRd wss://[::]:443 And start your client with
wstunnel client --http-upgrade-path-prefix h3GywpDrP6gJEdZ6xbJbZZVFmvFZDCa4KcRd ... wss://myRemoteHostNow your wstu
11.0.0 Tests fail on OpenBSD
HTTP proxy answers an unauthenticated CONNECT with 401 instead of 407, so clients that wait for a challenge never authenticate
Latest client version on Windows 11 with MS Defender detecting VAC and delete executable
PowerShell client -> company proxy -> nginx -> wstunnel server scenario issues
Better support for multi-loopback scenarios
Multipath TCP (MPTCP) + wstunnel
Feature request - Improvement suggestions for enhancing security protection
Runtime errors on Windows 2008 and Windows 7
Weird results in iperf3 tests
Windows Defender flags newest wstunnel.exe as trojan