|
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 | - [Contributing](#contributing) |
23 | 24 | - [License](#license) |
@@ -56,6 +57,9 @@ Specify http server in proxy configuration of Postman |
56 | 57 | - **Transparent proxy** |
57 | 58 | Supports `redirect` (SO_ORIGINAL_DST) and `tproxy` (IP_TRANSPARENT) modes |
58 | 59 |
|
| 60 | +- **Traffic sniffing** |
| 61 | + Proxy is able to parse HTTP headers and TLS handshake metadata |
| 62 | + |
59 | 63 | - **DNS Leak Protection** |
60 | 64 | DNS resolution occurs on SOCKS5 server side. |
61 | 65 |
|
@@ -89,7 +93,7 @@ You can download the binary for your platform from [Releases](https://github.com |
89 | 93 | Example: |
90 | 94 |
|
91 | 95 | ```shell |
92 | | -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 |
| 96 | +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 |
93 | 97 | ``` |
94 | 98 |
|
95 | 99 | Alternatively, you can install it using `go install` command (requires Go [1.24](https://go.dev/doc/install) or later): |
@@ -128,32 +132,36 @@ GitHub: https://github.com/shadowy-pycoder/go-http-proxy-to-socks |
128 | 132 | Usage: gohpts [OPTIONS] |
129 | 133 | Options: |
130 | 134 | -h Show this help message and exit. |
131 | | - -D Run as a daemon (provide -logfile to see logs) |
| 135 | + -D Run as a daemon (provide -logfile to see logs) |
132 | 136 | -M value |
133 | | - Transparent proxy mode: [redirect tproxy] |
| 137 | + Transparent proxy mode: [redirect tproxy] |
134 | 138 | -T string |
135 | | - Address of transparent proxy server (no HTTP) |
| 139 | + Address of transparent proxy server (no HTTP) |
136 | 140 | -U string |
137 | | - User for HTTP proxy (basic auth). This flag invokes prompt for password (not echoed to terminal) |
| 141 | + User for HTTP proxy (basic auth). This flag invokes prompt for password (not echoed to terminal) |
138 | 142 | -c string |
139 | | - Path to certificate PEM encoded file |
140 | | - -d Show logs in DEBUG mode |
| 143 | + Path to certificate PEM encoded file |
| 144 | + -d Show logs in DEBUG mode |
141 | 145 | -f string |
142 | | - Path to server configuration file in YAML format |
143 | | - -j Show logs in JSON format |
| 146 | + Path to server configuration file in YAML format |
| 147 | + -j Show logs in JSON format |
144 | 148 | -k string |
145 | | - Path to private key PEM encoded file |
| 149 | + Path to private key PEM encoded file |
146 | 150 | -l string |
147 | | - Address of HTTP proxy server (default "127.0.0.1:8080") |
| 151 | + Address of HTTP proxy server (default "127.0.0.1:8080") |
148 | 152 | -logfile string |
149 | | - Log file path (Default: stdout) |
| 153 | + Log file path (Default: stdout) |
150 | 154 | -s string |
151 | | - Address of SOCKS5 proxy server (default "127.0.0.1:1080") |
| 155 | + Address of SOCKS5 proxy server (default "127.0.0.1:1080") |
| 156 | + -sniff |
| 157 | + Enable traffic sniffing for HTTP and TLS |
| 158 | + -snifflog string |
| 159 | + Sniffed traffic log file path (Default: the same as -logfile) |
152 | 160 | -t string |
153 | | - Address of transparent proxy server (it starts along with HTTP proxy server) |
| 161 | + Address of transparent proxy server (it starts along with HTTP proxy server) |
154 | 162 | -u string |
155 | | - User for SOCKS5 proxy authentication. This flag invokes prompt for password (not echoed to terminal) |
156 | | - -v print version |
| 163 | + User for SOCKS5 proxy authentication. This flag invokes prompt for password (not echoed to terminal) |
| 164 | + -v print version |
157 | 165 | ``` |
158 | 166 |
|
159 | 167 | ### Configuration via CLI flags |
@@ -414,6 +422,144 @@ ip netns del ns-client |
414 | 422 | ip link del veth1 |
415 | 423 | ``` |
416 | 424 |
|
| 425 | +## Traffic sniffing |
| 426 | + |
| 427 | +[[Back]](#table-of-contents) |
| 428 | + |
| 429 | +`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): |
| 430 | + |
| 431 | +```json |
| 432 | +[ |
| 433 | + { |
| 434 | + "connection": { |
| 435 | + "tproxy_mode": "redirect", |
| 436 | + "src_local": "127.0.0.1:8888", |
| 437 | + "src_remote": "192.168.0.107:51142", |
| 438 | + "dst_local": "127.0.0.1:56256", |
| 439 | + "dst_remote": "127.0.0.1:1080", |
| 440 | + "original_dst": "216.58.209.206:443" |
| 441 | + } |
| 442 | + }, |
| 443 | + { |
| 444 | + "tls_request": { |
| 445 | + "sni": "www.youtube.com", |
| 446 | + "type": "Client hello (1)", |
| 447 | + "version": "TLS 1.2 (0x0303)", |
| 448 | + "session_id": "2670a6779b4346e5e84d46890ad2aaf7a53b08adcfe0c9f6868c2d9882242e39", |
| 449 | + "cipher_suites": [ |
| 450 | + "TLS_AES_128_GCM_SHA256 (0x1301)", |
| 451 | + "TLS_CHACHA20_POLY1305_SHA256 (0x1303)", |
| 452 | + "TLS_AES_256_GCM_SHA384 (0x1302)", |
| 453 | + "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 (0xc02b)", |
| 454 | + "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (0xc02f)", |
| 455 | + "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256 (0xcca9)", |
| 456 | + "TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256 (0xcca8)", |
| 457 | + "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 (0xc02c)", |
| 458 | + "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (0xc030)", |
| 459 | + "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA (0xc00a)", |
| 460 | + "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA (0xc009)", |
| 461 | + "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA (0xc013)", |
| 462 | + "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA (0xc014)", |
| 463 | + "TLS_RSA_WITH_AES_128_GCM_SHA256 (0x9c)", |
| 464 | + "TLS_RSA_WITH_AES_256_GCM_SHA384 (0x9d)", |
| 465 | + "TLS_RSA_WITH_AES_128_CBC_SHA (0x2f)", |
| 466 | + "TLS_RSA_WITH_AES_256_CBC_SHA (0x35)" |
| 467 | + ], |
| 468 | + "extensions": [ |
| 469 | + "server_name (0)", |
| 470 | + "extended_master_secret (23)", |
| 471 | + "renegotiation_info (65281)", |
| 472 | + "supported_groups (10)", |
| 473 | + "ec_point_formats (11)", |
| 474 | + "session_ticket (35)", |
| 475 | + "application_layer_protocol_negotiation (16)", |
| 476 | + "status_request (5)", |
| 477 | + "delegated_credential (34)", |
| 478 | + "signed_certificate_timestamp (18)", |
| 479 | + "key_share (51)", |
| 480 | + "supported_versions (43)", |
| 481 | + "signature_algorithms (13)", |
| 482 | + "psk_key_exchange_modes (45)", |
| 483 | + "record_size_limit (28)", |
| 484 | + "compress_certificate (27)", |
| 485 | + "encrypted_client_hello (65037)" |
| 486 | + ], |
| 487 | + "alpn": ["h2", "http/1.1"] |
| 488 | + } |
| 489 | + }, |
| 490 | + { |
| 491 | + "tls_response": { |
| 492 | + "type": "Server hello (2)", |
| 493 | + "version": "TLS 1.2 (0x0303)", |
| 494 | + "session_id": "2670a6779b4346e5e84d46890ad2aaf7a53b08adcfe0c9f6868c2d9882242e39", |
| 495 | + "cipher_suite": "TLS_AES_128_GCM_SHA256 (0x1301)", |
| 496 | + "extensions": ["key_share (51)", "supported_versions (43)"], |
| 497 | + "supported_version": "TLS 1.3 (0x0304)" |
| 498 | + } |
| 499 | + } |
| 500 | +] |
| 501 | +``` |
| 502 | + |
| 503 | +And HTTP request with curl: |
| 504 | + |
| 505 | +```json |
| 506 | +[ |
| 507 | + { |
| 508 | + "connection": { |
| 509 | + "tproxy_mode": "redirect", |
| 510 | + "src_local": "127.0.0.1:8888", |
| 511 | + "src_remote": "192.168.0.107:45736", |
| 512 | + "dst_local": "127.0.0.1:37640", |
| 513 | + "dst_remote": "127.0.0.1:1080", |
| 514 | + "original_dst": "96.7.128.198:80" |
| 515 | + } |
| 516 | + }, |
| 517 | + { |
| 518 | + "http_request": { |
| 519 | + "host": "example.com", |
| 520 | + "uri": "/", |
| 521 | + "method": "GET", |
| 522 | + "proto": "HTTP/1.1", |
| 523 | + "header": { |
| 524 | + "Accept": ["*/*"], |
| 525 | + "My": ["Header"], |
| 526 | + "User-Agent": ["curl/7.81.0"] |
| 527 | + } |
| 528 | + } |
| 529 | + }, |
| 530 | + { |
| 531 | + "http_response": { |
| 532 | + "proto": "HTTP/1.1", |
| 533 | + "status": "200 OK", |
| 534 | + "content-length": 1256, |
| 535 | + "header": { |
| 536 | + "Cache-Control": ["max-age=2880"], |
| 537 | + "Connection": ["keep-alive"], |
| 538 | + "Content-Length": ["1256"], |
| 539 | + "Content-Type": ["text/html"], |
| 540 | + "Date": ["Tue, 17 Jun 2025 14:43:24 GMT"], |
| 541 | + "Etag": ["\"84238dfc8092e5d9c0dac8ef93371a07:1736799080.121134\""], |
| 542 | + "Last-Modified": ["Mon, 13 Jan 2025 20:11:20 GMT"] |
| 543 | + } |
| 544 | + } |
| 545 | + } |
| 546 | +] |
| 547 | +``` |
| 548 | + |
| 549 | +Usage as simple as specifying `-sniff` flag along with regular flags |
| 550 | + |
| 551 | +```shell |
| 552 | +gohpts -d -t 8888 -M redirect -sniff |
| 553 | +``` |
| 554 | + |
| 555 | +You can also specify a file to which write sniffed traffic: |
| 556 | + |
| 557 | +```shell |
| 558 | +gohpts -d -sniff -snifflog ~/sniff.log |
| 559 | +``` |
| 560 | + |
| 561 | +Please note that for now sniffing only visible with `-d` flag, it may change in the future. |
| 562 | + |
417 | 563 | ## Links |
418 | 564 |
|
419 | 565 | [[Back]](#table-of-contents) |
|
0 commit comments