From ea31feaebcf7dde639b00bd83538467e628dcb75 Mon Sep 17 00:00:00 2001 From: Christian Mehlmauer Date: Sun, 16 Sep 2012 12:26:28 +0200 Subject: [PATCH] bugfixing --- lib/wpscan/modules/wp_item.rb | 2 +- lib/wpscan/modules/wp_plugins.rb | 13 +++++++++++-- lib/wpscan/modules/wp_themes.rb | 15 ++++++++++++--- lib/wpscan/wp_detector.rb | 11 ++++++++--- lib/wpscan/wp_enumerator.rb | 14 +++++++++----- 5 files changed, 41 insertions(+), 14 deletions(-) diff --git a/lib/wpscan/modules/wp_item.rb b/lib/wpscan/modules/wp_item.rb index 719758f7..7310404a 100644 --- a/lib/wpscan/modules/wp_item.rb +++ b/lib/wpscan/modules/wp_item.rb @@ -26,7 +26,7 @@ module WpItem def get_url_without_filename uri = get_url - URI.parse("#{uri.scheme}://#{uri.host}#{File.dirname(uri.path)}") + URI.parse("#{uri.scheme}://#{uri.host}#{File.dirname(uri.path)}/") end def version diff --git a/lib/wpscan/modules/wp_plugins.rb b/lib/wpscan/modules/wp_plugins.rb index a16d4fc2..15cda935 100644 --- a/lib/wpscan/modules/wp_plugins.rb +++ b/lib/wpscan/modules/wp_plugins.rb @@ -27,8 +27,17 @@ module WpPlugins options[:vulns_xpath] = "//plugin[@name='#{@name}']/vulnerability" options[:vulns_xpath_2] = "//plugin" options[:type] = "plugins" - result = WpDetector.aggressive_detection(options) - result.sort_by { |p| p.name } + result = WpDetector.aggressive_detection(options) + plugins = [] + result.each do |r| + plugins << WpPlugin.new( + :url => r[:url], + :path => r[:path], + :wp_content_dir => r[:wp_content_dir], + :name => r[:name] + ) + end + plugins.sort_by { |p| p.name } end # http://code.google.com/p/wpscan/issues/detail?id=42 diff --git a/lib/wpscan/modules/wp_themes.rb b/lib/wpscan/modules/wp_themes.rb index 4c2a1e3c..0c4e61cf 100644 --- a/lib/wpscan/modules/wp_themes.rb +++ b/lib/wpscan/modules/wp_themes.rb @@ -24,8 +24,17 @@ module WpThemes options[:vulns_xpath] = "//theme[@name='#{@name}']/vulnerability" options[:vulns_xpath_2] = "//theme" options[:type] = "themes" - result = WpDetector.aggressive_detection(options) - result.sort_by { |t| t.name } + result = WpDetector.aggressive_detection(options) + themes = [] + result.each do |r| + themes << WpTheme.new( + :url => r[:url], + :path => r[:path], + :wp_content_dir => r[:wp_content_dir], + :name => r[:name] + ) + end + themes.sort_by { |t| t.name } end def themes_from_passive_detection(wp_content_dir) @@ -33,7 +42,7 @@ module WpThemes temp = WpDetector.passive_detection(url(), "themes", wp_content_dir) temp.each do |item| - themes << WpPlugin.new( + themes << WpTheme.new( :url => item[:url], :name => item[:name], :path => item[:path], diff --git a/lib/wpscan/wp_detector.rb b/lib/wpscan/wp_detector.rb index 96f67fbf..57066780 100644 --- a/lib/wpscan/wp_detector.rb +++ b/lib/wpscan/wp_detector.rb @@ -22,7 +22,7 @@ class WpDetector WpOptions.check_options(options) result = items - unless items == nil or items.length == 0 + if items == nil or items.length == 0 result = passive_detection(options[:url], options[:type], options[:wp_content_dir]) end @@ -31,7 +31,7 @@ class WpDetector already_present = false result.each do |r| # Already found via passive detection - if r.name == enum_result.name + if r[:name] == enum_result[:name] already_present = true break end @@ -60,7 +60,12 @@ class WpDetector names.uniq! names.each do |item| - items << { :url => url, :name => item, :path => "#{type}/#{item}" } + items << { + :url => url, + :name => item, + :path => "#{type}/#{item}", + :wp_content_dir => wp_content_dir + } end items end diff --git a/lib/wpscan/wp_enumerator.rb b/lib/wpscan/wp_enumerator.rb index bb504f5e..6702354f 100644 --- a/lib/wpscan/wp_enumerator.rb +++ b/lib/wpscan/wp_enumerator.rb @@ -44,7 +44,7 @@ class WpEnumerator enumerate_size = targets.size targets.each do |target| - url = target.get_url + url = "#{target[:url]}#{target[:wp_content_dir]}/#{target[:path]}" request = enum_browser.forge_request(url, :cache_timeout => 0, :follow_location => true) request_count += 1 @@ -87,7 +87,12 @@ class WpEnumerator # Open and parse the 'most popular' plugin list... File.open(file, 'r') do |f| f.readlines.collect do |line| - targets_url << WpPlugin.new(:url => url, :path => "#{type}/#{line.strip}", :wp_content_dir => wp_content_dir) + targets_url << { + :url => url, + :path => "#{type}/#{line.strip}", + :wp_content_dir => wp_content_dir, + :name => File.dirname(line.strip) + } end end end @@ -101,13 +106,12 @@ class WpEnumerator item_name = node.attribute('name').text if targets_url.grep(%r{/#{item_name}/}).empty? - # TODO: Generic - targets_url << WpPlugin.new( + targets_url << { :url => url, :path => "#{type}/#{item_name}", :wp_content_dir => wp_content_dir, :name => item_name - ) + } end end