Skip to content

Commit f6f0050

Browse files
committed
Fix rapid7#3886 - Backtrace for #check when session is invalid
If the user supplies an invalid session (as in not on the session list), it will cause a backtrace, because the setup method from Msf::PostMixin isn't actually called. We have thought about implementing this in a new OptSession instead. But you can't use or even pass framework to option_container.rb, so this is NOT possible. The original PR was rapid7#3956.
1 parent fb43925 commit f6f0050

3 files changed

Lines changed: 6 additions & 0 deletions

File tree

lib/msf/base/simple/auxiliary.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ def self.check_simple(mod, opts)
113113
# be normalized
114114
mod.validate
115115

116+
mod.setup
117+
116118
# Run check
117119
mod.check
118120
end

lib/msf/base/simple/exploit.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,8 @@ def self.check_simple(mod, opts)
182182
# be normalized
183183
mod.validate
184184

185+
mod.setup
186+
185187
# Run check
186188
mod.check
187189
end

lib/msf/core/post/common.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
module Msf::Post::Common
44

55
def rhost
6+
return nil unless session
7+
68
case session.type
79
when 'meterpreter'
810
session.sock.peerhost

0 commit comments

Comments
 (0)