|
15 | 15 | - [Usage](#usage) |
16 | 16 | - [Configuration via CLI flags](#configuration-via-cli-flags) |
17 | 17 | - [Configuration via YAML file](#configuration-via-yaml-file) |
18 | | -- [Transparent proxy](#usage) |
| 18 | +- [Transparent proxy](#transparent-proxy) |
19 | 19 | - [redirect (via NAT and SO_ORIGINAL_DST)](#redirect-via-nat-and-so_original_dst) |
20 | 20 | - [tproxy (via MANGLE and IP_TRANSPARENT)](#tproxy-via-mangle-and-ip_transparent) |
| 21 | +- [Traffic sniffing](#traffic-sniffing) |
21 | 22 | - [Links](#links) |
22 | 23 | - [License](#license) |
23 | 24 |
|
@@ -51,6 +52,9 @@ Specify http server in proxy configuration of Postman |
51 | 52 | - **Transparent proxy** |
52 | 53 | Supports `redirect` (SO_ORIGINAL_DST) and `tproxy` (IP_TRANSPARENT) modes |
53 | 54 |
|
| 55 | +- **Traffic sniffing** |
| 56 | + Proxy is able to parse HTTP headers and TLS handshake metadata |
| 57 | + |
54 | 58 | - **DNS Leak Protection** |
55 | 59 | DNS resolution occurs on SOCKS5 server side. |
56 | 60 |
|
@@ -82,7 +86,7 @@ You can download the binary for your platform from [Releases](https://github.com |
82 | 86 | Example: |
83 | 87 |
|
84 | 88 | ```shell |
85 | | -HPTS_RELEASE=v1.6.1; wget -v https://github.com/shadowy-pycoder/go-http-proxy-to-socks/releases/download/$HPTS_RELEASE/gohpts-$HPTS_RELEASE-linux-amd64.tar.gz -O gohpts && tar xvzf gohpts && mv -f gohpts-$HPTS_RELEASE-linux-amd64 gohpts && ./gohpts -h |
| 89 | +HPTS_RELEASE=v1.7.0; wget -v https://github.com/shadowy-pycoder/go-http-proxy-to-socks/releases/download/$HPTS_RELEASE/gohpts-$HPTS_RELEASE-linux-amd64.tar.gz -O gohpts && tar xvzf gohpts && mv -f gohpts-$HPTS_RELEASE-linux-amd64 gohpts && ./gohpts -h |
86 | 90 | ``` |
87 | 91 |
|
88 | 92 | Alternatively, you can install it using `go install` command (requires Go [1.24](https://go.dev/doc/install) or later): |
@@ -119,32 +123,36 @@ GitHub: https://github.com/shadowy-pycoder/go-http-proxy-to-socks |
119 | 123 | Usage: gohpts [OPTIONS] |
120 | 124 | Options: |
121 | 125 | -h Show this help message and exit. |
122 | | - -D Run as a daemon (provide -logfile to see logs) |
| 126 | + -D Run as a daemon (provide -logfile to see logs) |
123 | 127 | -M value |
124 | | - Transparent proxy mode: [redirect tproxy] |
| 128 | + Transparent proxy mode: [redirect tproxy] |
125 | 129 | -T string |
126 | | - Address of transparent proxy server (no HTTP) |
| 130 | + Address of transparent proxy server (no HTTP) |
127 | 131 | -U string |
128 | | - User for HTTP proxy (basic auth). This flag invokes prompt for password (not echoed to terminal) |
| 132 | + User for HTTP proxy (basic auth). This flag invokes prompt for password (not echoed to terminal) |
129 | 133 | -c string |
130 | | - Path to certificate PEM encoded file |
131 | | - -d Show logs in DEBUG mode |
| 134 | + Path to certificate PEM encoded file |
| 135 | + -d Show logs in DEBUG mode |
132 | 136 | -f string |
133 | | - Path to server configuration file in YAML format |
134 | | - -j Show logs in JSON format |
| 137 | + Path to server configuration file in YAML format |
| 138 | + -j Show logs in JSON format |
135 | 139 | -k string |
136 | | - Path to private key PEM encoded file |
| 140 | + Path to private key PEM encoded file |
137 | 141 | -l string |
138 | | - Address of HTTP proxy server (default "127.0.0.1:8080") |
| 142 | + Address of HTTP proxy server (default "127.0.0.1:8080") |
139 | 143 | -logfile string |
140 | | - Log file path (Default: stdout) |
| 144 | + Log file path (Default: stdout) |
141 | 145 | -s string |
142 | | - Address of SOCKS5 proxy server (default "127.0.0.1:1080") |
| 146 | + Address of SOCKS5 proxy server (default "127.0.0.1:1080") |
| 147 | + -sniff |
| 148 | + Enable traffic sniffing for HTTP and TLS |
| 149 | + -snifflog string |
| 150 | + Sniffed traffic log file path (Default: the same as -logfile) |
143 | 151 | -t string |
144 | | - Address of transparent proxy server (it starts along with HTTP proxy server) |
| 152 | + Address of transparent proxy server (it starts along with HTTP proxy server) |
145 | 153 | -u string |
146 | | - User for SOCKS5 proxy authentication. This flag invokes prompt for password (not echoed to terminal) |
147 | | - -v print version |
| 154 | + User for SOCKS5 proxy authentication. This flag invokes prompt for password (not echoed to terminal) |
| 155 | + -v print version |
148 | 156 | ``` |
149 | 157 |
|
150 | 158 | ### Configuration via CLI flags |
@@ -397,6 +405,144 @@ ip netns del ns-client |
397 | 405 | ip link del veth1 |
398 | 406 | ``` |
399 | 407 |
|
| 408 | +## Traffic sniffing |
| 409 | + |
| 410 | +[[Back]](#table-of-contents) |
| 411 | + |
| 412 | +`GoHPTS` proxy allows one to capture and monitor traffic that goes through the service. This procces is known as `traffic sniffing`, `packet sniffing` or just `sniffing`. In particular, proxy tries to identify whether it is a plain text (HTTP) or TLS traffic, and after identification is done, it parses request/response metadata and writes it to the file or console. In the case of `GoHTPS` proxy a parsed metadata looks like the following (TLS Handshake): |
| 413 | + |
| 414 | +```json |
| 415 | +[ |
| 416 | + { |
| 417 | + "connection": { |
| 418 | + "tproxy_mode": "redirect", |
| 419 | + "src_local": "127.0.0.1:8888", |
| 420 | + "src_remote": "192.168.0.107:51142", |
| 421 | + "dst_local": "127.0.0.1:56256", |
| 422 | + "dst_remote": "127.0.0.1:1080", |
| 423 | + "original_dst": "216.58.209.206:443" |
| 424 | + } |
| 425 | + }, |
| 426 | + { |
| 427 | + "tls_request": { |
| 428 | + "sni": "www.youtube.com", |
| 429 | + "type": "Client hello (1)", |
| 430 | + "version": "TLS 1.2 (0x0303)", |
| 431 | + "session_id": "2670a6779b4346e5e84d46890ad2aaf7a53b08adcfe0c9f6868c2d9882242e39", |
| 432 | + "cipher_suites": [ |
| 433 | + "TLS_AES_128_GCM_SHA256 (0x1301)", |
| 434 | + "TLS_CHACHA20_POLY1305_SHA256 (0x1303)", |
| 435 | + "TLS_AES_256_GCM_SHA384 (0x1302)", |
| 436 | + "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 (0xc02b)", |
| 437 | + "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (0xc02f)", |
| 438 | + "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256 (0xcca9)", |
| 439 | + "TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256 (0xcca8)", |
| 440 | + "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 (0xc02c)", |
| 441 | + "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (0xc030)", |
| 442 | + "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA (0xc00a)", |
| 443 | + "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA (0xc009)", |
| 444 | + "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA (0xc013)", |
| 445 | + "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA (0xc014)", |
| 446 | + "TLS_RSA_WITH_AES_128_GCM_SHA256 (0x9c)", |
| 447 | + "TLS_RSA_WITH_AES_256_GCM_SHA384 (0x9d)", |
| 448 | + "TLS_RSA_WITH_AES_128_CBC_SHA (0x2f)", |
| 449 | + "TLS_RSA_WITH_AES_256_CBC_SHA (0x35)" |
| 450 | + ], |
| 451 | + "extensions": [ |
| 452 | + "server_name (0)", |
| 453 | + "extended_master_secret (23)", |
| 454 | + "renegotiation_info (65281)", |
| 455 | + "supported_groups (10)", |
| 456 | + "ec_point_formats (11)", |
| 457 | + "session_ticket (35)", |
| 458 | + "application_layer_protocol_negotiation (16)", |
| 459 | + "status_request (5)", |
| 460 | + "delegated_credential (34)", |
| 461 | + "signed_certificate_timestamp (18)", |
| 462 | + "key_share (51)", |
| 463 | + "supported_versions (43)", |
| 464 | + "signature_algorithms (13)", |
| 465 | + "psk_key_exchange_modes (45)", |
| 466 | + "record_size_limit (28)", |
| 467 | + "compress_certificate (27)", |
| 468 | + "encrypted_client_hello (65037)" |
| 469 | + ], |
| 470 | + "alpn": ["h2", "http/1.1"] |
| 471 | + } |
| 472 | + }, |
| 473 | + { |
| 474 | + "tls_response": { |
| 475 | + "type": "Server hello (2)", |
| 476 | + "version": "TLS 1.2 (0x0303)", |
| 477 | + "session_id": "2670a6779b4346e5e84d46890ad2aaf7a53b08adcfe0c9f6868c2d9882242e39", |
| 478 | + "cipher_suite": "TLS_AES_128_GCM_SHA256 (0x1301)", |
| 479 | + "extensions": ["key_share (51)", "supported_versions (43)"], |
| 480 | + "supported_version": "TLS 1.3 (0x0304)" |
| 481 | + } |
| 482 | + } |
| 483 | +] |
| 484 | +``` |
| 485 | + |
| 486 | +And HTTP request with curl: |
| 487 | + |
| 488 | +```json |
| 489 | +[ |
| 490 | + { |
| 491 | + "connection": { |
| 492 | + "tproxy_mode": "redirect", |
| 493 | + "src_local": "127.0.0.1:8888", |
| 494 | + "src_remote": "192.168.0.107:45736", |
| 495 | + "dst_local": "127.0.0.1:37640", |
| 496 | + "dst_remote": "127.0.0.1:1080", |
| 497 | + "original_dst": "96.7.128.198:80" |
| 498 | + } |
| 499 | + }, |
| 500 | + { |
| 501 | + "http_request": { |
| 502 | + "host": "example.com", |
| 503 | + "uri": "/", |
| 504 | + "method": "GET", |
| 505 | + "proto": "HTTP/1.1", |
| 506 | + "header": { |
| 507 | + "Accept": ["*/*"], |
| 508 | + "My": ["Header"], |
| 509 | + "User-Agent": ["curl/7.81.0"] |
| 510 | + } |
| 511 | + } |
| 512 | + }, |
| 513 | + { |
| 514 | + "http_response": { |
| 515 | + "proto": "HTTP/1.1", |
| 516 | + "status": "200 OK", |
| 517 | + "content-length": 1256, |
| 518 | + "header": { |
| 519 | + "Cache-Control": ["max-age=2880"], |
| 520 | + "Connection": ["keep-alive"], |
| 521 | + "Content-Length": ["1256"], |
| 522 | + "Content-Type": ["text/html"], |
| 523 | + "Date": ["Tue, 17 Jun 2025 14:43:24 GMT"], |
| 524 | + "Etag": ["\"84238dfc8092e5d9c0dac8ef93371a07:1736799080.121134\""], |
| 525 | + "Last-Modified": ["Mon, 13 Jan 2025 20:11:20 GMT"] |
| 526 | + } |
| 527 | + } |
| 528 | + } |
| 529 | +] |
| 530 | +``` |
| 531 | + |
| 532 | +Usage as simple as specifying `-sniff` flag along with regular flags |
| 533 | + |
| 534 | +```shell |
| 535 | +gohpts -d -t 8888 -M redirect -sniff |
| 536 | +``` |
| 537 | + |
| 538 | +You can also specify a file to which write sniffed traffic: |
| 539 | + |
| 540 | +```shell |
| 541 | +gohpts -d -sniff -snifflog ~/sniff.log |
| 542 | +``` |
| 543 | + |
| 544 | +Please note that for now sniffing only visible with `-d` flag, it may change in the future. |
| 545 | + |
400 | 546 | ## Links |
401 | 547 |
|
402 | 548 | Learn more about transparent proxies by visiting the following links: |
|
0 commit comments