From eb4ae0e5b76012c4d0468e7674259ad4707b99eb Mon Sep 17 00:00:00 2001 From: James Lee Date: Thu, 6 Jan 2011 22:16:24 +0000 Subject: [PATCH] add tab-completion for post modules in the meterpreter run command git-svn-id: file:///home/svn/framework3/trunk@11498 4d416f70-5f16-0410-b530-b9f4589650da --- .../ui/console/command_dispatcher/core.rb | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/rex/post/meterpreter/ui/console/command_dispatcher/core.rb b/lib/rex/post/meterpreter/ui/console/command_dispatcher/core.rb index d31c18b6d3..dd25928077 100644 --- a/lib/rex/post/meterpreter/ui/console/command_dispatcher/core.rb +++ b/lib/rex/post/meterpreter/ui/console/command_dispatcher/core.rb @@ -350,7 +350,6 @@ class Console::CommandDispatcher::Core # fall back to using the scripting interface. if (client.framework and mod = client.framework.modules.create(script_name)) opts = (args + [ "SESSION=#{client.sid}" ]).join(',') - print_status opts.inspect mod.run_simple( #'RunAsJob' => true, 'LocalInput' => shell.input, @@ -372,6 +371,19 @@ class Console::CommandDispatcher::Core tabs = [] if(not words[1] or not words[1].match(/^\//)) begin + if (client.framework) + # XXX This might get slow with a large number of post + # modules. The proper solution is probably to implement a + # Module::Post#session_compatible?(session_object_or_int) method + tabs += client.framework.modules.post.map { |name,klass| + mod = klass.new + if mod.compatible_sessions.include?(client.sid) + mod.fullname.dup + else + nil + end + }.compact + end [ ::Msf::Sessions::Meterpreter::ScriptBase, ::Msf::Sessions::Meterpreter::UserScriptBase @@ -385,7 +397,7 @@ class Console::CommandDispatcher::Core rescue Exception end end - return tabs.map { |e| e.sub!(/\.rb$/, '') } + return tabs.map { |e| e.sub(/\.rb$/, '') } end