Pivoting, Tunneling, Port Forwarding
Introduction
Pivoting is essentially the idea of moving to other networks through a compromised host (pivot host) to find more targets on different network segments. Pivoting's primary use is to defeat segmentation (both physically and virtually) to access an isolated network. Tunneling is a subset of pivoting. Tunneling encapsulates network traffic into another protocol and routes traffic through it. Port forwarding is a technique that allows us to redirect a communication request from one port to another.
Initial Enumeration - Finding More Targets
Finding Networks
Command | Description |
---|---|
| Linux-based command that displays all current network configurations of a system. |
| Windows-based command that displays all system network configurations. |
| Command used to display the routing table for all IPv4-based protocols. |
| Used to display all active network connections with associated process IDs. Useful to identify internal services to enumerate though pivoting |
| Windows-based command used to list TCP network connections listening on port 1080. |
Internal Hosts Discovery
Command | Description |
---|---|
| For Loop used on a Linux-based system to discover devices in a specified network segment. |
| For Loop used on a Windows-based system to discover devices in a specified network segment. |
| PowerShell one-liner used to ping addresses 1 - 254 in the specified network segment. |
SSH Local Port forwarding
Command | Description |
---|---|
| SSH comand used to create an SSH tunnel from local port 1234 to a remote target using port 3306. |
| Netstat option used to display network connections associated with a tunnel created. Using |
| Nmap command used to scan a host through a connection that has been made on local port |
| SSH command that instructs the ssh client to request multiple local port forwarding at the same time. |
SSH Dynamic Port Forwarding
Command | Description |
---|---|
| SSH command used to perform a dynamic port forward on port |
| Read proxychains.conf to ensure socks configurations are in place. |
| Send traffic generated by Nmap through Proxychains and a SOCKS proxy. |
| Uses Proxychains to open Metasploit and send all generated network traffic through a SOCKS proxy. |
SSH Reverse Port Forwarding
Command | Description |
---|---|
| Reverse SSH tunnel from target host to attack host. Traffic is forwarded on port |
Chisel Pivoting
Command | Description |
---|---|
| Used to start a chisel server in verbose mode listening on port |
| Used to connect to a chisel server at the specified IP address & port using socks. |
Add to proxychains: | Line to add to |
ProxyChains Configuration
Many tools will require setting up the proxychain configuration in order to function properly.
For example, chisel requires adding the following:
127.0.0.1 socks5 1080
.
Command | Description |
---|---|
| Line of text that should be added to /etc/proxychains.conf to ensure a SOCKS version 4 proxy is used in combination with proxychains on the specified IP address and port. |
| Line of text that should be added to /etc/proxychains.conf to ensure a SOCKS version 5 proxy is used in combination with proxychains on the specified IP address and port. |
Meterpreter Pivoting
Command | Description |
---|---|
| Metasploit command used to select the autoroute module. |
| Meterpreter-based portfwd command that adds a forwarding rule to the current Meterpreter session. This rule forwards network traffic on port 3300 on the local machine to port 3389 (RDP) on the target. |
| Meterpreter-based portfwd command that adds a forwarding rule that directs traffic coming on on port 8081 to the port |
Socat Pivoting
Command | Description |
---|---|
| Uses Socat to listen on port 8080 and then to fork when the connection is received. It will then connect to the attack host on port 80. |
| Uses Socat to listen on port 8080 and then to fork when the connection is received. Then it will connect to the target host on port 8443. |
Windows PLink Pivoting
Command | Description |
---|---|
| Windows-based command that uses PuTTY's Plink.exe to perform SSH dynamic port forwarding and establishes an SSH tunnel with the specified target. This will allow for proxy chaining on a Windows host, similar to what is done with Proxychains on a Linux-based host. |
SSHuttle Pivoting
Command | Description |
---|---|
| Runs sshuttle, connects to the target host, and creates a route to the 172.16.5.0 network so traffic can pass from the attack host to hosts on the internal network |
Windows NetSh Pivoting
netsh
is the native way to create a port forward on Windows.
Notice that netsh
can only be run from Administrator
users.
Command | Description |
---|---|
| Listen on port on the 192.168.50.64 IP on port 2222 and forward packets to the 10.4.50.215 IP on port 22. |
| Check estabilished port forwards |
| Allow the previous port foward's traffic from the windows firewall |
| Delete the previously created port forward |
Rpivot Pivoting
Command | Description |
---|---|
| Used to run the rpivot server ( |
| Uses secure copy protocol to transfer an entire directory and all of its contents to a specified target. |
| Clones the rpivot project GitHub repository. |
| Used to run the rpivot client ( |
DNSCat Pivoting
Command | Description |
---|---|
| Clones the dnscat2-powershell project Github repository. |
| PowerShell command used to import the dnscat2.ps1 tool. |
| PowerShell command used to connect to a specified dnscat2 server using a IP address, domain name and preshared secret. The client will send back a shell connection to the server ( |
| Used to list dnscat2 options. |
| Used to interact with an established dnscat2 session. |
PTunnel-NG Pivoting
Command | Description |
---|---|
| Clones the ptunnel-ng project GitHub repository. |
| Used to run the autogen.sh shell script that will build the necessary ptunnel-ng files. |
| Used to start the ptunnel-ng server on the specified IP address ( |
| Used to connect to a specified ptunnel-ng server through local port 2222 ( |
Others
Command | Description |
---|---|
proxychains firefox-esr :80 | Open firefox with Proxychains and send the web request through a SOCKS proxy server to the specified destination web server. |
python client.py --server-ip TargetIP --server-port 8080 --ntlm-proxy-ip ProxyIP --ntlm-proxy-port 8081 --domain nameofWindowsDomain --username username --password password | Run the rpivot client to connect to a web server that is using HTTP-Proxy with NTLM authentication. |
netsh.exe interface portproxy add v4tov4 listenport=8080 listenaddress=10.129.42.198 connectport=3389 connectaddress=172.16.5.25 | Windows-based command that uses |
netsh.exe interface portproxy show v4tov4` | Windows-based command used to view the configurations of a portproxy rule called v4tov4. |
sudo ruby dnscat2.rb --dns host=10.10.14.18,port=53,domain=inlanefreight.local --no-cache | Used to start the dnscat2.rb server running on the specified IP address, port ( |
Last updated