Cheat sheets

Checking for NICs/Network adapters

  • One key defining characteristic of a router is that it has a routing table, which it utilizes to forward traffic based on the destination IP address.

Linux and MacOS

ifconfig
ip -br addr

windows

ipconfig

Routing

  • One key defining characteristic of a router is that it has a routing table, which it utilizes to forward traffic based on the destination IP address.

  • When looking to pivot, it can be helpful to look at the machines routing table to identify which networks we may be able to reach or which routes we may need to add.

viewing the routing table

Linux, MacOS

netstat -r
ip route

windows

netstat -r

Executing a Local Port forward SSH

  • accessing a MySQL server via port forwarding via SSH

  • -L: tells the SSH client to request the SSH server to forward all the data we send via (our local) port 1234 to localhost:3306 (being the target machine and target port)

  • By doing this we should be able to access the MySQL service via our local port 1234

If we wanted to forward multiple ports from the target server to our localhost, we can do so by including the local:server:port argument for example

Setting up a pivot

Enabling Dynamic Port Forwarding with SSH

  • -D: argument requests the SSH server to enable dynamic port forwarding

Once we have this set up and connected to the target machine, we need proxychains to direct our TCP traffic through to the target machine

to do this we need to add an entry to our /etc/proxychains.conf file

  • we can see our entry points to our localhost and port 9050, the same port we specified for port forwarding

now when we specify Nmap with proxychains, it will route all the packets of Nmap through our local port 9050, where our SSH client is listening, which in turn will forward the packets to say a internal subnet

  • we can only perform full TCP connect scans over proxychains

  • Host alive check may not against Window's targets because Windows Defender firewall blocks ICMP

xfreerdp with proxychains

example

Remote/Reverse Port Forwarding with SSH

  • used to expose services from a remote machine to our local machine securely, think of it like creating a reverse tunnel from the remote machine to our local machine

  • The remote server establishes a tunnel back to the local machine, allowing external systems to connect to the specified port on the remote server, which then is forwarded to our local machine

ping sweep

Linux

CMD (windows)

PowerShell

socat

being executed on the pivot host

  • will listen on localhost port 8080, then redirect traffic back to our local machine on port 80

Last updated