2010-06-09 20:41:58 +02:00
|
|
|
#
|
|
|
|
# $Id$
|
|
|
|
# $Revision$
|
|
|
|
#
|
|
|
|
|
2010-06-01 21:28:03 +02:00
|
|
|
module Msf
|
|
|
|
|
|
|
|
###
|
2010-06-09 20:41:58 +02:00
|
|
|
#
|
2010-06-01 21:28:03 +02:00
|
|
|
# This plugin is a simple editor command, designed to make it easy to edit modules in the console.
|
|
|
|
#
|
|
|
|
###
|
2010-06-02 03:48:59 +02:00
|
|
|
class Plugin::Editor < Msf::Plugin
|
2010-06-01 21:28:03 +02:00
|
|
|
|
|
|
|
###
|
|
|
|
#
|
|
|
|
# This class implements a single edit command.
|
|
|
|
#
|
|
|
|
###
|
2010-08-13 18:55:42 +02:00
|
|
|
class EditorCommandDispatcher
|
2010-06-01 21:28:03 +02:00
|
|
|
include Msf::Ui::Console::CommandDispatcher
|
|
|
|
|
|
|
|
#
|
|
|
|
# The dispatcher's name.
|
|
|
|
#
|
|
|
|
def name
|
|
|
|
"Editor"
|
|
|
|
end
|
|
|
|
|
|
|
|
#
|
|
|
|
# Returns the hash of commands supported by this dispatcher.
|
|
|
|
#
|
|
|
|
def commands
|
|
|
|
{
|
|
|
|
"edit" => "A handy editor commmand"
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
#
|
2010-08-13 18:55:42 +02:00
|
|
|
# This method handles the edit command.
|
2010-06-01 21:28:03 +02:00
|
|
|
#
|
|
|
|
def cmd_edit(*args)
|
|
|
|
print_line ("Launching editor...")
|
2010-06-09 20:41:58 +02:00
|
|
|
|
2010-06-01 21:28:03 +02:00
|
|
|
e = Rex::Compat.getenv("EDITOR") || "vi"
|
|
|
|
|
|
|
|
if (not active_module) or (not (path = active_module.file_path))
|
|
|
|
$stderr.puts "no active module selected"
|
|
|
|
return nil
|
|
|
|
end
|
2010-06-09 20:41:58 +02:00
|
|
|
|
2010-06-01 21:28:03 +02:00
|
|
|
system(e + " " + path)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def initialize(framework, opts)
|
|
|
|
super
|
|
|
|
|
|
|
|
# console dispatcher commands.
|
2010-08-13 18:55:42 +02:00
|
|
|
add_console_dispatcher(EditorCommandDispatcher)
|
2010-06-01 21:28:03 +02:00
|
|
|
|
|
|
|
print_status("Editor plugin loaded.")
|
|
|
|
end
|
|
|
|
|
|
|
|
def cleanup
|
2010-06-09 20:41:58 +02:00
|
|
|
remove_console_dispatcher('Editor')
|
2010-06-01 21:28:03 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
def name
|
|
|
|
"editor"
|
|
|
|
end
|
|
|
|
|
|
|
|
def desc
|
|
|
|
"Simple Editor Plugin"
|
|
|
|
end
|
|
|
|
|
|
|
|
protected
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|