Skip to content

Commit 2476d9b

Browse files
committed
Fix invalid session ID bug
This fix should work seamlessly with rapid7#2952.
1 parent 1f0020a commit 2476d9b

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

lib/msf/base/simple/post.rb

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,15 +93,22 @@ def run_simple(opts = {}, &block)
9393
#
9494
def self.job_run_proc(ctx)
9595
mod = ctx[0]
96+
sid = mod.datastore["SESSION"]
9697
begin
9798
mod.setup
9899
mod.framework.events.on_module_run(mod)
99100
# Grab the session object since we need to fire an event for not
100101
# only the normal module_run event that all module types have to
101102
# report, but a specific event for sessions as well.
102-
s = mod.framework.sessions[mod.datastore["SESSION"]]
103-
mod.framework.events.on_session_module_run(s, mod)
104-
mod.run
103+
s = mod.framework.sessions.get(sid)
104+
if s
105+
mod.framework.events.on_session_module_run(s, mod)
106+
mod.run
107+
else
108+
mod.print_error("Invalid session ID: #{sid}")
109+
mod.cleanup
110+
return
111+
end
105112
rescue ::Timeout::Error => e
106113
mod.error = e
107114
mod.print_error("Post triggered a timeout exception")

0 commit comments

Comments
 (0)