Port Forwarding with Chisel
Last modified: 2023-03-19
Chisel is a fast TCP/UDP tunnel over HTTP. Is can be used for port forwarding.
Port Forwarding
# In remote
chisel server -p <listen-port>
# In local
chisel client <listen-ip>:<listen-port> <local-port>:<target-ip>:<target-port>
Reverse Tunneling
# In local
chisel server -p <listen-port> --reverse
# In remote
chisel client <attack-ip>:<listen-port> R:<local-port>:<target-ip>:<target-port>
Example
We want to connect the SSH server from remote.
In such cases, we cannot connect SSH server from our local machine so use chisel and build reverse tunneling to connect the target SSH.
First execute chisel command in each machine.
# In local
chisel server -p 9999 --reverse
# In remote (assume we want to connect ssh://172.17.0.1:22)
chisel client <local-ip>:9999 R:2222:172.17.0.1:22
After that, we can connect the target host and port via localhost.
Run the following command in local machine.
ssh user@localhost -p 2222
SOCKS Proxy
Forwarding SOCKS Proxy
# In remote
chisel server -p <listen-port> --sock5
# In local
chisel client <target-ip>:<listen-port> <proxy-port>:socks
Reverse SOCKS Proxy
# In local
chisel server -p <listen-port> --reverse
# In remote
chisel client <attack-ip>:<listen-port> R:socks