passivedns-client 2.1.11 → 2.1.12
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 +5 -5
- data/.gitignore +0 -0
- data/Gemfile +0 -0
- data/LICENSE.txt +0 -0
- data/README.md +0 -0
- data/lib/passivedns/client.rb +0 -0
- data/lib/passivedns/client/cli.rb +1 -0
- data/lib/passivedns/client/passivedb.rb +0 -0
- data/lib/passivedns/client/provider/bfk.rb +2 -2
- data/lib/passivedns/client/provider/circl.rb +1 -1
- data/lib/passivedns/client/provider/cn360.rb +9 -4
- data/lib/passivedns/client/provider/dnsdb.rb +1 -1
- data/lib/passivedns/client/provider/mnemonic.rb +1 -1
- data/lib/passivedns/client/provider/passivetotal.rb +6 -2
- data/lib/passivedns/client/provider/riskiq.rb +1 -1
- data/lib/passivedns/client/provider/tcpiputils.rb +2 -2
- data/lib/passivedns/client/provider/virustotal.rb +1 -1
- data/lib/passivedns/client/state.rb +2 -1
- data/lib/passivedns/client/version.rb +1 -1
- data/passivedns-client.gemspec +0 -0
- data/test/helper.rb +0 -0
- data/test/test_cli.rb +0 -0
- data/test/test_passivedns-client.rb +136 -135
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: d8ea3feed82ed9f049ef8d7cd6ac78c087b94a630449cdbb3560fc28364ffe41
|
4
|
+
data.tar.gz: 37056ad39c2d721a3b5e6ee9f0347c5f1f79686f75eb15da99e2f155fc7b22d0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 61ca76c52991e1a9e131d51412f0a855301b9555cbd0d1d6e5fe9c0071c1bc2d0b1539926148c090ad31c7db1aaff544565537c4db2f59bfd449e6747786d655
|
7
|
+
data.tar.gz: 4bae5d3265ca1723c9170dc3e1ec726a6d855ff2324b4744692f0a9a486444751723fa907ce50ef9960900fa4236b53fdfb1484f04fc4a91c7dc1e6d61889756
|
data/.gitignore
CHANGED
File without changes
|
data/Gemfile
CHANGED
File without changes
|
data/LICENSE.txt
CHANGED
File without changes
|
data/README.md
CHANGED
File without changes
|
data/lib/passivedns/client.rb
CHANGED
File without changes
|
File without changes
|
@@ -43,7 +43,7 @@ module PassiveDNS #:nodoc: don't document this
|
|
43
43
|
|
44
44
|
# Takes a label (either a domain or an IP address) and returns
|
45
45
|
# an array of PassiveDNS::PDNSResult instances with the answers to the query
|
46
|
-
|
46
|
+
def lookup(label, limit=nil)
|
47
47
|
$stderr.puts "DEBUG: #{self.class.name}.lookup(#{label})" if @debug
|
48
48
|
Timeout::timeout(@timeout) {
|
49
49
|
t1 = Time.now
|
@@ -60,7 +60,7 @@ module PassiveDNS #:nodoc: don't document this
|
|
60
60
|
end
|
61
61
|
end
|
62
62
|
}
|
63
|
-
rescue Timeout::Error
|
63
|
+
rescue Timeout::Error
|
64
64
|
$stderr.puts "#{self.class.name} lookup timed out: #{label}"
|
65
65
|
end
|
66
66
|
|
@@ -3,6 +3,7 @@ require 'net/https'
|
|
3
3
|
require 'openssl'
|
4
4
|
require 'json'
|
5
5
|
require 'digest/md5'
|
6
|
+
require 'pp'
|
6
7
|
|
7
8
|
module PassiveDNS #:nodoc: don't document this
|
8
9
|
# The Provider module contains all the Passive DNS provider client code
|
@@ -85,7 +86,7 @@ module PassiveDNS #:nodoc: don't document this
|
|
85
86
|
recs
|
86
87
|
end
|
87
88
|
}
|
88
|
-
rescue Timeout::Error
|
89
|
+
rescue Timeout::Error
|
89
90
|
$stderr.puts "#{self.class.name} lookup timed out: #{label}"
|
90
91
|
recs
|
91
92
|
end
|
@@ -96,20 +97,24 @@ module PassiveDNS #:nodoc: don't document this
|
|
96
97
|
def parse_json(page,query,response_time=0)
|
97
98
|
res = []
|
98
99
|
data = JSON.parse(page)
|
100
|
+
if data.class == Hash and data['err']
|
101
|
+
raise "#{self.class.name} Error: #{data['err']}"
|
102
|
+
end
|
99
103
|
data.each do |row|
|
100
|
-
time_first = (row["time_first"]) ? Time.at(row["time_first"]
|
101
|
-
time_last = (row["time_last"]) ? Time.at(row["time_last"]
|
104
|
+
time_first = (row["time_first"]) ? Time.at(row["time_first"]) : nil
|
105
|
+
time_last = (row["time_last"]) ? Time.at(row["time_last"]) : nil
|
102
106
|
count = row["count"] || 0
|
103
107
|
query = row["rrname"]
|
104
108
|
answers = row["rdata"].gsub(/;$/,'').split(/;/)
|
105
109
|
rrtype = row["rrtype"]
|
106
110
|
answers.each do |answer|
|
107
|
-
res << PDNSResult.new(self.class.name, response_time, query, answer, rrtype, time_first, time_last, count, 'yellow')
|
111
|
+
res << PDNSResult.new(self.class.name, response_time, query, answer, rrtype, nil, time_first, time_last, count, TLPSecurityControl.new('yellow'))
|
108
112
|
end
|
109
113
|
end
|
110
114
|
res
|
111
115
|
rescue Exception => e
|
112
116
|
$stderr.puts "#{self.class.name} Exception: #{e}"
|
117
|
+
puts e.backtrace
|
113
118
|
raise e
|
114
119
|
end
|
115
120
|
end
|
@@ -86,7 +86,7 @@ module PassiveDNS #:nodoc: don't document this
|
|
86
86
|
recs
|
87
87
|
end
|
88
88
|
}
|
89
|
-
rescue Timeout::Error
|
89
|
+
rescue Timeout::Error
|
90
90
|
$stderr.puts "#{self.class.name} lookup timed out: #{label}"
|
91
91
|
end
|
92
92
|
|
@@ -94,8 +94,12 @@ module PassiveDNS #:nodoc: don't document this
|
|
94
94
|
|
95
95
|
# parses the response of passivetotals's JSON reply to generate an array of PDNSResult
|
96
96
|
def parse_json(page,query,response_time=0)
|
97
|
-
|
97
|
+
res = []
|
98
98
|
data = JSON.parse(page)
|
99
|
+
pp data
|
100
|
+
if data['message']
|
101
|
+
raise "#{self.class.name} Error: #{data['message']}"
|
102
|
+
end
|
99
103
|
query = data['queryValue']
|
100
104
|
if data['results']
|
101
105
|
data['results'].each do |row|
|
@@ -78,7 +78,7 @@ module PassiveDNS #:nodoc: don't document this
|
|
78
78
|
recs
|
79
79
|
end
|
80
80
|
}
|
81
|
-
rescue Timeout::Error
|
81
|
+
rescue Timeout::Error
|
82
82
|
$stderr.puts "#{self.class.name} lookup timed out: #{label}"
|
83
83
|
end
|
84
84
|
|
@@ -111,7 +111,7 @@ module PassiveDNS #:nodoc: don't document this
|
|
111
111
|
when "domains"
|
112
112
|
data.each do |rec|
|
113
113
|
lastseen = (rec["updatedate"]) ? Date.parse(rec["updatedate"]) : nil
|
114
|
-
recs << PDNSResult.new(self.class.name, delta, rec, question, "A", nil, nil,
|
114
|
+
recs << PDNSResult.new(self.class.name, delta, rec, question, "A", nil, nil, lastseen, nil, 'yellow')
|
115
115
|
end
|
116
116
|
end
|
117
117
|
if add_records
|
@@ -205,11 +205,12 @@ module PassiveDNS # :nodoc:
|
|
205
205
|
# creates an SQLite3-based Passive DNS Client state
|
206
206
|
# only argument is the filename of the sqlite3 database
|
207
207
|
def initialize(sqlitedb=nil)
|
208
|
+
@debug = false
|
208
209
|
puts "PDNSToolState initialize #{sqlitedb}" if @debug
|
209
210
|
@level = 0
|
210
211
|
@sqlitedb = sqlitedb
|
211
212
|
raise "Cannot use this class without a database file" unless @sqlitedb
|
212
|
-
unless File.
|
213
|
+
unless File.exist?(@sqlitedb)
|
213
214
|
newdb = true
|
214
215
|
end
|
215
216
|
@sqlitedbh = SQLite3::Database.new(@sqlitedb)
|
data/passivedns-client.gemspec
CHANGED
File without changes
|
data/test/helper.rb
CHANGED
File without changes
|
data/test/test_cli.rb
CHANGED
File without changes
|
@@ -1,9 +1,9 @@
|
|
1
1
|
unless Kernel.respond_to?(:require_relative)
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
2
|
+
module Kernel
|
3
|
+
def require_relative(path)
|
4
|
+
require File.join(File.dirname(caller[0]), path.to_str)
|
5
|
+
end
|
6
|
+
end
|
7
7
|
end
|
8
8
|
|
9
9
|
require_relative 'helper'
|
@@ -22,37 +22,37 @@ class TestPassiveDnsQuery < Minitest::Test
|
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
25
|
+
def test_instantiate_Nonexisting_Client
|
26
|
+
assert_raises RuntimeError do
|
27
|
+
PassiveDNS::Client.new(['doesnotexist'])
|
28
|
+
end
|
29
|
+
end
|
30
30
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
31
|
+
def test_instantiate_All_Clients
|
32
|
+
PassiveDNS::Client.new()
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_instantiate_Passive_DNS_State
|
36
|
+
refute_nil(PassiveDNS::PDNSToolState.new)
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_instantiate_Passive_DNS_State_database
|
40
|
+
if File.exist?("test/test.sqlite3")
|
41
|
+
File.unlink("test/test.sqlite3")
|
42
|
+
end
|
43
|
+
refute_nil(PassiveDNS::PDNSToolStateDB.new("test/test.sqlite3"))
|
44
|
+
if File.exist?("test/test.sqlite3")
|
45
|
+
File.unlink("test/test.sqlite3")
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_BFK
|
50
50
|
assert_raises RuntimeError do
|
51
51
|
PassiveDNS::Client.new(['bfk'])
|
52
52
|
end
|
53
53
|
|
54
54
|
assert_raises RuntimeError do
|
55
|
-
|
55
|
+
PassiveDNS::Provider::BFK.new(@cp['bfk'] || {})
|
56
56
|
end
|
57
57
|
|
58
58
|
# refute_nil(d)
|
@@ -69,18 +69,18 @@ class TestPassiveDnsQuery < Minitest::Test
|
|
69
69
|
# refute_nil(rows.to_xml)
|
70
70
|
# refute_nil(rows.to_json)
|
71
71
|
# refute_nil(rows.to_yaml)
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
72
|
+
end
|
73
|
+
|
74
|
+
def test_DNSDB
|
75
|
+
PassiveDNS::Client.new(['dnsdb'])
|
76
76
|
d = PassiveDNS::Provider::DNSDB.new(@cp['dnsdb'] || {})
|
77
77
|
refute_nil(d)
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
78
|
+
rows = d.lookup("example.org",3)
|
79
|
+
refute_nil(rows)
|
80
|
+
refute_nil(rows.to_s)
|
81
|
+
refute_nil(rows.to_xml)
|
82
|
+
refute_nil(rows.to_json)
|
83
|
+
refute_nil(rows.to_yaml)
|
84
84
|
assert_equal(3, rows.length) # this will fail since DNSDB has an off by one error
|
85
85
|
rows = d.lookup("8.8.8.8")
|
86
86
|
refute_nil(rows)
|
@@ -88,18 +88,18 @@ class TestPassiveDnsQuery < Minitest::Test
|
|
88
88
|
refute_nil(rows.to_xml)
|
89
89
|
refute_nil(rows.to_json)
|
90
90
|
refute_nil(rows.to_yaml)
|
91
|
-
|
91
|
+
end
|
92
92
|
|
93
|
-
|
94
|
-
|
93
|
+
def test_VirusTotal
|
94
|
+
PassiveDNS::Client.new(['virustotal'])
|
95
95
|
d = PassiveDNS::Provider::VirusTotal.new(@cp['virustotal'] || {})
|
96
96
|
refute_nil(d)
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
97
|
+
rows = d.lookup("google.com",3)
|
98
|
+
refute_nil(rows)
|
99
|
+
refute_nil(rows.to_s)
|
100
|
+
refute_nil(rows.to_xml)
|
101
|
+
refute_nil(rows.to_json)
|
102
|
+
refute_nil(rows.to_yaml)
|
103
103
|
assert_equal(3, rows.length)
|
104
104
|
rows = d.lookup("8.8.8.8")
|
105
105
|
refute_nil(rows)
|
@@ -107,7 +107,7 @@ class TestPassiveDnsQuery < Minitest::Test
|
|
107
107
|
refute_nil(rows.to_xml)
|
108
108
|
refute_nil(rows.to_json)
|
109
109
|
refute_nil(rows.to_yaml)
|
110
|
-
|
110
|
+
end
|
111
111
|
|
112
112
|
def test_TCPIPUtils
|
113
113
|
PassiveDNS::Client.new(['tcpiputils'])
|
@@ -157,105 +157,106 @@ class TestPassiveDnsQuery < Minitest::Test
|
|
157
157
|
refute_nil(rows.to_xml)
|
158
158
|
refute_nil(rows.to_json)
|
159
159
|
refute_nil(rows.to_yaml)
|
160
|
-
|
160
|
+
end
|
161
161
|
|
162
162
|
def test_nmemonic
|
163
|
-
|
163
|
+
PassiveDNS::Client.new(['mnemonic'])
|
164
164
|
d = PassiveDNS::Provider::Mnemonic.new(@cp['mnemonic'] || {})
|
165
165
|
refute_nil(d)
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
166
|
+
rows = d.lookup("example.org")
|
167
|
+
refute_nil(rows)
|
168
|
+
refute_nil(rows.to_s)
|
169
|
+
refute_nil(rows.to_xml)
|
170
|
+
refute_nil(rows.to_json)
|
171
|
+
refute_nil(rows.to_yaml)
|
172
|
+
rows = d.lookup("example.org",3)
|
173
|
+
refute_nil(rows)
|
174
|
+
refute_nil(rows.to_s)
|
175
|
+
refute_nil(rows.to_xml)
|
176
|
+
refute_nil(rows.to_json)
|
177
|
+
refute_nil(rows.to_yaml)
|
178
|
+
assert_equal(3, rows.length)
|
179
|
+
rows = d.lookup("8.8.8.8")
|
180
|
+
refute_nil(rows)
|
181
|
+
refute_nil(rows.to_s)
|
182
|
+
refute_nil(rows.to_xml)
|
183
|
+
refute_nil(rows.to_json)
|
184
|
+
refute_nil(rows.to_yaml)
|
185
|
+
end
|
186
186
|
|
187
187
|
def test_passivetotal
|
188
|
-
|
188
|
+
PassiveDNS::Client.new(['passivetotal'])
|
189
189
|
d = PassiveDNS::Provider::PassiveTotal.new(@cp['passivetotal'] || {})
|
190
190
|
refute_nil(d)
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
191
|
+
rows = d.lookup("example.org")
|
192
|
+
refute_nil(rows)
|
193
|
+
refute_nil(rows.to_s)
|
194
|
+
refute_nil(rows.to_xml)
|
195
|
+
refute_nil(rows.to_json)
|
196
|
+
refute_nil(rows.to_yaml)
|
197
|
+
rows = d.lookup("example.org", 3)
|
198
|
+
refute_nil(rows)
|
199
|
+
refute_nil(rows.to_s)
|
200
|
+
refute_nil(rows.to_xml)
|
201
|
+
refute_nil(rows.to_json)
|
202
|
+
refute_nil(rows.to_yaml)
|
203
|
+
puts(rows)
|
204
|
+
assert_equal(3, rows.length)
|
205
|
+
rows = d.lookup("8.8.8.8")
|
206
|
+
refute_nil(rows)
|
207
|
+
refute_nil(rows.to_s)
|
208
|
+
refute_nil(rows.to_xml)
|
209
|
+
refute_nil(rows.to_json)
|
210
|
+
refute_nil(rows.to_yaml)
|
211
|
+
end
|
211
212
|
|
212
213
|
def test_circl
|
213
|
-
|
214
|
+
PassiveDNS::Client.new(['circl'])
|
214
215
|
d = PassiveDNS::Provider::CIRCL.new(@cp['circl'] || {})
|
215
216
|
refute_nil(d)
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
217
|
+
rows = d.lookup("example.org")
|
218
|
+
refute_nil(rows)
|
219
|
+
refute_nil(rows.to_s)
|
220
|
+
refute_nil(rows.to_xml)
|
221
|
+
refute_nil(rows.to_json)
|
222
|
+
refute_nil(rows.to_yaml)
|
223
|
+
rows = d.lookup("example.org",3)
|
224
|
+
refute_nil(rows)
|
225
|
+
refute_nil(rows.to_s)
|
226
|
+
refute_nil(rows.to_xml)
|
227
|
+
refute_nil(rows.to_json)
|
228
|
+
refute_nil(rows.to_yaml)
|
229
|
+
assert_equal(3, rows.length)
|
230
|
+
rows = d.lookup("8.8.8.8")
|
231
|
+
refute_nil(rows)
|
232
|
+
refute_nil(rows.to_s)
|
233
|
+
refute_nil(rows.to_xml)
|
234
|
+
refute_nil(rows.to_json)
|
235
|
+
refute_nil(rows.to_yaml)
|
236
|
+
end
|
236
237
|
|
237
238
|
def test_riskiq
|
238
|
-
|
239
|
+
PassiveDNS::Client.new(['riskiq'])
|
239
240
|
d = PassiveDNS::Provider::RiskIQ.new(@cp['riskiq'] || {})
|
240
241
|
refute_nil(d)
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
242
|
+
rows = d.lookup("example.org")
|
243
|
+
refute_nil(rows)
|
244
|
+
refute_nil(rows.to_s)
|
245
|
+
refute_nil(rows.to_xml)
|
246
|
+
refute_nil(rows.to_json)
|
247
|
+
refute_nil(rows.to_yaml)
|
248
|
+
rows = d.lookup("example.org",3)
|
249
|
+
refute_nil(rows)
|
250
|
+
refute_nil(rows.to_s)
|
251
|
+
refute_nil(rows.to_xml)
|
252
|
+
refute_nil(rows.to_json)
|
253
|
+
refute_nil(rows.to_yaml)
|
254
|
+
assert_equal(3, rows.length)
|
255
|
+
rows = d.lookup("8.8.8.8")
|
256
|
+
refute_nil(rows)
|
257
|
+
refute_nil(rows.to_s)
|
258
|
+
refute_nil(rows.to_xml)
|
259
|
+
refute_nil(rows.to_json)
|
260
|
+
refute_nil(rows.to_yaml)
|
261
|
+
end
|
261
262
|
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.12
|
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: 2020-12-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -161,8 +161,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
161
161
|
- !ruby/object:Gem::Version
|
162
162
|
version: '0'
|
163
163
|
requirements: []
|
164
|
-
|
165
|
-
rubygems_version: 2.4.6
|
164
|
+
rubygems_version: 3.1.2
|
166
165
|
signing_key:
|
167
166
|
specification_version: 4
|
168
167
|
summary: Query passive DNS databases
|