diff --git a/lib/msf/core/rpc/job.rb b/lib/msf/core/rpc/job.rb index 38c2b61218..763bde770a 100644 --- a/lib/msf/core/rpc/job.rb +++ b/lib/msf/core/rpc/job.rb @@ -22,6 +22,16 @@ class Job < Base { "result" => "success" } end end + def info(token,jid) + authenticate(token) + obj = @framework.jobs[jid.to_s] + if(not obj) + raise ::XMLRPC::FaultException.new(404, "no such job") + else + info = obj.info + { "result" => "success" , "info" => info} + end + end end end end diff --git a/lib/msf/ui/console/command_dispatcher/core.rb b/lib/msf/ui/console/command_dispatcher/core.rb index ad38a2eae6..0e24ad77aa 100644 --- a/lib/msf/ui/console/command_dispatcher/core.rb +++ b/lib/msf/ui/console/command_dispatcher/core.rb @@ -34,6 +34,7 @@ class Core "-h" => [ false, "Help banner." ], "-k" => [ true, "Terminate the specified job name." ], "-K" => [ false, "Terminate all running jobs." ], + "-i" => [ true, "Lists information about a running job." ], "-l" => [ false, "List all running jobs." ]) @@persist_opts = Rex::Parser::Arguments.new( @@ -539,7 +540,33 @@ class Core framework.jobs.each_key do |i| framework.jobs.stop_job(i) end + when "-i" + if (framework.jobs[val.to_s]) + name = framework.jobs[val.to_s].name + info = framework.jobs[val.to_s].info + mod_name = name.split(": ")[1] + if ((mod = framework.modules.create(mod_name)) == nil) + print_error("Failed to load module: #{mod_name}") + return false + end + + info["datastore"].each { |key,val| + mod.datastore[key] = val + } + output = "\n" + output += "Name: #{mod.name}\n" + print_line(output) + + if (mod.options.has_options?) + show_options(mod) + end + + mod_opt = Serializer::ReadableText.dump_advanced_options(mod,' ') + print_line("\nModule advanced options:\n\n#{mod_opt}\n") if (mod_opt and mod_opt.length > 0) + else + print_line("Invalid Job ID") + end when "-h" print( "Usage: jobs [options]\n\n" + diff --git a/lib/rex/job_container.rb b/lib/rex/job_container.rb index f6116bac14..e33932df5f 100644 --- a/lib/rex/job_container.rb +++ b/lib/rex/job_container.rb @@ -59,6 +59,28 @@ class Job clean_proc.call(ctx) if (clean_proc) end + # + # Surfaces the setings from the job to determine the current settings + # + def info + ret = {} + con = nil + ret['jid'] = self.jid + ret['name'] = self.name + if(self.ctx.class == Array) + con = self.ctx[0] + + else + con = self.ctx + end + ret['datastore'] = con.datastore + if(con.kind_of? Msf::Exploit::Remote::HttpServer) + + ret['datastore']['URIPATH'] = con.get_resource() + end + ret + end + # # The name of the job. #