Tunneling and Port Forwarding
SSH
SSH graphical connection (X)
ssh -Y -C <user>@<ip> #-Y is less secure but faster than -XLocal Port2Port
Open new Port in SSH Server --> Other port
ssh -R 0.0.0.0:10521:127.0.0.1:1521 user@10.0.0.1 #Local port 1521 accessible in port 10521 from everywheressh -R 0.0.0.0:10521:10.0.0.1:1521 user@10.0.0.1 #Remote port 1521 accessible in port 10521 from everywherePort2Port
Local port --> Compromised host (SSH) --> Third_box:Port
ssh -i ssh_key <user>@<ip_compromised> -L <attacker_port>:<ip_victim>:<remote_port> [-p <ssh_port>] [-N -f] #This way the terminal is still in your host
#Example
sudo ssh -L 631:<ip_victim>:631 -N -f -l <username> <ip_compromised>Port2hostnet (proxychains)
Local Port --> Compromised host(SSH) --> Wherever
ssh -f -N -D <attacker_port> <username>@<ip_compromised> #All sent to local port will exit through the compromised server (use as proxy)VPN-Tunnel
You need root in both devices (as you are going to create new interfaces) and the sshd config has to allow root login:
PermitRootLogin yes
PermitTunnel yes
Enable forwarding in Server side
Set new route on client side
SSHUTTLE
You can tunnel via ssh all the traffic to a subnetwork through a host. Example, forwarding all the traffic going to 10.10.10.0/24
Meterpreter
Port2Port
Local port --> Compromised host (active session) --> Third_box:Port
Port2hostnet (proxychains)
Another way:
reGeorg
https://github.com/sensepost/reGeorg
You need to upload a web file tunnel: ashx|aspx|js|jsp|php|php|jsp
Chisel
https://github.com/jpillora/chisel
Chisel is a fast TCP tunnel, transported over HTTP, secured via SSH. Single executable including both client and server. Written in Go (golang). Chisel is mainly useful for passing through firewalls, though it can also be used to provide a secure endpoint into your network. Chisel is very similar to crowbar though achieves much higher performance.
You can do port forwarding (bind & reverse), create a socks proxy (bind & reverse).

Read more:
https://www.youtube.com/watch?v=Yp4oxoQIBAM&t=1469s (HTB Reddish by ippsec)
https://0xdf.gitlab.io/2019/01/26/htb-reddish.html (HTB Reddish by 0xdf)
Rpivot
https://github.com/klsecservices/rpivot
Reverse tunnel. The tunnel is started from the victim. A socks4 proxy is created on 127.0.0.1:1080
Pivot through NTLM proxy
Socat
https://github.com/andrew-d/static-binaries
Bind shell
Reverse shell
Port2Port
Port2Port through socks
Meterpreter through SSL Socat
You can bypass a non-authenticated proxy executing this line instead of the last one in the victim's console:
https://funoverip.net/2011/01/reverse-ssl-backdoor-with-socat-and-metasploit/
SSL Socat Tunnel
/bin/sh console
Create certificates in both sides: Client and Server
Remote Port2Port
Connect the local SSH port (22) to the 443 port of the attacker host
Plink.exe
It's like a console PuTTY version ( the options are very similar to a ssh client).
As this binary will be executed in the victim and it is a ssh client, we need to open our ssh service and port so we can have a reverse connection. Then, to forward a only locally accessible port to a port in our machine:
NTLM proxy bypass
The previously mentioned tool: Rpivot OpenVPN can also bypass it, setting these options in the configuration file:
Cntlm
It authenticates against a proxy and binds a port locally that is forwarded to the external service you specify. Then, you can use the tool of your choice through this port. Example that forward port 443
Now, if you set for example in the victim the SSH service to listen in port 443. You can connect to it through the attacker port 2222. You could also use a meterpreter that connects to localhost:443 and the attacker is listening in port 2222.
YARP
A reverse proxy create by Microsoft. You can find it here: https://github.com/microsoft/reverse-proxy
DNS Tunneling
Iodine
Root is needed in both systems to create tun adapters and tunnels data between them using DNS queries.
The tunnel will be really slow. You can create a compressed SSH connection through this tunnel by using:
DNSCat2
Establishes a C&C channel through DNS. It doesn't need root privileges.
Port forwarding with dnscat
Change proxychains DNS
Proxychains intercepts gethostbyname libc call and tunnels tcp DNS request through the socks proxy. By default the DNS server that proxychains use is 4.2.2.2 (hardcoded). To change it, edit the file: /usr/lib/proxychains3/proxyresolv and change the IP. If you are in a Windows environment you could set the IP of the domain controller.
Tunnels in Go
https://github.com/hotnops/gtunnel
ICMP Tunneling
Hans
https://github.com/friedrich/hans https://github.com/albertzak/hanstunnel
Root is needed in both systems to create tun adapters and tunnels data between them using ICMP echo requests.
Other tools to check
最后更新于
这有帮助吗?