You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
User for HTTP proxy (basic auth). This flag invokes prompt for password (not echoed to terminal)
113
+
User for HTTP proxy (basic auth). This flag invokes prompt for password (not echoed to terminal)
107
114
-c string
108
-
Path to certificate PEM encoded file
109
-
-dShow logs in DEBUG mode
115
+
Path to certificate PEM encoded file
116
+
-dShow logs in DEBUG mode
110
117
-f string
111
-
Path to server configuration file in YAML format
112
-
-jShow logs in JSON format
118
+
Path to server configuration file in YAML format
119
+
-jShow logs in JSON format
113
120
-k string
114
-
Path to private key PEM encoded file
121
+
Path to private key PEM encoded file
115
122
-l string
116
-
Address of HTTP proxy server (default "127.0.0.1:8080")
123
+
Address of HTTP proxy server (default "127.0.0.1:8080")
117
124
-s string
118
-
Address of SOCKS5 proxy server (default "127.0.0.1:1080")
125
+
Address of SOCKS5 proxy server (default "127.0.0.1:1080")
126
+
-t string
127
+
Address of transparent proxy server (it starts along with HTTP proxy server)
119
128
-u string
120
-
User for SOCKS5 proxy authentication. This flag invokes prompt for password (not echoed to terminal)
121
-
-vprint version
129
+
User for SOCKS5 proxy authentication. This flag invokes prompt for password (not echoed to terminal)
130
+
-vprint version
122
131
```
123
132
124
133
## Example
@@ -217,6 +226,148 @@ server:
217
226
218
227
To learn more about proxy chains visit [Proxychains Github](https://github.com/rofl0r/proxychains-ng)
219
228
229
+
## Transparent proxy
230
+
231
+
> Also known as an `intercepting proxy`, `inline proxy`, or `forced proxy`, a transparent proxy intercepts normal application layer communication without requiring any special client configuration. Clients need not be aware of the existence of the proxy. A transparent proxy is normally located between the client and the Internet, with the proxy performing some of the functions of a gateway or router
This functionality available only on Linux systems and requires `iptables` setup
236
+
237
+
`-T`flag specifies the address for the transparent server but `GoHPTS` will be running without HTTP server.
238
+
239
+
`-t`flag specifies the address of transparent proxy (all other functionality stays the same).
240
+
241
+
In other words, `-T` spins up a single server, but `-t` two servers, http and tcp.
242
+
243
+
There are two modes `redirect` and `tproxy` that can be specified by `-M` flag
244
+
245
+
## `redirect` (Transparent proxy via NAT)
246
+
247
+
In this mode proxying happens with `iptables` `nat` table and `REDIRECT` target. Host of incoming packet changes to the address of running `redirect` transparent proxy, but it also contains original destination that can be retrieved with `getsockopt(SO_ORIGINAL_DST)`
248
+
249
+
To run `GoHPTS` in this mode you use `-t` or `-T` flags with `-M redirect`
250
+
251
+
### Example
252
+
253
+
```shell
254
+
# run the proxy
255
+
gohpts -s 1080 -t 1090 -M redirect -d
256
+
```
257
+
258
+
```shell
259
+
# run socks5 server on 127.0.0.1:1080
260
+
ssh remote -D 1080 -Nf
261
+
```
262
+
263
+
Setup your operating system:
264
+
265
+
```shell
266
+
# commands below require elevated privileges (you can run it with `sudo -i`)
267
+
268
+
#enable ip forwarding
269
+
sysctl -w net.ipv4.ip_forward=1
270
+
271
+
# create `GOHPTS` nat chain
272
+
iptables -t nat -N GOHPTS
273
+
274
+
# set no redirection rules for local, http proxy, ssh and redirect procy itself
275
+
iptables -t nat -A GOHPTS -d 127.0.0.0/8 -j RETURN
curl http://example.com #traffic should be redirected via 127.0.0.1:1090
294
+
```
295
+
296
+
```shell
297
+
curl --proxy http://127.0.0.1:8080 http://example.com #traffic should be redirected via 127.0.0.1:8080
298
+
```
299
+
300
+
Undo everything:
301
+
302
+
```shell
303
+
sysctl -w net.ipv4.ip_forward=0
304
+
iptables -t nat -D PREROUTING -p tcp -j GOHPTS
305
+
iptables -t nat -D OUTPUT -p tcp -j GOHPT
306
+
iptables -t nat -F GOHPTS
307
+
iptables -t nat -X GOHPTS
308
+
```
309
+
310
+
## `tproxy` (Transparent proxy with IP_TRANSPARENT socket option)
311
+
312
+
In this mode proxying happens with `iptables``mangle` table and `TPROXY` target. Transparent proxy sees destination address as it is, it is not being rewrited by the kernel. For this to work the proxy binds with socket option `IP_TRANSPARENT`, `iptables` intercepts traffic using TPROXY target, routing rules are used marked packets to the local proxy without changing their original destination.
313
+
314
+
This mode requires elevated privileges to run `GoHPTS`. You can do that by running the follwing command:
315
+
316
+
```shell
317
+
sudo setcap 'cap_net_admin+ep'~/go/bin/gohpts
318
+
```
319
+
320
+
To run `GoHPTS` in this mode you use `-t` or `-T` flags with `-M tproxy`
321
+
322
+
### Example
323
+
324
+
```shell
325
+
# run the proxy
326
+
gohpts -s 1080 -T 0.0.0.0:1090 -M tproxy -d
327
+
```
328
+
329
+
```shell
330
+
# run socks5 server on 127.0.0.1:1080
331
+
ssh remote -D 1080 -Nf
332
+
```
333
+
334
+
Setup your operating system:
335
+
336
+
```shell
337
+
ip netns exec ns-client ip route add default via 10.0.0.1
0 commit comments