From f556a5f8055af9003177f6d213d17a4c9a97d3e0 Mon Sep 17 00:00:00 2001 From: William Vu Date: Wed, 11 Oct 2017 16:12:39 -0500 Subject: [PATCH 1/2] Add compatible session types to post module info --- lib/msf/base/serializer/readable_text.rb | 14 ++++++++++++-- lib/msf/core/post_mixin.rb | 14 +++++++++++--- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/lib/msf/base/serializer/readable_text.rb b/lib/msf/base/serializer/readable_text.rb index edd82099e9..1c170f8ce6 100644 --- a/lib/msf/base/serializer/readable_text.rb +++ b/lib/msf/base/serializer/readable_text.rb @@ -165,6 +165,7 @@ class ReadableText output << " Name: #{mod.name}\n" output << " Module: #{mod.fullname}\n" output << " Platform: #{mod.platform_to_s}\n" + output << " Arch: #{mod.arch_to_s}\n" output << " Privileged: " + (mod.privileged? ? "Yes" : "No") + "\n" output << " License: #{mod.license}\n" output << " Rank: #{mod.rank_to_s.capitalize}\n" @@ -275,11 +276,20 @@ class ReadableText # Authors output << "Provided by:\n" - mod.each_author { |author| + mod.each_author.each do |author| output << indent + author.to_s + "\n" - } + end output << "\n" + # Compatible session types + if mod.session_types + output << "Compatible session types:\n" + mod.session_types.sort.each do |type| + output << indent + type.capitalize + "\n" + end + output << "\n" + end + # Actions if mod.action output << "Available actions:\n" diff --git a/lib/msf/core/post_mixin.rb b/lib/msf/core/post_mixin.rb index 1319bd42b2..1d17f63a5d 100644 --- a/lib/msf/core/post_mixin.rb +++ b/lib/msf/core/post_mixin.rb @@ -20,7 +20,8 @@ module Msf::PostMixin ] , Msf::Post) # Default stance is active - self.passive = (info['Passive'] and info['Passive'] == true) || false + self.passive = info['Passive'] || false + self.session_types = info['SessionTypes'] || [] end # @@ -161,8 +162,8 @@ module Msf::PostMixin return false if s.nil? # Can't be compatible if it's the wrong type - if self.module_info["SessionTypes"] - return false unless self.module_info["SessionTypes"].include?(s.type) + if session_types + return false unless session_types.include?(s.type) end # Types are okay, now check the platform. @@ -189,9 +190,16 @@ module Msf::PostMixin # @see passive? attr_reader :passive + # + # A list of compatible session types + # + # @return [Array] + attr_reader :session_types + protected attr_writer :passive + attr_writer :session_types def session_changed? @ds_session ||= datastore["SESSION"] From bf2fb7051a588b5a67389e94d4148a8e5e17459e Mon Sep 17 00:00:00 2001 From: William Vu Date: Wed, 11 Oct 2017 16:26:25 -0500 Subject: [PATCH 2/2] Fix session compatibility check for post modules --- lib/msf/core/post.rb | 4 ++++ lib/msf/core/post_mixin.rb | 2 -- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/msf/core/post.rb b/lib/msf/core/post.rb index 2e042a3160..6a7a2486e9 100644 --- a/lib/msf/core/post.rb +++ b/lib/msf/core/post.rb @@ -29,9 +29,13 @@ class Msf::Post < Msf::Module def setup m = replicant + if m.actions.length > 0 && !m.action raise Msf::MissingActionError, "Please use: #{m.actions.collect {|e| e.name} * ", "}" end + + # PostMixin + super end def type diff --git a/lib/msf/core/post_mixin.rb b/lib/msf/core/post_mixin.rb index 1d17f63a5d..f1859ece16 100644 --- a/lib/msf/core/post_mixin.rb +++ b/lib/msf/core/post_mixin.rb @@ -39,8 +39,6 @@ module Msf::PostMixin print_warning('SESSION may not be compatible with this module.') end - super - check_for_session_readiness() if session.type == "meterpreter" @session.init_ui(self.user_input, self.user_output)