Skip to content

Commit 5b40feb

Browse files
committed
Land rapid7#9075, missing setup fix for post modules
2 parents 8cfd492 + bf2fb70 commit 5b40feb

File tree

3 files changed

+27
-7
lines changed

3 files changed

+27
-7
lines changed

lib/msf/base/serializer/readable_text.rb

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ def self.dump_exploit_module(mod, indent = '')
165165
output << " Name: #{mod.name}\n"
166166
output << " Module: #{mod.fullname}\n"
167167
output << " Platform: #{mod.platform_to_s}\n"
168+
output << " Arch: #{mod.arch_to_s}\n"
168169
output << " Privileged: " + (mod.privileged? ? "Yes" : "No") + "\n"
169170
output << " License: #{mod.license}\n"
170171
output << " Rank: #{mod.rank_to_s.capitalize}\n"
@@ -275,11 +276,20 @@ def self.dump_post_module(mod, indent = '')
275276

276277
# Authors
277278
output << "Provided by:\n"
278-
mod.each_author { |author|
279+
mod.each_author.each do |author|
279280
output << indent + author.to_s + "\n"
280-
}
281+
end
281282
output << "\n"
282283

284+
# Compatible session types
285+
if mod.session_types
286+
output << "Compatible session types:\n"
287+
mod.session_types.sort.each do |type|
288+
output << indent + type.capitalize + "\n"
289+
end
290+
output << "\n"
291+
end
292+
283293
# Actions
284294
if mod.action
285295
output << "Available actions:\n"

lib/msf/core/post.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,13 @@ class Failed < RuntimeError
2929

3030
def setup
3131
m = replicant
32+
3233
if m.actions.length > 0 && !m.action
3334
raise Msf::MissingActionError, "Please use: #{m.actions.collect {|e| e.name} * ", "}"
3435
end
36+
37+
# PostMixin
38+
super
3539
end
3640

3741
def type

lib/msf/core/post_mixin.rb

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ def initialize(info={})
2020
] , Msf::Post)
2121

2222
# Default stance is active
23-
self.passive = (info['Passive'] and info['Passive'] == true) || false
23+
self.passive = info['Passive'] || false
24+
self.session_types = info['SessionTypes'] || []
2425
end
2526

2627
#
@@ -38,8 +39,6 @@ def setup
3839
print_warning('SESSION may not be compatible with this module.')
3940
end
4041

41-
super
42-
4342
check_for_session_readiness() if session.type == "meterpreter"
4443

4544
@session.init_ui(self.user_input, self.user_output)
@@ -161,8 +160,8 @@ def session_compatible?(sess_or_sid)
161160
return false if s.nil?
162161

163162
# Can't be compatible if it's the wrong type
164-
if self.module_info["SessionTypes"]
165-
return false unless self.module_info["SessionTypes"].include?(s.type)
163+
if session_types
164+
return false unless session_types.include?(s.type)
166165
end
167166

168167
# Types are okay, now check the platform.
@@ -189,9 +188,16 @@ def session_compatible?(sess_or_sid)
189188
# @see passive?
190189
attr_reader :passive
191190

191+
#
192+
# A list of compatible session types
193+
#
194+
# @return [Array]
195+
attr_reader :session_types
196+
192197
protected
193198

194199
attr_writer :passive
200+
attr_writer :session_types
195201

196202
def session_changed?
197203
@ds_session ||= datastore["SESSION"]

0 commit comments

Comments
 (0)