Files
metasploit-gs/plugins/editor.rb
T

88 lines
1.3 KiB
Ruby
Raw Normal View History

2010-06-09 18:41:58 +00:00
#
# $Id$
# $Revision$
#
module Msf
###
2010-06-09 18:41:58 +00:00
#
# This plugin is a simple editor command, designed to make it easy to edit modules in the console.
#
###
class Plugin::Editor < Msf::Plugin
###
#
# This class implements a single edit command.
#
###
2010-08-13 16:55:42 +00:00
class EditorCommandDispatcher
2011-01-28 19:47:35 +00:00
include Msf::Ui::Console::ModuleCommandDispatcher
#
# The dispatcher's name.
#
def name
"Editor"
end
#
# Returns the hash of commands supported by this dispatcher.
#
def commands
2011-01-28 19:47:35 +00:00
# Don't update super here since we don't want the commands from
# super, just the methods
{
"edit" => "A handy editor commmand"
}
end
#
2010-08-13 16:55:42 +00:00
# This method handles the edit command.
#
def cmd_edit(*args)
2011-10-12 23:28:02 +00:00
print_line("Launching editor...")
2010-06-09 18:41:58 +00:00
e = Rex::Compat.getenv("EDITOR") || "vi"
2011-01-28 19:47:35 +00:00
if (not mod) or (not (path = mod.file_path))
print_line("Error: No active module selected")
return nil
end
2010-06-09 18:41:58 +00:00
2011-01-28 19:47:35 +00:00
ret = system(e, path)
if not ret
print_line("Failed to execute your editor (#{e})")
2011-01-28 19:47:35 +00:00
return
end
2011-01-28 19:47:35 +00:00
reload
ret
end
end
def initialize(framework, opts)
super
# console dispatcher commands.
2010-08-13 16:55:42 +00:00
add_console_dispatcher(EditorCommandDispatcher)
end
def cleanup
2010-06-09 18:41:58 +00:00
remove_console_dispatcher('Editor')
end
def name
"editor"
end
def desc
"Simple Editor Plugin"
end
protected
end
end