erebe / wstunnel

Tunnel all your traffic over Websocket or HTTP2 - Bypass firewalls/DPI - Static binary available
Other
3.22k stars 289 forks source link

v7x - Host header sent twice when specifying HOST header with --http-headers #173

Closed bluewalk closed 6 months ago

bluewalk commented 6 months ago

Describe the bug As per documentation when specifying SNI you also need to include the HOST header.

      --tls-sni-override <DOMAIN_NAME>
          Domain name that will be use as SNI during TLS handshake
          Warning: If you are behind a CDN (i.e: Cloudflare) you must set this domain also in the http HOST header.
                   or it will be flagged as fishy and your request rejected

However the host header is already added here: https://github.com/erebe/wstunnel/blob/7cafa674ba8ad6d7e2cf8357af73074d0ee53e17/src/tunnel/client.rs#L61

Resulting in two HOST headers int he request, thus failing to connect.

GET https://cloudflareIP/mysecretpath/events?bearer=xxxkHCzcSnMJeA-9zMyI HTTP/1.1
host: cloudflareIP
host: myhost
upgrade: websocket
connection: upgrade
sec-websocket-key: xxx
sec-websocket-version: 13

To Reproduce Run wstunnel wstunnel client wss://cloudflareIP -L tcp://8085:127.0.0.1:8085 -p http://127.0.0.1:8888 -c 3 --http-upgrade-path-prefix mysecretpath --tls-sni-override myhost --http-headers "Host: myhost"

Expected behavior Only one host header, default but when specified by the headers parameter it should override existing headers.

erebe commented 6 months ago

Fixed in the new release https://github.com/erebe/wstunnel/releases/tag/v7.5.0

bluewalk commented 6 months ago

I can confirm it's fixed, works perfectly now!