From 4e967d45aba64b71b8c29821bd9b2fca337bf1cc Mon Sep 17 00:00:00 2001 From: Brent Cook Date: Sat, 25 Aug 2018 22:21:46 -0500 Subject: [PATCH] Land #10520, Only allow setting persistence on payload jobs --- lib/msf/base/serializer/readable_text.rb | 4 +++- lib/msf/ui/console/command_dispatcher/jobs.rb | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/msf/base/serializer/readable_text.rb b/lib/msf/base/serializer/readable_text.rb index 86b314b6d2..3f157b7d54 100644 --- a/lib/msf/base/serializer/readable_text.rb +++ b/lib/msf/base/serializer/readable_text.rb @@ -836,7 +836,9 @@ class ReadableText end persist_list.each do |e| - row[7] = 'true' if e['mod_options']['Options'] == framework.jobs[job_id.to_s].ctx[1].datastore + if framework.jobs[job_id.to_s].ctx[1] + row[7] = 'true' if e['mod_options']['Options'] == framework.jobs[job_id.to_s].ctx[1].datastore + end end end diff --git a/lib/msf/ui/console/command_dispatcher/jobs.rb b/lib/msf/ui/console/command_dispatcher/jobs.rb index 024e412577..8cd5e271c2 100644 --- a/lib/msf/ui/console/command_dispatcher/jobs.rb +++ b/lib/msf/ui/console/command_dispatcher/jobs.rb @@ -210,6 +210,7 @@ module Msf end job_list.map(&:to_s).each do |job| + next unless framework.jobs[job.to_s].ctx[1] # next if no payload context in the job payload_option = framework.jobs[job.to_s].ctx[1].datastore persist_list.delete_if{|pjob|pjob['mod_options']['Options'] == payload_option} end @@ -237,6 +238,11 @@ module Msf def add_persist_job(job_id) if job_id && framework.jobs.has_key?(job_id.to_s) + unless framework.jobs[job_id.to_s].ctx[1] + print_error("Add persistent job failed: job #{job_id} is not payload handler.") + return + end + mod = framework.jobs[job_id.to_s].ctx[0].replicant payload = framework.jobs[job_id.to_s].ctx[1].replicant