class Yawast::Scanner::Plugins::Http::DirectorySearch

Public Class Methods

load_queue(uri) click to toggle source
# File lib/scanner/plugins/http/directory_search.rb, line 83
def self.load_queue(uri)
  @search_list.each do |line|
    check = uri.copy

    begin
      check.path = check.path + "#{line}/"

      # add the job to the queue
      @jobs.push check
    rescue # rubocop:disable Style/RescueStandardError, Lint/HandleExceptions
      # who cares
    end
  end
end
process(uri) click to toggle source
# File lib/scanner/plugins/http/directory_search.rb, line 98
def self.process(uri)
  begin
    res = Yawast::Shared::Http.head uri

    if res.code == '200'
      @results.push "\tFound: '#{uri}'"
      Yawast::Shared::Output.log_append_value 'http', 'http_dir', uri

      load_queue uri if @recursive
    elsif res.code == '301' && @list_redirects
      @results.push "\tFound Redirect: '#{uri} -> '#{res['Location']}'"
      Yawast::Shared::Output.log_value 'http', 'http_dir_redirect', uri, res['Location']
    end
  rescue => e # rubocop:disable Style/RescueStandardError
    unless e.message.include?('end of file') || e.message.include?('getaddrinfo')
      Yawast::Utilities.puts_error "Error searching for directory '#{uri.path}' (#{e.message})"
    end
  end
end