From c5ce575543ef56455df276576dc73a8f74852618 Mon Sep 17 00:00:00 2001 From: Tod Beardsley Date: Tue, 17 Jan 2012 15:33:47 -0600 Subject: [PATCH] Revert "Merge pull request #101 from chao-mu/master" Reverting the OptRegexp commit from chao-mu. Before committing to master, this option type needs to be tested on the various mainstream UI's (Metasploit Pro, msfgui, and Armitage) to see if they behave as reasonably as msfconsole. Each UI tends to handle option setting, passing, and display in their own special way. This should make it back in by Wednesday, assuming all goes well. [See #101] This reverts commit 84db5a21fc1a22d4eb83d0a7a651b94b479df035, reversing changes made to 24aaf85a1b73ba0b4c67b77a4e2e2a2649cc964c. --- lib/msf/base/serializer/readable_text.rb | 4 +- lib/msf/core/option_container.rb | 46 ------------------- .../post/test/railgun_reverse_lookups.rb | 17 ++++--- 3 files changed, 10 insertions(+), 57 deletions(-) diff --git a/lib/msf/base/serializer/readable_text.rb b/lib/msf/base/serializer/readable_text.rb index 402a553bfa..ef7aeb71f9 100644 --- a/lib/msf/base/serializer/readable_text.rb +++ b/lib/msf/base/serializer/readable_text.rb @@ -312,9 +312,9 @@ class ReadableText next if (opt.advanced?) next if (opt.evasion?) - val_display = opt.display_value(mod.datastore[name] || opt.default) + val = mod.datastore[name] || opt.default.to_s - tbl << [ name, val_display, opt.required? ? "yes" : "no", opt.desc ] + tbl << [ name, val.to_s, opt.required? ? "yes" : "no", opt.desc ] } return tbl.to_s diff --git a/lib/msf/core/option_container.rb b/lib/msf/core/option_container.rb index 99d0aaab3e..a56a02c129 100644 --- a/lib/msf/core/option_container.rb +++ b/lib/msf/core/option_container.rb @@ -81,13 +81,6 @@ class OptBase value end - # - # Returns a string representing a user-friendly display of the chosen value - # - def display_value(value) - value.to_s - end - # # The name of the option. # @@ -144,7 +137,6 @@ end # OptEnum - Select from a set of valid values # OptAddressRange - A subnet or range of addresses # OptSession - A session identifier -# OptRegexp - Valid Ruby regular expression # ### @@ -448,44 +440,6 @@ class OptInt < OptBase end end -### -# -# Regexp option -# -### -class OptRegexp < OptBase - def type - return 'regexp' - end - - def valid?(value) - unless super - return false - end - - begin - Regexp.compile(value) - - return true - rescue RegexpError => e - return false - end - end - - def normalize(value) - return Regexp.compile(value) - end - - def display_value(value) - if value.kind_of?(Regexp) - return value.source - elsif value.kind_of?(String) - return display_value(normalize(value)) - end - - return super - end -end ### # diff --git a/test/modules/post/test/railgun_reverse_lookups.rb b/test/modules/post/test/railgun_reverse_lookups.rb index 5571f42373..513cebca38 100644 --- a/test/modules/post/test/railgun_reverse_lookups.rb +++ b/test/modules/post/test/railgun_reverse_lookups.rb @@ -1,3 +1,4 @@ + ## # $Id$ ## @@ -11,12 +12,9 @@ require 'msf/core' require 'rex' -require 'msf/core/post/windows/railgun' class Metasploit3 < Msf::Post - include Msf::Post::Windows::Railgun - def initialize(info={}) super( update_info( info, 'Name' => 'railgun_testing', @@ -30,25 +28,26 @@ class Metasploit3 < Msf::Post [ OptInt.new("ERR_CODE" , [true, "Error code to reverse lookup", 0x420]), OptInt.new("WIN_CONST", [true, "Windows constant to reverse lookup", 4]), - OptRegexp.new("WCREGEX", [false,"Regexp to apply to constant rev lookup", '^SERVICE']), - OptRegexp.new("ECREGEX", [false,"Regexp to apply to error code lookup", '^ERROR_SERVICE_']), + OptString.new("WCREGEX", [false,"Regexp to apply to constant rev lookup", "^SERVICE"]), + OptString.new("ECREGEX", [false,"Regexp to apply to error code lookup", "^ERROR_SERVICE_"]), ], self.class) end def run - print_debug datastore['ECREGEX'] print_status("Running against session #{datastore["SESSION"]}") print_status("Session type is #{session.type}") + @rg = session.railgun + print_status() - print_status("TESTING: select_const_names on #{datastore['WIN_CONST']} filtering by #{datastore['WCREGEX'].to_s}") - results = select_const_names(datastore['WIN_CONST'],datastore['WCREGEX']) + print_status("TESTING: const_reverse_lookup on #{datastore['WIN_CONST']} filtering by #{datastore['WCREGEX'].to_s}") + results = @rg.const_reverse_lookup(datastore['WIN_CONST'],datastore['WCREGEX']) print_status("RESULTS: #{results.class} #{results.pretty_inspect}") print_status() print_status("TESTING: error_lookup on #{datastore['ERR_CODE']} filtering by #{datastore['ECREGEX'].to_s}") - results = lookup_error(datastore['ERR_CODE'],datastore['ECREGEX']) + results = @rg.error_lookup(datastore['ERR_CODE'],datastore['ECREGEX']) print_status("RESULTS: #{results.class} #{results.inspect}") print_status()