passivedns-client 2.1.5 → 2.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/lib/passivedns/client/provider/passivetotal.rb +12 -10
- data/lib/passivedns/client/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c9428d4dc084c7a7f0e734e9902791b469e6bd49
|
4
|
+
data.tar.gz: ddd6535a823edbf3e3a89bdd388782405fc6b52a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6b0ca82916628a13baad54ce8c5ba263f33f8a661b43d659442656b5fe822914341b601b0203ecd8815898b096a4cb1d3c111c40a23032ec2ab7cc2d8b76713c
|
7
|
+
data.tar.gz: dcf33265380dedd7ad11f7d185036b7336dea02c7a89510d2d0cae4fac7ca3fafb945b965c616c658b1775c19a9252abe3a963e83feec2faff0b8b020c032900
|
data/README.md
CHANGED
@@ -51,6 +51,7 @@ From version 2.0.0 on, all configuration keys for passive DNS providers are in o
|
|
51
51
|
[mnemonic]
|
52
52
|
APIKEY = 01234567890abcdef01234567890abcdef012345
|
53
53
|
[passivetotal]
|
54
|
+
USERNAME = tom@example.com
|
54
55
|
APIKEY = 0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef
|
55
56
|
[circl]
|
56
57
|
USERNAME = circl_user
|
@@ -27,23 +27,25 @@ module PassiveDNS #:nodoc: don't document this
|
|
27
27
|
attr_accessor :debug
|
28
28
|
# === Options
|
29
29
|
# * :debug Sets the debug flag for the module
|
30
|
+
# * "USERNAME" REQUIRED: The username for the associated API key
|
30
31
|
# * "APIKEY" REQUIRED: The API key associated with PassiveTotal
|
31
|
-
# * "URL" Alternate url for testing. Defaults to "https://
|
32
|
+
# * "URL" Alternate url for testing. Defaults to "https://api.passivetotal.org/v2/dns/passive"
|
32
33
|
#
|
33
34
|
# === Example Instantiation
|
34
35
|
#
|
35
36
|
# options = {
|
36
37
|
# :debug => true,
|
38
|
+
# "USERNAME" => "tom@example.com",
|
37
39
|
# "APIKEY" => "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef",
|
38
|
-
# "URL" => "https://
|
40
|
+
# "URL" => "https://api.passivetotal.org/v2/dns/passive"
|
39
41
|
# }
|
40
42
|
|
41
43
|
# or
|
42
44
|
#
|
43
45
|
# options = {
|
44
46
|
# :debug => true,
|
47
|
+
# "USERNAME" => "tom@example.com"
|
45
48
|
# "APIKEY" => "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef",
|
46
|
-
# "API_VERSION" => "current"
|
47
49
|
# }
|
48
50
|
#
|
49
51
|
# then
|
@@ -52,9 +54,9 @@ module PassiveDNS #:nodoc: don't document this
|
|
52
54
|
#
|
53
55
|
def initialize(options={})
|
54
56
|
@debug = options[:debug] || false
|
57
|
+
@username = options["USERNAME"] || raise("#{self.class.name} requires a USERNAME")
|
55
58
|
@apikey = options["APIKEY"] || raise("#{self.class.name} requires an APIKEY")
|
56
|
-
@
|
57
|
-
@url = options["URL"] || "https://www.passivetotal.org/api/#{@version}/passive"
|
59
|
+
@url = options["URL"] || "https://api.passivetotal.org/v2/dns/passive"
|
58
60
|
end
|
59
61
|
|
60
62
|
# Takes a label (either a domain or an IP address) and returns
|
@@ -62,7 +64,7 @@ module PassiveDNS #:nodoc: don't document this
|
|
62
64
|
def lookup(label, limit=nil)
|
63
65
|
$stderr.puts "DEBUG: #{self.class.name}.lookup(#{label})" if @debug
|
64
66
|
Timeout::timeout(240) {
|
65
|
-
url = @url+"?
|
67
|
+
url = @url+"?query=#{label}"
|
66
68
|
$stderr.puts "DEBUG: #{self.class.name} url = #{url}" if @debug
|
67
69
|
url = URI.parse url
|
68
70
|
http = Net::HTTP.new(url.host, url.port)
|
@@ -70,6 +72,7 @@ module PassiveDNS #:nodoc: don't document this
|
|
70
72
|
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
71
73
|
http.verify_depth = 5
|
72
74
|
request = Net::HTTP::Get.new(url.request_uri)
|
75
|
+
request.basic_auth(@username, @apikey)
|
73
76
|
request.add_field("User-Agent", "Ruby/#{RUBY_VERSION} passivedns-client rubygem v#{PassiveDNS::Client::VERSION}")
|
74
77
|
#request.set_form_data({"api_key" => @apikey, "query" => label})
|
75
78
|
t1 = Time.now
|
@@ -92,9 +95,9 @@ module PassiveDNS #:nodoc: don't document this
|
|
92
95
|
def parse_json(page,query,response_time=0)
|
93
96
|
res = []
|
94
97
|
data = JSON.parse(page)
|
95
|
-
query = data['
|
98
|
+
query = data['queryValue']
|
96
99
|
if data['results']
|
97
|
-
data['results']
|
100
|
+
data['results'].each do |row|
|
98
101
|
first_seen = (row['firstSeen'] == "None") ? nil : Time.parse(row['firstSeen']+" +0000")
|
99
102
|
last_seen = (row['lastSeen'] == "None") ? nil : Time.parse(row['lastSeen']+" +0000")
|
100
103
|
value = row['resolve']
|
@@ -108,7 +111,6 @@ module PassiveDNS #:nodoc: don't document this
|
|
108
111
|
$stderr.puts "#{self.class.name} Exception: #{e}"
|
109
112
|
raise e
|
110
113
|
end
|
111
|
-
|
112
114
|
end
|
113
115
|
end
|
114
|
-
end
|
116
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: passivedns-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- chrislee35
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-02-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|