Skip to content

Commit 86ec586

Browse files
committed
Land rapid7#7649, update session_compatible? for changes from PR#7507
Fixing the ability to find compatible post scripts for sessions
2 parents 7ee9408 + b218c76 commit 86ec586

File tree

1 file changed

+5
-22
lines changed

1 file changed

+5
-22
lines changed

lib/msf/core/post_mixin.rb

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -160,34 +160,17 @@ def session_compatible?(sess_or_sid)
160160
return false unless self.module_info["SessionTypes"].include?(s.type)
161161
end
162162

163-
# Types are okay, now check the platform. This is kind of a ghetto
164-
# workaround for session platforms being ad-hoc and Platform being
165-
# inflexible.
163+
# Types are okay, now check the platform.
166164
if self.platform and self.platform.kind_of?(Msf::Module::PlatformList)
167-
[
168-
# Add as necessary
169-
'win', 'linux', 'osx'
170-
].each do |name|
171-
if self.platform =~ /#{name}/
172-
p = Msf::Module::PlatformList.transform(name)
173-
return false unless self.platform.supports? p
174-
end
175-
end
176-
elsif self.platform and self.platform.kind_of?(Msf::Module::Platform)
177-
p_klass = Msf::Module::Platform
178-
case self.platform
179-
when 'win'
180-
return false unless self.platform.kind_of?(p_klass::Windows)
181-
when 'osx'
182-
return false unless self.platform.kind_of?(p_klass::OSX)
183-
when 'linux'
184-
return false unless self.platform.kind_of?(p_klass::Linux)
185-
end
165+
return false unless self.platform.supports?(Msf::Module::PlatformList.transform(s.base_platform))
186166
end
187167

188168
# Check to make sure architectures match
189169
mod_arch = self.module_info['Arch']
170+
unless mod_arch.nil?
190171
mod_arch = [mod_arch] unless mod_arch.kind_of?(Array)
172+
return false unless mod_arch.include? s.base_arch
173+
end
191174

192175
# If we got here, we haven't found anything that definitely
193176
# disqualifies this session. Assume that means we can use it.

0 commit comments

Comments
 (0)