Skip to content

Commit

Permalink
Merge branch 'passivetotal-collector'
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Henriksen committed Jun 24, 2017
2 parents e276deb + 9882996 commit f03ff8b
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/aquatone/collector.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def add_host(host)
end

def get_request(uri, options={})
Aquatone::HttpClient.get(uri)
Aquatone::HttpClient.get(uri, options)
end

def post_request(uri, body=nil, options={})
Expand Down
31 changes: 31 additions & 0 deletions lib/aquatone/collectors/passivetotal.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
module Aquatone
module Collectors
class Passivetotal < Aquatone::Collector
self.meta = {
:name => "PassiveTotal",
:author => "Michael Henriksen (@michenriksen)",
:description => "Uses RiskIQ's PassiveTotal API to find hostnames",
:require_keys => ["passivetotal_key", "passivetotal_secret"]
}

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

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
end
end
end

0 comments on commit f03ff8b

Please sign in to comment.