diff --git a/lib/common/browser.rb b/lib/common/browser.rb index 23743ab7..a2663159 100644 --- a/lib/common/browser.rb +++ b/lib/common/browser.rb @@ -18,7 +18,9 @@ class Browser :request_timeout, :connect_timeout, :cookie, - :throttle + :throttle, + :disable_accept_header, + :disable_referer ] @@instance = nil @@ -68,6 +70,7 @@ class Browser end # Override for setting the User-Agent + # @param [ String ] user_agent def user_agent=(user_agent) Typhoeus::Config.user_agent = user_agent end @@ -158,6 +161,8 @@ class Browser params.merge!(cookiejar: @cache_dir + '/cookie-jar') params.merge!(cookiefile: @cache_dir + '/cookie-jar') params.merge!(cookie: @cookie) if @cookie + params = Browser.remove_params_header_field(params, 'Accept') if @disable_accept_header + params = Browser.remove_params_header_field(params, 'Referer') if @disable_referer params end @@ -177,4 +182,18 @@ class Browser end params end + + # @param [ Hash ] params + # @param [ String ] field + # @param [ Mixed ] field_value + # + # @return [ Array ] + def self.remove_params_header_field(params = {}, field) + if !params.has_key?(:headers) + params = params.merge(:headers => { field => nil }) + elsif !params[:headers].has_key?(field) + params[:headers][field] = nil + end + params + end end diff --git a/lib/common/browser/options.rb b/lib/common/browser/options.rb index 8e25f5e9..0e6defd9 100644 --- a/lib/common/browser/options.rb +++ b/lib/common/browser/options.rb @@ -3,9 +3,8 @@ class Browser module Options - attr_accessor :request_timeout, :connect_timeout + attr_accessor :request_timeout, :connect_timeout, :user_agent, :disable_accept_header, :disable_referer attr_reader :basic_auth, :cache_ttl, :proxy, :proxy_auth, :throttle - attr_writer :user_agent # Sets the Basic Authentification credentials # Accepted format: diff --git a/lib/wpscan/wpscan_options.rb b/lib/wpscan/wpscan_options.rb index 269538c6..72a66c24 100644 --- a/lib/wpscan/wpscan_options.rb +++ b/lib/wpscan/wpscan_options.rb @@ -43,7 +43,9 @@ class WpscanOptions :connect_timeout, :max_threads, :no_banner, - :throttle + :throttle, + :disable_accept_header, + :disable_referer ] attr_accessor *ACCESSOR_OPTIONS @@ -208,7 +210,9 @@ class WpscanOptions enumerate_options_from_string(cli_value) else - raise "Unknow option : #{cli_option} with value #{cli_value}" + text = "Unknown option : #{cli_option}" + text << " with value #{cli_value}" if (cli_value && !cli_value.empty?) + raise text end end @@ -282,7 +286,9 @@ class WpscanOptions ['--cookie', GetoptLong::REQUIRED_ARGUMENT], ['--log', GetoptLong::NO_ARGUMENT], ['--no-banner', GetoptLong::NO_ARGUMENT], - ['--throttle', GetoptLong::REQUIRED_ARGUMENT] + ['--throttle', GetoptLong::REQUIRED_ARGUMENT], + ['--disable-accept-header', GetoptLong::NO_ARGUMENT], + ['--disable-referer', GetoptLong::NO_ARGUMENT] ) end