From 0c00c7cc5099b0ab38ba605a0888394020dbb9d3 Mon Sep 17 00:00:00 2001 From: Luke Imhoff Date: Fri, 17 Oct 2014 12:43:40 -0500 Subject: [PATCH] Fully-qualifiy Msf::MODULE_TYPES constants MSP-11126 Fully-qualify `Msf::MODULE_TYPES`, `Msf::MODULE_ANY`, Msf::MODULE_ENCODER`, `Msf::MODULE_EXPLOIT`, `Msf::MODULE_NOP`, `Msf::MODULE_AUX`, `Msf::MODULE_PAYLOAD`, `Msf::MODULE_POST` so that their usage isn't dependent on nested lexical scoping. --- lib/msf/base/serializer/readable_text.rb | 12 ++++++------ lib/msf/base/simple/framework.rb | 12 ++++++------ lib/msf/core/auxiliary.rb | 4 ++-- lib/msf/core/encoder.rb | 4 ++-- lib/msf/core/exploit.rb | 4 ++-- lib/msf/core/framework.rb | 2 +- lib/msf/core/module/compatibility.rb | 6 +++--- lib/msf/core/module/type.rb | 12 ++++++------ lib/msf/core/nop.rb | 4 ++-- lib/msf/core/payload.rb | 4 ++-- lib/msf/core/payload_set.rb | 2 +- lib/msf/ui/console/command_dispatcher/core.rb | 12 ++++++------ 12 files changed, 39 insertions(+), 39 deletions(-) diff --git a/lib/msf/base/serializer/readable_text.rb b/lib/msf/base/serializer/readable_text.rb index c558a0117c..b3d30a125c 100644 --- a/lib/msf/base/serializer/readable_text.rb +++ b/lib/msf/base/serializer/readable_text.rb @@ -20,17 +20,17 @@ class ReadableText # @return [String] formatted text output of the dump. def self.dump_module(mod, indent = " ") case mod.type - when MODULE_PAYLOAD + when Msf::MODULE_PAYLOAD return dump_payload_module(mod, indent) - when MODULE_NOP + when Msf::MODULE_NOP return dump_basic_module(mod, indent) - when MODULE_ENCODER + when Msf::MODULE_ENCODER return dump_basic_module(mod, indent) - when MODULE_EXPLOIT + when Msf::MODULE_EXPLOIT return dump_exploit_module(mod, indent) - when MODULE_AUX + when Msf::MODULE_AUX return dump_auxiliary_module(mod, indent) - when MODULE_POST + when Msf::MODULE_POST return dump_post_module(mod, indent) else return dump_generic_module(mod, indent) diff --git a/lib/msf/base/simple/framework.rb b/lib/msf/base/simple/framework.rb index ff45da2aa2..b67b285d22 100644 --- a/lib/msf/base/simple/framework.rb +++ b/lib/msf/base/simple/framework.rb @@ -54,12 +54,12 @@ module Framework ModuleSimplifiers = { - MODULE_ENCODER => Msf::Simple::Encoder, - MODULE_EXPLOIT => Msf::Simple::Exploit, - MODULE_NOP => Msf::Simple::Nop, - MODULE_PAYLOAD => Msf::Simple::Payload, - MODULE_AUX => Msf::Simple::Auxiliary, - MODULE_POST => Msf::Simple::Post, + Msf::MODULE_ENCODER => Msf::Simple::Encoder, + Msf::MODULE_EXPLOIT => Msf::Simple::Exploit, + Msf::MODULE_NOP => Msf::Simple::Nop, + Msf::MODULE_PAYLOAD => Msf::Simple::Payload, + Msf::MODULE_AUX => Msf::Simple::Auxiliary, + Msf::MODULE_POST => Msf::Simple::Post, } # diff --git a/lib/msf/core/auxiliary.rb b/lib/msf/core/auxiliary.rb index 44aa6329c3..c244724fd3 100644 --- a/lib/msf/core/auxiliary.rb +++ b/lib/msf/core/auxiliary.rb @@ -21,14 +21,14 @@ class Auxiliary < Msf::Module # Returns MODULE_AUX to indicate that this is an auxiliary module. # def self.type - MODULE_AUX + Msf::MODULE_AUX end # # Returns MODULE_AUX to indicate that this is an auxiliary module. # def type - MODULE_AUX + Msf::MODULE_AUX end # diff --git a/lib/msf/core/encoder.rb b/lib/msf/core/encoder.rb index 78cc094b84..5106ef184d 100644 --- a/lib/msf/core/encoder.rb +++ b/lib/msf/core/encoder.rb @@ -150,14 +150,14 @@ class Encoder < Module # Returns MODULE_ENCODER to indicate that this is an encoder module. # def self.type - return MODULE_ENCODER + return Msf::MODULE_ENCODER end # # Returns MODULE_ENCODER to indicate that this is an encoder module. # def type - return MODULE_ENCODER + return Msf::MODULE_ENCODER end # diff --git a/lib/msf/core/exploit.rb b/lib/msf/core/exploit.rb index e5b070d546..363d6c4a9c 100644 --- a/lib/msf/core/exploit.rb +++ b/lib/msf/core/exploit.rb @@ -621,14 +621,14 @@ class Exploit < Msf::Module # Returns MODULE_EXPLOIT to indicate that this is an exploit module. # def self.type - MODULE_EXPLOIT + Msf::MODULE_EXPLOIT end # # Returns MODULE_EXPLOIT to indicate that this is an exploit module. # def type - MODULE_EXPLOIT + Msf::MODULE_EXPLOIT end # diff --git a/lib/msf/core/framework.rb b/lib/msf/core/framework.rb index 70c7ae6883..55fc46e557 100644 --- a/lib/msf/core/framework.rb +++ b/lib/msf/core/framework.rb @@ -69,7 +69,7 @@ class Framework def initialize(opts={}) # Allow specific module types to be loaded - types = opts[:module_types] || MODULE_TYPES + types = opts[:module_types] || Msf::MODULE_TYPES self.threads = ThreadManager.new(self) self.events = EventDispatcher.new(self) diff --git a/lib/msf/core/module/compatibility.rb b/lib/msf/core/module/compatibility.rb index e1e7ca300a..72cdf143cf 100644 --- a/lib/msf/core/module/compatibility.rb +++ b/lib/msf/core/module/compatibility.rb @@ -17,11 +17,11 @@ module Msf::Module::Compatibility return true if (mod == nil) # Determine which hash to used based on the supplied module type - if (mod.type == MODULE_ENCODER) + if (mod.type == Msf::MODULE_ENCODER) ch = self.compat['Encoder'] - elsif (mod.type == MODULE_NOP) + elsif (mod.type == Msf::MODULE_NOP) ch = self.compat['Nop'] - elsif (mod.type == MODULE_PAYLOAD) + elsif (mod.type == Msf::MODULE_PAYLOAD) ch = self.compat['Payload'] if self.respond_to?("target") and self.target and self.target['Payload'] and self.target['Payload']['Compat'] ch = ch.merge(self.target['Payload']['Compat']) diff --git a/lib/msf/core/module/type.rb b/lib/msf/core/module/type.rb index 14b4c6be77..1b0505df86 100644 --- a/lib/msf/core/module/type.rb +++ b/lib/msf/core/module/type.rb @@ -18,42 +18,42 @@ module Msf::Module::Type # Returns true if this module is an auxiliary module. # def auxiliary? - (type == MODULE_AUX) + (type == Msf::MODULE_AUX) end # # Returns true if this module is an encoder module. # def encoder? - (type == MODULE_ENCODER) + (type == Msf::MODULE_ENCODER) end # # Returns true if this module is an exploit module. # def exploit? - (type == MODULE_EXPLOIT) + (type == Msf::MODULE_EXPLOIT) end # # Returns true if this module is a nop module. # def nop? - (type == MODULE_NOP) + (type == Msf::MODULE_NOP) end # # Returns true if this module is a payload module. # def payload? - (type == MODULE_PAYLOAD) + (type == Msf::MODULE_PAYLOAD) end # # Returns true if this module is an post-exploitation module. # def post? - (type == MODULE_POST) + (type == Msf::MODULE_POST) end # diff --git a/lib/msf/core/nop.rb b/lib/msf/core/nop.rb index 763c76f8a7..3f52876c98 100644 --- a/lib/msf/core/nop.rb +++ b/lib/msf/core/nop.rb @@ -14,14 +14,14 @@ class Nop < Msf::Module # Returns MODULE_NOP to indicate that this is a NOP module. # def self.type - return MODULE_NOP + return Msf::MODULE_NOP end # # Returns MODULE_NOP to indicate that this is a NOP module. # def type - return MODULE_NOP + return Msf::MODULE_NOP end # diff --git a/lib/msf/core/payload.rb b/lib/msf/core/payload.rb index a712034020..34bdeac9ef 100644 --- a/lib/msf/core/payload.rb +++ b/lib/msf/core/payload.rb @@ -102,14 +102,14 @@ class Payload < Msf::Module # Returns MODULE_PAYLOAD to indicate that this is a payload module. # def self.type - return MODULE_PAYLOAD + return Msf::MODULE_PAYLOAD end # # Returns MODULE_PAYLOAD to indicate that this is a payload module. # def type - return MODULE_PAYLOAD + return Msf::MODULE_PAYLOAD end # diff --git a/lib/msf/core/payload_set.rb b/lib/msf/core/payload_set.rb index 97b5b4c7a2..9a202d936a 100644 --- a/lib/msf/core/payload_set.rb +++ b/lib/msf/core/payload_set.rb @@ -21,7 +21,7 @@ class PayloadSet < ModuleSet # set class that has custom handling for payloads. # def initialize - super(MODULE_PAYLOAD) + super(Msf::MODULE_PAYLOAD) # A hash of each of the payload types that holds an array # for all of the associated modules diff --git a/lib/msf/ui/console/command_dispatcher/core.rb b/lib/msf/ui/console/command_dispatcher/core.rb index 20a6de64de..1906582b6c 100644 --- a/lib/msf/ui/console/command_dispatcher/core.rb +++ b/lib/msf/ui/console/command_dispatcher/core.rb @@ -2364,17 +2364,17 @@ class Core dispatcher = nil case mod.type - when MODULE_ENCODER + when Msf::MODULE_ENCODER dispatcher = Msf::Ui::Console::CommandDispatcher::Encoder - when MODULE_EXPLOIT + when Msf::MODULE_EXPLOIT dispatcher = Msf::Ui::Console::CommandDispatcher::Exploit - when MODULE_NOP + when Msf::MODULE_NOP dispatcher = Msf::Ui::Console::CommandDispatcher::Nop - when MODULE_PAYLOAD + when Msf::MODULE_PAYLOAD dispatcher = Msf::Ui::Console::CommandDispatcher::Payload - when MODULE_AUX + when Msf::MODULE_AUX dispatcher = Msf::Ui::Console::CommandDispatcher::Auxiliary - when MODULE_POST + when Msf::MODULE_POST dispatcher = Msf::Ui::Console::CommandDispatcher::Post else print_error("Unsupported module type: #{mod.type}")