Pivoting

Tools and Techniques

SSH

# Dynamic ssh-tunnel
ssh -D localhost:9050 -f -N <USER>@<DOMAIN>
# Run commands with proxychains <Command>
# Not all tools are proxy aware

Metasploit

  • Socks Proxy

Meterpreter> run autoroute -s 172.16.2.0/24
background
use auxiliary/server/socks_proxy
set SRVPORT 9050
run
  • Portforward

# Forward remote port 22 to localhost port 1337
Meterpreter> portfwd add -r 172.16.2.5 -p 22 -L 127.0.0.1 -l 1337

Ligolo-ng

Setup

  • Server

  • Client

sshuttle

Acting as a VPN, we can access hosts without using proxychains.

Cons: No internet access on HTB

circle-info

Proxychains don't work with golang binaries as it uses LDPRELOAD to hijack linked library calls, while golang doesn't use them.

Check: graftcparrow-up-right, tun2socksarrow-up-right below

Chisel

Installation

  • Server

  • Client

circle-info

The server and Client must be the same version

Graftcp

graftcp can redirect the TCP connection made by the program [application, script, shell, etc.] to SOCKS5 or HTTP proxy.

Compared with tsocksarrow-up-right, proxychainsarrow-up-right, or proxychains-ngarrow-up-right, graftcp is not using the LD_PRELOAD trickarrow-up-right which only works for dynamically linked programs, e.g., applications built by Go can not be hooked by proxychains-ngarrow-up-right. graftcp can trace or modify any given programs connected by ptrace(2)arrow-up-right

Installation

Usage

Check the repositoryarrow-up-right for more instructions.

Tun2socks

  • Proxy Everything: Handle all network traffic of any internet programs sent by the device through a proxy.

  • Proxy Protocols: HTTP/Socks4/Socks5/Shadowsocks with authentication support for remote connections.

  • Run Everywhere: Linux/macOS/Windows/FreeBSD/OpenBSD multi-platform support with specific optimization.

  • Gateway Mode: Act as a layer three gateway to handle network traffic from other devices in the same network.

  • Full IPv6 Support: All functions work in IPv6, tunnel IPv4 connections through IPv6 proxy and vice versa.

  • Network Stack: Powered by user-space TCP/IP stack from Google container application kernel gVisorarrow-up-right.

Installation

Usage

Last updated