diff --git a/lib/environment.rb b/lib/environment.rb index 58be2da9..46270890 100644 --- a/lib/environment.rb +++ b/lib/environment.rb @@ -35,6 +35,7 @@ begin require 'nokogiri' require 'terminal-table' require 'ruby-progressbar' + require 'addressable/uri' # Custom libs require 'common/browser' require 'common/custom_option_parser' diff --git a/lib/wpscan/wp_target/wp_custom_directories.rb b/lib/wpscan/wp_target/wp_custom_directories.rb index 1e60791a..59956edb 100644 --- a/lib/wpscan/wp_target/wp_custom_directories.rb +++ b/lib/wpscan/wp_target/wp_custom_directories.rb @@ -23,9 +23,9 @@ class WpTarget < WebSite # @return [ Boolean ] def default_wp_content_dir_exists? response = Browser.get(@uri.merge('wp-content').to_s) - hash = Digest::MD5.hexdigest(response.body) if WpTarget.valid_response_codes.include?(response.code) + hash = WebSite.page_hash(response) return true if hash != error_404_hash and hash != homepage_hash end diff --git a/lib/wpscan/wp_target/wp_must_use_plugins.rb b/lib/wpscan/wp_target/wp_must_use_plugins.rb index 9f9f5a9b..f0c82203 100644 --- a/lib/wpscan/wp_target/wp_must_use_plugins.rb +++ b/lib/wpscan/wp_target/wp_must_use_plugins.rb @@ -10,7 +10,7 @@ class WpTarget < WebSite response = Browser.get(must_use_url) if response && WpTarget.valid_response_codes.include?(response.code) - hash = WebSite.page_hash(response.body) + hash = WebSite.page_hash(response) return true if hash != error_404_hash && hash != homepage_hash end diff --git a/lib/wpscan/wpscan_options.rb b/lib/wpscan/wpscan_options.rb index 76b8fdbd..195c7be0 100644 --- a/lib/wpscan/wpscan_options.rb +++ b/lib/wpscan/wpscan_options.rb @@ -55,6 +55,8 @@ class WpscanOptions def url=(url) raise Exception.new('Empty URL given') if url.nil? || url == '' + url = Addressable::URI.parse(url).normalize.to_s unless url.ascii_only? + @url = URI.parse(add_http_protocol(url)).to_s end diff --git a/spec/lib/wpscan/wpscan_options_spec.rb b/spec/lib/wpscan/wpscan_options_spec.rb index 947229d9..2d689a25 100644 --- a/spec/lib/wpscan/wpscan_options_spec.rb +++ b/spec/lib/wpscan/wpscan_options_spec.rb @@ -32,6 +32,11 @@ describe 'WpscanOptions' do @wpscan_options.url = url expect(@wpscan_options.url).to be === url end + + it 'should encode IDN' do + @wpscan_options.url = 'http://пример.испытание/' + expect(@wpscan_options.url).to be === 'http://xn--e1afmkfd.xn--80akhbyknj4f/' + end end describe '#threads=' do diff --git a/spec/wpscan_spec.rb b/spec/wpscan_spec.rb index e2de8712..85d8f12f 100644 --- a/spec/wpscan_spec.rb +++ b/spec/wpscan_spec.rb @@ -5,14 +5,14 @@ require 'spec_helper' describe 'wpscan main checks' do it 'should check for errors on running the mainscript' do - a = %x[ruby #{ROOT_DIR}/wpscan.rb] + a = %x[#{RbConfig.ruby} #{ROOT_DIR}/wpscan.rb] expect(a).to match /No argument supplied/ end it 'should check for valid syntax' do result = "" Dir.glob("**/*.rb") do |file| - res = %x{ruby -c #{ROOT_DIR}/#{file} 2>&1}.split("\n") + res = %x{#{RbConfig.ruby} -c #{ROOT_DIR}/#{file} 2>&1}.split("\n") ok = res.select {|msg| msg =~ /Syntax OK/} result << ("####################\nSyntax error in #{file}:\n#{res.join("\n").strip()}\n") if ok.size != 1 end