Class: Aquatone::Collectors::Passivetotal

Inherits:
Aquatone::Collector show all
Defined in:
lib/aquatone/collectors/passivetotal.rb

Constant Summary collapse

API_BASE_URI =
"https://api.passivetotal.org".freeze

Constants inherited from Aquatone::Collector

Aquatone::Collector::DEFAULT_PRIORITY

Instance Attribute Summary

Attributes inherited from Aquatone::Collector

#domain, #hosts

Instance Method Summary collapse

Methods inherited from Aquatone::Collector

cli_options, descendants, #execute!, #initialize, meta, meta=, priority, sluggified_name

Constructor Details

This class inherits a constructor from Aquatone::Collector

Instance Method Details

#runObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/aquatone/collectors/passivetotal.rb', line 13

def run
  response = get_request(
    "#{API_BASE_URI}/v2/enrichment/subdomains?query=.#{url_escape(domain.name)}",
    :basic_auth => {:username => get_key("passivetotal_key"), :password => get_key("passivetotal_secret")}
  )
  body = response.parsed_response
  if response.code != 200
    failure(failure(body["message"] || "PassiveTotal API returned unexpected response code: #{response.code}"))
  end
  if !(body.key?("success") && body["success"])
    failure("Request failed")
  end
  body["subdomains"].each do |subdomain|
    add_host("#{subdomain}.#{domain.name}")
  end
end