Using AutoRunScript in Metasploit
Metasploit offers another great feature of using AutoRunScript. The AutoRunScript option can be populated by issuing the show advanced command. AutoRunScript automates post-exploitation, and executes once access to the target has been achieved. We can either set the AutoRunScript option manually by issuing set AutoRunScript [script-name]
, or by using the resource
script itself, which automates exploitation and post-exploitation together. AutoRunScript can also run more than one post-exploitation script by using the multi_script
and multi_console_command
modules as well. Let us take an example where we have two scripts, one for automating the exploitation and the second for automating the post-exploitation, as shown in the following screenshot:
This is a small post-exploitation script that automates the checkvm
(a module to check whether the target is running on a virtual environment) and migrate
(a module that helps in migrating from the exploited process...