Created
March 16, 2011 10:04
-
-
Save bka/872269 to your computer and use it in GitHub Desktop.
How to send commands to an existing metasploit framework instance
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# init console with metasploit framwork | |
@console = Msf::Ui::Web::WebConsole.new(@framework,1) | |
# used to exec a command like it would be typed into msfconsole | |
def cmd_send_to_terminal cmd | |
@console.execute(cmd) | |
return @[email protected] | |
end | |
# used to interact with an open meterpreter session | |
def cmd_send_to_msfsession cmd, session_uuid | |
input = Rex::Ui::Text::Input::Readline.new | |
output = Rex::Ui::Text::Output::Buffer.new | |
session = get_session_by_uuid @framework.sessions, session_uuid | |
session.init_ui(input,output) | |
session.run_cmd(cmd) | |
return session.console.output.dump_buffer | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment