require_relative 'core/cli_options' module CMSScanner module Controller # Core Controller class Core < Base def setup_cache return unless parsed_options[:cache_dir] storage_path = File.join(parsed_options[:cache_dir], Digest::MD5.hexdigest(target.url)) Typhoeus::Config.cache = Cache::Typhoeus.new(storage_path) Typhoeus::Config.cache.clean if parsed_options[:clear_cache] end def before_scan(output_banner = true) output('banner') if output_banner setup_cache fail "The url supplied '#{target.url}' seems to be down" unless target.online? fail AccessForbiddenError if target.access_forbidden? fail HTTPAuthRequiredError if target.http_auth? fail ProxyAuthRequiredError if target.proxy_auth? redirection = target.redirection fail HTTPRedirectError, redirection if redirection && !parsed_options[:ignore_main_redirect] end def run @start_time = Time.now @start_memory = memory_usage output('started', url: target.url) end def after_scan @stop_time = Time.now @elapsed = @stop_time - @start_time @used_memory = memory_usage - @start_memory @requests_done = CMSScanner.total_requests output('finished') end end end end