Class: WPScan::Finders::DbExports::KnownLocations
- Inherits:
-
CMSScanner::Finders::Finder
- Object
- CMSScanner::Finders::Finder
- WPScan::Finders::DbExports::KnownLocations
- Includes:
- CMSScanner::Finders::Finder::Enumerator
- Defined in:
- app/finders/db_exports/known_locations.rb
Overview
DB Exports finder
Constant Summary collapse
- SQL_PATTERN =
/(?:DROP|(?:UN)?LOCK|CREATE|ALTER) (?:TABLE|DATABASE)|INSERT INTO/.freeze
Instance Method Summary collapse
- #aggressive(opts = {}) ⇒ Array<DBExport>
- #create_progress_bar(opts = {}) ⇒ Object
- #domain_name ⇒ Object
- #domain_name_with_sub ⇒ Object
- #full_request_params ⇒ Object
- #potential_urls(opts = {}) ⇒ Hash
- #valid_response_codes ⇒ Object
Instance Method Details
#aggressive(opts = {}) ⇒ Array<DBExport>
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'app/finders/db_exports/known_locations.rb', line 21 def aggressive(opts = {}) found = [] enumerate(potential_urls(opts), opts.merge(check_full_response: valid_response_codes)) do |res| if res.effective_url.end_with?('.zip') next unless %r{\Aapplication/zip}i.match?(res.headers['Content-Type']) else next unless SQL_PATTERN.match?(res.body) end found << Model::DbExport.new(res.request.url, found_by: DIRECT_ACCESS, confidence: 100) end found end |
#create_progress_bar(opts = {}) ⇒ Object
97 98 99 |
# File 'app/finders/db_exports/known_locations.rb', line 97 def (opts = {}) super(opts.merge(title: ' Checking DB Exports -')) end |
#domain_name ⇒ Object
70 71 72 73 74 75 76 |
# File 'app/finders/db_exports/known_locations.rb', line 70 def domain_name @domain_name ||= if Resolv::AddressRegex.match?(target.uri.host) target.uri.host else (PublicSuffix.domain(target.uri.host) || target.uri.host)[/(^[\w|-]+)/, 1] end end |
#domain_name_with_sub ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'app/finders/db_exports/known_locations.rb', line 78 def domain_name_with_sub @domain_name_with_sub ||= if Resolv::AddressRegex.match?(target.uri.host) target.uri.host else parsed = PublicSuffix.parse(target.uri.host) if parsed.subdomain parsed.subdomain.gsub(".#{parsed.tld}", '') elsif parsed.domain parsed.domain.gsub(".#{parsed.tld}", '') else target.uri.host end end rescue PublicSuffix::DomainNotAllowed @domain_name_with_sub = target.uri.host end |
#full_request_params ⇒ Object
37 38 39 |
# File 'app/finders/db_exports/known_locations.rb', line 37 def full_request_params @full_request_params ||= { headers: { 'Range' => 'bytes=0-3000' } } end |
#potential_urls(opts = {}) ⇒ Hash
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'app/finders/db_exports/known_locations.rb', line 45 def potential_urls(opts = {}) urls = {} index = 0 File.open(opts[:list]).each do |path| path.chomp! if path.include?('{domain_name}') urls[target.url(path.gsub('{domain_name}', domain_name))] = index if domain_name != domain_name_with_sub urls[target.url(path.gsub('{domain_name}', domain_name_with_sub))] = index + 1 index += 1 end else urls[target.url(path)] = index end index += 1 end urls end |
#valid_response_codes ⇒ Object
10 11 12 |
# File 'app/finders/db_exports/known_locations.rb', line 10 def valid_response_codes @valid_response_codes ||= [200, 206].freeze end |