new options

This commit is contained in:
Christian Mehlmauer
2016-07-21 21:27:21 +02:00
parent 2cc5bb0311
commit 7f2762eb6f
3 changed files with 30 additions and 6 deletions

View File

@@ -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

View File

@@ -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:

View File

@@ -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