This commit is contained in:
FireFart
2014-02-28 21:49:01 +01:00
parent 3f3f5fdaa0
commit 68e47d70fd
9 changed files with 19 additions and 292 deletions

View File

@@ -9,12 +9,10 @@ class Browser
include Browser::Options
OPTIONS = [
:available_user_agents,
:basic_auth,
:cache_ttl,
:max_threads,
:user_agent,
:user_agent_mode,
:useragent,
:proxy,
:proxy_auth,
:request_timeout,
@@ -23,16 +21,15 @@ class Browser
@@instance = nil
attr_reader :hydra, :config_file, :cache_dir
attr_reader :hydra, :cache_dir
# @param [ Hash ] options
#
# @return [ Browser ]
def initialize(options = {})
@config_file = options[:config_file] || CONF_DIR + '/browser.conf.json'
@cache_dir = options[:cache_dir] || CACHE_DIR + '/browser'
load_config
browser_defaults
override_config(options)
unless @hydra
@@ -62,28 +59,14 @@ class Browser
end
#
# If an option was set but is not in the new config_file
# it's value is kept
# sets browser default values
#
# @param [ String ] config_file
#
# @return [ void ]
def load_config(config_file = nil)
@config_file = config_file || @config_file
if File.symlink?(@config_file)
raise '[ERROR] Config file is a symlink.'
else
data = JSON.parse(File.read(@config_file))
end
OPTIONS.each do |option|
option_name = option.to_s
unless data[option_name].nil?
self.send(:"#{option_name}=", data[option_name])
end
end
def browser_defaults
@max_threads = 20
@cache_ttl = 600 # 10 minutes, at this time the cache is cleaned before each scan. If this value is set to 0, the cache will be disabled
@request_timeout = 2000 # 2s
@connect_timeout = 1000 # 1s
@useragent = "WPScan v#{WPSCAN_VERSION} (http://wpscan.org)"
end
# @param [ String ] url
@@ -101,7 +84,7 @@ class Browser
params = Browser.append_params_header_field(
params,
'User-Agent',
self.user_agent
@useragent
)
if @proxy