From 611a6dd377d45a94dc4f552c722d8bcbe4923d0d Mon Sep 17 00:00:00 2001 From: Christian Mehlmauer Date: Sun, 16 Sep 2012 00:35:06 +0200 Subject: [PATCH] -) removed double entries in output -) Output is now sorted --- lib/wpscan/modules/wp_plugins.rb | 4 ++-- lib/wpscan/modules/wp_themes.rb | 4 ++-- lib/wpscan/wp_detector.rb | 12 +++++++++++- lib/wpscan/wp_plugin.rb | 2 ++ spec/lib/wpscan/modules/wp_plugins_spec.rb | 2 +- spec/lib/wpscan/wp_plugin_spec.rb | 11 ++++++++--- 6 files changed, 26 insertions(+), 9 deletions(-) diff --git a/lib/wpscan/modules/wp_plugins.rb b/lib/wpscan/modules/wp_plugins.rb index fcf5a9c3..0092d956 100644 --- a/lib/wpscan/modules/wp_plugins.rb +++ b/lib/wpscan/modules/wp_plugins.rb @@ -28,7 +28,7 @@ module WpPlugins options[:vulns_xpath_2] = "//plugin" options[:type] = "plugins" result = WpDetector.aggressive_detection(options) - result + result.sort_by { |p| p.name } end private @@ -51,7 +51,7 @@ module WpPlugins :wp_content_dir => wp_content_dir ) end - plugins + plugins.sort_by { |p| p.name } end end diff --git a/lib/wpscan/modules/wp_themes.rb b/lib/wpscan/modules/wp_themes.rb index 705b1d14..f13855de 100644 --- a/lib/wpscan/modules/wp_themes.rb +++ b/lib/wpscan/modules/wp_themes.rb @@ -25,7 +25,7 @@ module WpThemes options[:vulns_xpath_2] = "//theme" options[:type] = "themes" result = WpDetector.aggressive_detection(options) - result + result.sort_by { |t| t.name } end private @@ -42,7 +42,7 @@ module WpThemes :wp_content_dir => wp_content_dir ) end - themes + themes.sort_by { |t| t.name } end end diff --git a/lib/wpscan/wp_detector.rb b/lib/wpscan/wp_detector.rb index 21806f00..f0e06256 100644 --- a/lib/wpscan/wp_detector.rb +++ b/lib/wpscan/wp_detector.rb @@ -28,7 +28,17 @@ class WpDetector enum_results = WpEnumerator.enumerate(options) enum_results.each do |enum_result| - result << enum_result + already_present = false + result.each do |r| + # Already found via passive detection + if r.name == enum_result.name + already_present = true + break + end + end + if not already_present + result << enum_result + end end result end diff --git a/lib/wpscan/wp_plugin.rb b/lib/wpscan/wp_plugin.rb index e9eaea6e..28994577 100644 --- a/lib/wpscan/wp_plugin.rb +++ b/lib/wpscan/wp_plugin.rb @@ -21,6 +21,8 @@ require "#{WPSCAN_LIB_DIR}/vulnerable" class WpPlugin < Vulnerable include WpItem + attr_reader :name + def initialize(options = {}) @base_url = options[:url] @path = options[:path] diff --git a/spec/lib/wpscan/modules/wp_plugins_spec.rb b/spec/lib/wpscan/modules/wp_plugins_spec.rb index fecdd111..612d097f 100644 --- a/spec/lib/wpscan/modules/wp_plugins_spec.rb +++ b/spec/lib/wpscan/modules/wp_plugins_spec.rb @@ -137,7 +137,7 @@ shared_examples_for "WpPlugins" do end # testing response codes - WpPlugins.valid_response_codes.each do |valid_response_code| + WpTarget.valid_response_codes.each do |valid_response_code| it "should detect the plugin if the reponse.code is #{valid_response_code}" do @expected_plugins = [] diff --git a/spec/lib/wpscan/wp_plugin_spec.rb b/spec/lib/wpscan/wp_plugin_spec.rb index 2759ea23..5fc829f2 100644 --- a/spec/lib/wpscan/wp_plugin_spec.rb +++ b/spec/lib/wpscan/wp_plugin_spec.rb @@ -120,13 +120,18 @@ describe WpPlugin do end it "should initialize the object (no options given), :name should be 'example'" do - wp_plugin = WpPlugin.new(location_url) + options = WpOptions.get_empty_options + options[:url] = location_url + wp_plugin = WpPlugin.new(options) wp_plugin.name.should === 'example' - wp_plugin.location_url.should === location_url + wp_plugin.get_url.should === location_url end it "should initialize the object (options[:name] = 'example')" do - wp_plugin = WpPlugin.new(location_url, :name => 'example') + options = WpOptions.get_empty_options + options[:url] = location_url + options[:name] = "example" + wp_plugin = WpPlugin.new(options) wp_plugin.name.should === 'example' wp_plugin.location_url.should === location_url end