passivedns-client 2.1.6 → 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 +3 -0
- data/lib/passivedns/client.rb +77 -37
- data/lib/passivedns/client/cli.rb +149 -141
- data/lib/passivedns/client/passivedb.rb +0 -0
- data/lib/passivedns/client/provider/bfk.rb +56 -52
- data/lib/passivedns/client/provider/circl.rb +55 -39
- data/lib/passivedns/client/provider/cn360.rb +44 -33
- data/lib/passivedns/client/provider/dnsdb.rb +57 -56
- data/lib/passivedns/client/provider/mnemonic.rb +63 -55
- data/lib/passivedns/client/provider/passivetotal.rb +48 -43
- data/lib/passivedns/client/provider/riskiq.rb +59 -43
- data/lib/passivedns/client/provider/tcpiputils.rb +20 -19
- data/lib/passivedns/client/provider/virustotal.rb +60 -46
- data/lib/passivedns/client/state.rb +237 -236
- data/lib/passivedns/client/version.rb +1 -1
- data/passivedns-client.gemspec +6 -6
- data/test/helper.rb +0 -0
- data/test/test_cli.rb +34 -5
- data/test/test_passivedns-client.rb +153 -146
- metadata +23 -24
data/passivedns-client.gemspec
CHANGED
@@ -18,12 +18,12 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_runtime_dependency 'json'
|
22
|
-
spec.add_runtime_dependency 'sqlite3'
|
23
|
-
spec.add_runtime_dependency 'structformatter'
|
24
|
-
spec.add_runtime_dependency 'configparser'
|
25
|
-
spec.add_development_dependency "minitest"
|
26
|
-
spec.add_development_dependency "bundler"
|
21
|
+
spec.add_runtime_dependency 'json'
|
22
|
+
spec.add_runtime_dependency 'sqlite3'
|
23
|
+
spec.add_runtime_dependency 'structformatter'
|
24
|
+
spec.add_runtime_dependency 'configparser'
|
25
|
+
spec.add_development_dependency "minitest"
|
26
|
+
spec.add_development_dependency "bundler"
|
27
27
|
spec.add_development_dependency "rake"
|
28
28
|
|
29
29
|
#spec.signing_key = "#{File.dirname(__FILE__)}/../gem-private_key.pem"
|
data/test/helper.rb
CHANGED
File without changes
|
data/test/test_cli.rb
CHANGED
@@ -20,7 +20,7 @@ class TestCLI < Minitest::Test
|
|
20
20
|
helptext = PassiveDNS::CLI.run(["--help"])
|
21
21
|
helptext.gsub!(/Usage: .*?\[/, "Usage: [")
|
22
22
|
assert_equal(
|
23
|
-
"Usage: [-d [3bcdmprtv]] [-g|-v|-m|-c|-x|-y|-j|-t] [-os <sep>] [-f <file>] [-r#|-w#|-v] [-l <count>] <ip|domain|cidr>
|
23
|
+
"Usage: [-d [3bcdmprtv]] [-g|-v|-m|-c|-x|-y|-j|-t] [-os <sep>] [-f <file>] [-r#|-w#|-v] [-l <count>] [--config <file>] <ip|domain|cidr>
|
24
24
|
Passive DNS Providers
|
25
25
|
-d3bcdmprtv uses all of the available passive dns database
|
26
26
|
-d3 use 360.cn
|
@@ -51,6 +51,9 @@ State and Recursion
|
|
51
51
|
-w# specifies the amount of time to wait, in seconds, between queries (Default: 0)
|
52
52
|
-l <count> limits the number of records returned per passive dns database queried.
|
53
53
|
|
54
|
+
Specifying a Configuration File
|
55
|
+
--config <file> specifies a config file. default: #{ENV['HOME']}/.passivedns-client
|
56
|
+
|
54
57
|
Getting Help
|
55
58
|
-h hello there. This option produces this helpful help information on how to access help.
|
56
59
|
-v debugging information
|
@@ -68,7 +71,8 @@ Getting Help
|
|
68
71
|
:debug => false,
|
69
72
|
:sqlitedb => nil,
|
70
73
|
:limit => nil,
|
71
|
-
:help => false
|
74
|
+
:help => false,
|
75
|
+
:configfile => "#{ENV['HOME']}/.passivedns-client"
|
72
76
|
}
|
73
77
|
|
74
78
|
options, items = PassiveDNS::CLI.parse_command_line([])
|
@@ -108,7 +112,8 @@ Getting Help
|
|
108
112
|
:debug => false,
|
109
113
|
:sqlitedb => nil,
|
110
114
|
:limit => nil,
|
111
|
-
:help => false
|
115
|
+
:help => false,
|
116
|
+
:configfile => "#{ENV['HOME']}/.passivedns-client"
|
112
117
|
}
|
113
118
|
|
114
119
|
options_target[:sep] = ","
|
@@ -171,7 +176,8 @@ Getting Help
|
|
171
176
|
:debug => false,
|
172
177
|
:sqlitedb => nil,
|
173
178
|
:limit => nil,
|
174
|
-
:help => true
|
179
|
+
:help => true,
|
180
|
+
:configfile => "#{ENV['HOME']}/.passivedns-client"
|
175
181
|
}
|
176
182
|
|
177
183
|
options, items = PassiveDNS::CLI.parse_command_line(["-dptv", "-h", "8.8.8.8"])
|
@@ -195,11 +201,34 @@ Getting Help
|
|
195
201
|
:debug => false,
|
196
202
|
:sqlitedb => "test.db",
|
197
203
|
:limit => 10,
|
198
|
-
:help => false
|
204
|
+
:help => false,
|
205
|
+
:configfile => "#{ENV['HOME']}/.passivedns-client"
|
199
206
|
}
|
200
207
|
|
201
208
|
options, items = PassiveDNS::CLI.parse_command_line(["-dptv", "-f", "test.db", "-r", "5", "-w", "30", "-l", "10", "8.8.8.8"])
|
202
209
|
assert_equal(options_target, options)
|
203
210
|
assert_equal(["8.8.8.8"], items)
|
204
211
|
end
|
212
|
+
|
213
|
+
def test_configuration_file
|
214
|
+
options_target = {
|
215
|
+
:pdnsdbs => ["bfk"],
|
216
|
+
:format => "text",
|
217
|
+
:sep => "\t",
|
218
|
+
:recursedepth => 1,
|
219
|
+
:wait => 0,
|
220
|
+
:res => nil,
|
221
|
+
:debug => false,
|
222
|
+
:sqlitedb => nil,
|
223
|
+
:limit => nil,
|
224
|
+
:help => false,
|
225
|
+
:configfile => "#{ENV['HOME']}/.passivedns-client"
|
226
|
+
}
|
227
|
+
|
228
|
+
|
229
|
+
options, items = PassiveDNS::CLI.parse_command_line(["--config", "#{ENV['HOME']}/.passivedns-client"])
|
230
|
+
assert_equal(options_target, options)
|
231
|
+
assert_equal([], items)
|
232
|
+
|
233
|
+
end
|
205
234
|
end
|
@@ -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,59 +22,65 @@ 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
|
-
|
50
|
-
|
51
|
-
|
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
|
+
assert_raises RuntimeError do
|
51
|
+
PassiveDNS::Client.new(['bfk'])
|
52
|
+
end
|
53
|
+
|
54
|
+
assert_raises RuntimeError do
|
55
|
+
PassiveDNS::Provider::BFK.new(@cp['bfk'] || {})
|
56
|
+
end
|
57
|
+
|
58
|
+
# refute_nil(d)
|
59
|
+
# rows = d.lookup("example.org",3)
|
60
|
+
# refute_nil(rows)
|
61
|
+
# refute_nil(rows.to_s)
|
62
|
+
# refute_nil(rows.to_xml)
|
63
|
+
# refute_nil(rows.to_json)
|
64
|
+
# refute_nil(rows.to_yaml)
|
65
|
+
# assert_equal(3, rows.length)
|
66
|
+
# rows = d.lookup("8.8.8.8")
|
67
|
+
# refute_nil(rows)
|
68
|
+
# refute_nil(rows.to_s)
|
69
|
+
# refute_nil(rows.to_xml)
|
70
|
+
# refute_nil(rows.to_json)
|
71
|
+
# refute_nil(rows.to_yaml)
|
72
|
+
end
|
73
|
+
|
74
|
+
def test_DNSDB
|
75
|
+
PassiveDNS::Client.new(['dnsdb'])
|
76
|
+
d = PassiveDNS::Provider::DNSDB.new(@cp['dnsdb'] || {})
|
52
77
|
refute_nil(d)
|
53
|
-
|
54
|
-
refute_nil(rows)
|
55
|
-
refute_nil(rows.to_s)
|
56
|
-
refute_nil(rows.to_xml)
|
57
|
-
refute_nil(rows.to_json)
|
58
|
-
refute_nil(rows.to_yaml)
|
59
|
-
assert_equal(3, rows.length)
|
60
|
-
rows = d.lookup("8.8.8.8")
|
78
|
+
rows = d.lookup("example.org",3)
|
61
79
|
refute_nil(rows)
|
62
80
|
refute_nil(rows.to_s)
|
63
81
|
refute_nil(rows.to_xml)
|
64
82
|
refute_nil(rows.to_json)
|
65
83
|
refute_nil(rows.to_yaml)
|
66
|
-
end
|
67
|
-
|
68
|
-
def test_DNSDB
|
69
|
-
PassiveDNS::Client.new(['dnsdb'])
|
70
|
-
d = PassiveDNS::Provider::DNSDB.new(@cp['dnsdb'] || {})
|
71
|
-
refute_nil(d)
|
72
|
-
rows = d.lookup("example.org",3)
|
73
|
-
refute_nil(rows)
|
74
|
-
refute_nil(rows.to_s)
|
75
|
-
refute_nil(rows.to_xml)
|
76
|
-
refute_nil(rows.to_json)
|
77
|
-
refute_nil(rows.to_yaml)
|
78
84
|
assert_equal(3, rows.length) # this will fail since DNSDB has an off by one error
|
79
85
|
rows = d.lookup("8.8.8.8")
|
80
86
|
refute_nil(rows)
|
@@ -82,18 +88,18 @@ class TestPassiveDnsQuery < Minitest::Test
|
|
82
88
|
refute_nil(rows.to_xml)
|
83
89
|
refute_nil(rows.to_json)
|
84
90
|
refute_nil(rows.to_yaml)
|
85
|
-
|
91
|
+
end
|
86
92
|
|
87
|
-
|
88
|
-
|
93
|
+
def test_VirusTotal
|
94
|
+
PassiveDNS::Client.new(['virustotal'])
|
89
95
|
d = PassiveDNS::Provider::VirusTotal.new(@cp['virustotal'] || {})
|
90
96
|
refute_nil(d)
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
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)
|
97
103
|
assert_equal(3, rows.length)
|
98
104
|
rows = d.lookup("8.8.8.8")
|
99
105
|
refute_nil(rows)
|
@@ -101,7 +107,7 @@ class TestPassiveDnsQuery < Minitest::Test
|
|
101
107
|
refute_nil(rows.to_xml)
|
102
108
|
refute_nil(rows.to_json)
|
103
109
|
refute_nil(rows.to_yaml)
|
104
|
-
|
110
|
+
end
|
105
111
|
|
106
112
|
def test_TCPIPUtils
|
107
113
|
PassiveDNS::Client.new(['tcpiputils'])
|
@@ -151,105 +157,106 @@ class TestPassiveDnsQuery < Minitest::Test
|
|
151
157
|
refute_nil(rows.to_xml)
|
152
158
|
refute_nil(rows.to_json)
|
153
159
|
refute_nil(rows.to_yaml)
|
154
|
-
|
160
|
+
end
|
155
161
|
|
156
162
|
def test_nmemonic
|
157
|
-
|
163
|
+
PassiveDNS::Client.new(['mnemonic'])
|
158
164
|
d = PassiveDNS::Provider::Mnemonic.new(@cp['mnemonic'] || {})
|
159
165
|
refute_nil(d)
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
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
|
180
186
|
|
181
187
|
def test_passivetotal
|
182
|
-
|
188
|
+
PassiveDNS::Client.new(['passivetotal'])
|
183
189
|
d = PassiveDNS::Provider::PassiveTotal.new(@cp['passivetotal'] || {})
|
184
190
|
refute_nil(d)
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
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
|
205
212
|
|
206
213
|
def test_circl
|
207
|
-
|
214
|
+
PassiveDNS::Client.new(['circl'])
|
208
215
|
d = PassiveDNS::Provider::CIRCL.new(@cp['circl'] || {})
|
209
216
|
refute_nil(d)
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
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
|
230
237
|
|
231
238
|
def test_riskiq
|
232
|
-
|
239
|
+
PassiveDNS::Client.new(['riskiq'])
|
233
240
|
d = PassiveDNS::Provider::RiskIQ.new(@cp['riskiq'] || {})
|
234
241
|
refute_nil(d)
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
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
|
255
262
|
end
|