port forwarding

meterpreter port forwarding:

portfwd list
portfwd [add | delete] -l LOCAL_PORT -p TARGET_PORT -r TARGET_IP
portfwd flush # to remove all port-forwarding

ssh port forwarding:

  • -f: background shell, to give shell back

  • -N: only setup connect, no commands are to be run

Forward connections (outgoing)

# for connecting to remote port via localhost (-L) (outgoing)
ssh -L KALI-IP:KALI-PORT:localhost:TARGET-PORT TARGET-USER@TARGET-IP

Reverse connections (incoming)

authorized_keys file

from="IP",command="echo 'This account can only be used for Port Forwarding'",no-agent-forwarding,no-X11-forwarding,no-pty <SSH-PUBLIC-key>

Command

chisel port forwarding

Remote Port Forward

Local Port Forward

plink.exe

socat port forwarding

Socket Check:

flag
description

-t

TCP sockets

-u

UDP sockets

-l

Listening sockets only

-p

Process using the socket

-n

No DNS resolution

Last updated

Was this helpful?