mailing list archives
Re: How to call Console::UI from MSF plugin
From: HD Moore <hdm () metasploit com>
Date: Sun, 04 Apr 2010 09:42:02 -0500
On 4/4/2010 2:39 AM, eski mo wrote:
1. I think the main MSF API console commands like use,exploit etc are
triggered by msf/ui/console . How do I call these commands within my
plugin. The 'Automating the Metasploit Console'
only provides automation just after msfconsole is fired. I want it at
the time of some triggered event (say arrival of session).
btw tried --- session.console.run_single(command)... dint worked :(
The code you are looking for is just:
$ cat test.rc
hdm () ubuntu:/msf3$ ./msfconsole -r test.rc
[*] resource (test.rc)> Ruby Code (41 bytes)
Console : 3.4.0-dev.8809
hdm () ubuntu:/msf3$
If you call interactive commands (interact, sessions -i, etc) from the
Ruby code, keep in mind the ruby will keep executing when it returns.
You can mix multiple ruby blocks with inline commands in RC scripts.
2. Can Meterpreter scripts call the main MSF UI console commands like
use,exploit etc. ?
No, by design they shouldn't. Messing with the user's console from a
payload script can lead to bad behavior.