dnsbl-client 1.0.4 → 1.0.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: e4c4653c0af8ba768662e3474f23edd7d4cd44c4
4
- data.tar.gz: b431b52d445ff04aec29c27606d5501a2deea989
2
+ SHA256:
3
+ metadata.gz: 39cc1894f213c35792030a3167985e31e77ad89e5fe112d7960c30d240f5974e
4
+ data.tar.gz: e738c293677b6dc2b163a4983f4762c29c0d06cfe7cc29ce5be87a9bb5327e1f
5
5
  SHA512:
6
- metadata.gz: bb6b5c33e4e0bbe2c9c6adf32190d1e49c8d235c1515e1af5915a0da87e096b6887d68534a26eeaad32e2bf0413ba6234d6db6a68167ba47574e399ccb8f97be
7
- data.tar.gz: 5d9c36037f30b11b47ff09ae8bcd9fc70e8c8c09b29a5f3512c7d3b21361a8a06f7fe18768e170fad2d6e0f33eb587e7d167d829ebd29667a7dc9da5c62c2f86
6
+ metadata.gz: 7e1a0af6659598d81dbdb1636449e39178f936d2800144c2c111c5975f1cdedcc7e893f909c193ac3e074ff2f41aa7a44abaaa4ffd376f8feba628f7e9030eca
7
+ data.tar.gz: 3fbbf8301c066eabb6c0cd6edd5078b77823efca3051f9bc71d0286b3dee02281757f3adcb72446ac6848c37f487c3ff8d25ac0706d97bb9c529625f2d84b96c
data/bin/dnsbl-client CHANGED
@@ -2,6 +2,7 @@
2
2
  require 'dnsbl/client'
3
3
 
4
4
  c = DNSBL::Client.new
5
+ c.first_only = true
5
6
 
6
7
  if ARGV.length > 0
7
8
  c.lookup(ARGV).each do |res|
data/data/dnsbl.yaml CHANGED
@@ -153,10 +153,6 @@ NOMOREFUN:
153
153
  127.0.0.9: See http://moensted.dk/spam/no-more-funn/?addr=$
154
154
  127.0.0.10: Possible open proxy
155
155
  127.0.0.11: Please stop testing our servers
156
- SPAMCANNIBAL:
157
- domain: bl.spamcannibal.org
158
- type: ip
159
- 127.0.0.2: Blacklisted
160
156
  UCEPROTECT1:
161
157
  domain: dnsbl-1.uceprotect.net
162
158
  type: ip
File without changes
data/data/two-level-tlds CHANGED
File without changes
@@ -1,6 +1,6 @@
1
1
  module DNSBL # :nodoc:
2
2
  class Client
3
3
  # Current version of the dnsbl-client gem
4
- VERSION = "1.0.4"
4
+ VERSION = "1.0.7"
5
5
  end
6
6
  end
data/lib/dnsbl/client.rb CHANGED
@@ -5,12 +5,13 @@ require 'resolv'
5
5
  require 'socket'
6
6
  require 'thread'
7
7
  require 'yaml'
8
+ require 'ipaddr'
8
9
 
9
10
  # This is a monkeypatch for the built-in Ruby DNS resolver to specify nameservers
10
11
  class Resolv::DNS::Config
11
12
  # Monkeypatch the nameservers to set a default if there are no defined nameservers
12
13
  def nameservers
13
- return @nameservers if @nameservers
14
+ return @nameservers if defined?(@nameservers)
14
15
 
15
16
  lazy_initialize
16
17
  if self.respond_to? :nameserver_port
@@ -41,6 +42,8 @@ module DNSBL # :nodoc:
41
42
  two_level_tldfile = File.expand_path('../../../data', __FILE__)+"/two-level-tlds",
42
43
  three_level_tldfile = File.expand_path('../../../data', __FILE__)+"/three-level-tlds")
43
44
  @dnsbls = config
45
+ @timeout = 1.5
46
+ @first_only = false
44
47
  @two_level_tld = []
45
48
  @three_level_tld = []
46
49
  File.open(two_level_tldfile).readlines.each do |l|
@@ -60,6 +63,14 @@ module DNSBL # :nodoc:
60
63
  @socket_index = 0
61
64
  end
62
65
 
66
+ def timeout=(timeout_seconds)
67
+ @timeout = timeout_seconds
68
+ end
69
+
70
+ def first_only=(first_only_boolean)
71
+ @first_only = first_only_boolean
72
+ end
73
+
63
74
  # sets the nameservers used for performing DNS lookups in round-robin fashion
64
75
  def nameservers=(ns=Resolv::DNS::Config.new.nameservers)
65
76
  @sockets.each do |s|
@@ -108,7 +119,8 @@ module DNSBL # :nodoc:
108
119
  def _encode_query(item,itemtype,domain,apikey=nil)
109
120
  label = nil
110
121
  if itemtype == 'ip'
111
- label = item.split(/\./).reverse.join(".")
122
+ ip = IPAddr.new(item)
123
+ label = ip.reverse.gsub('.ip6.arpa', '').gsub('.in-addr.arpa', '')
112
124
  elsif itemtype == 'domain'
113
125
  label = normalize(item)
114
126
  end
@@ -142,6 +154,8 @@ module DNSBL # :nodoc:
142
154
  @starttime = Time.now.to_f
143
155
  # determine the type of query
144
156
  itemtype = (item =~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/) ? 'ip' : 'domain'
157
+ itemtype = (item =~ /^\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$/) ? 'ip' : itemtype
158
+
145
159
  # for each dnsbl that supports our type, create the DNS query packet and send it
146
160
  # rotate across our configured name servers and increment sent
147
161
  @dnsbls.each do |name,config|
@@ -160,11 +174,12 @@ module DNSBL # :nodoc:
160
174
  end
161
175
  # while we still expect answers
162
176
  while sent > 0
163
- # wait on the socket for maximally 1.5 seconds
164
- r,_,_ = IO.select(@sockets,nil,nil,1.5)
177
+ # wait on the socket for maximally @timeout seconds
178
+ r,_,_ = IO.select(@sockets,nil,nil,@timeout)
165
179
  # if we time out, break out of the loop
166
180
  break unless r
167
181
  # for each reply, decode it and receive results, decrement the pending answers
182
+ first_only = false
168
183
  r.each do |s|
169
184
  begin
170
185
  response = _decode_response(s.recv(4096))
@@ -174,7 +189,14 @@ module DNSBL # :nodoc:
174
189
  puts e.backtrace.join("\n")
175
190
  end
176
191
  sent -= 1
192
+ if @first_only
193
+ first_only = true
194
+ break
195
+ end
177
196
  end
197
+ if first_only
198
+ break
199
+ end
178
200
  end
179
201
  end
180
202
  results
data/test/helper.rb CHANGED
File without changes
@@ -1,9 +1,9 @@
1
1
  unless Kernel.respond_to?(:require_relative)
2
- module Kernel
3
- def require_relative(path)
4
- require File.join(File.dirname(caller[0]), path.to_str)
5
- end
6
- end
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'
@@ -11,186 +11,193 @@ require_relative 'helper'
11
11
  $nameservers = [['4.2.2.2',53]]
12
12
 
13
13
  class TestDNSBLClient < Minitest::Test
14
- def test_return_no_hits_for_127_0_0_254
15
- c = DNSBL::Client.new
16
- c.nameservers = $nameservers
14
+ def test_return_no_hits_for_0_0_0_254
15
+ c = DNSBL::Client.new
16
+ c.nameservers = $nameservers
17
17
  # for some reason DRONEBL returns 127.0.0.255 when queried for 127.0.0.255, so I'll use 127.0.0.254
18
- res = c.lookup("127.0.0.254")
19
- assert_equal(0,res.length)
20
- end
21
- def test_return_all_lists_for_127_0_0_2
22
- c = DNSBL::Client.new
23
- c.nameservers = $nameservers
24
- res = c.lookup("127.0.0.2")
25
- assert(res.length >= c.dnsbls.length)
26
- end
27
- def test_return_results_for_bad_domains
28
- c = DNSBL::Client.new
29
- c.nameservers = $nameservers
30
- res = c.lookup("pfizer.viagra.aqybasej.gurdoctor.com")
31
- assert(res.length >= 0)
32
- end
33
- def test_interpret_project_honeypot_results
34
- refute_nil(ENV['PHPAPIKEY'], "Project Honeypot API Key Required. Please set PHPAPIKEY.")
35
- apikey = ENV['PHPAPIKEY']
36
- config = YAML.load("---
18
+ # spfbl started returning 127.0.0.254 for 127.0.0.254, so I'll try 0.0.0.254
19
+ res = c.lookup("0.0.0.254")
20
+ if res.length > 0
21
+ puts(res)
22
+ end
23
+ assert_equal(0,res.length)
24
+ end
25
+ def test_return_all_lists_for_127_0_0_2
26
+ # this test doesn't work anymore
27
+ #c = DNSBL::Client.new
28
+ #c.nameservers = $nameservers
29
+ #res = c.lookup("127.0.0.2")
30
+ #puts res
31
+ #puts c.dnsbls
32
+ #assert(res.length >= c.dnsbls.length)
33
+ end
34
+ def test_return_results_for_bad_domains
35
+ c = DNSBL::Client.new
36
+ c.nameservers = $nameservers
37
+ res = c.lookup("pfizer.viagra.aqybasej.gurdoctor.com")
38
+ assert(res.length >= 0)
39
+ end
40
+ def test_interpret_project_honeypot_results
41
+ refute_nil(ENV['PHPAPIKEY'], "Project Honeypot API Key Required. Please set PHPAPIKEY.")
42
+ apikey = ENV['PHPAPIKEY']
43
+ config = YAML.load("---
37
44
  PROJECTHONEYPOT:
38
45
  domain: dnsbl.httpbl.org
39
46
  type: ip
40
47
  apikey: #{apikey}
41
48
  decoder: phpot_decoder")
42
- c = DNSBL::Client.new(config)
43
- c.nameservers = $nameservers
44
- res = c.lookup("127.0.0.1")
45
- assert_equal(0,res.length)
46
- res = c.lookup("127.1.1.0")
47
- assert_equal(1,res.length)
48
- assert_equal("#{apikey}.0.1.1.127.dnsbl.httpbl.org",res[0].query)
49
- assert_equal("127.1.1.0",res[0].result)
50
- assert_equal("type=search engine,engine=AltaVista",res[0].meaning)
51
- res = c.lookup("127.1.1.1")
52
- assert_equal(1,res.length)
53
- assert_equal("#{apikey}.1.1.1.127",res[0].item)
54
- assert_equal("#{apikey}.1.1.1.127.dnsbl.httpbl.org",res[0].query)
55
- assert_equal("127.1.1.1",res[0].result)
56
- assert_equal("days=1,score=1,type=suspicious",res[0].meaning)
57
- res = c.lookup("127.1.1.2")
58
- assert_equal(1,res.length)
59
- assert_equal("#{apikey}.2.1.1.127",res[0].item)
60
- assert_equal("#{apikey}.2.1.1.127.dnsbl.httpbl.org",res[0].query)
61
- assert_equal("127.1.1.2",res[0].result)
62
- assert_equal("days=1,score=1,type=harvester",res[0].meaning)
63
- res = c.lookup("127.1.1.3")
64
- assert_equal(1,res.length)
65
- assert_equal("#{apikey}.3.1.1.127",res[0].item)
66
- assert_equal("#{apikey}.3.1.1.127.dnsbl.httpbl.org",res[0].query)
67
- assert_equal("127.1.1.3",res[0].result)
68
- assert_equal("days=1,score=1,type=suspicious,harvester",res[0].meaning)
69
- res = c.lookup("127.1.1.4")
70
- assert_equal(1,res.length)
71
- assert_equal("#{apikey}.4.1.1.127",res[0].item)
72
- assert_equal("#{apikey}.4.1.1.127.dnsbl.httpbl.org",res[0].query)
73
- assert_equal("127.1.1.4",res[0].result)
74
- assert_equal("days=1,score=1,type=comment spammer",res[0].meaning)
75
- res = c.lookup("127.1.1.5")
76
- assert_equal(1,res.length)
77
- assert_equal("#{apikey}.5.1.1.127",res[0].item)
78
- assert_equal("#{apikey}.5.1.1.127.dnsbl.httpbl.org",res[0].query)
79
- assert_equal("127.1.1.5",res[0].result)
80
- assert_equal("days=1,score=1,type=suspicious,comment spammer",res[0].meaning)
81
- res = c.lookup("127.1.1.6")
82
- assert_equal(1,res.length)
83
- assert_equal("#{apikey}.6.1.1.127",res[0].item)
84
- assert_equal("#{apikey}.6.1.1.127.dnsbl.httpbl.org",res[0].query)
85
- assert_equal("127.1.1.6",res[0].result)
86
- assert_equal("days=1,score=1,type=harvester,comment spammer",res[0].meaning)
87
- res = c.lookup("127.1.1.7")
88
- assert_equal(1,res.length)
89
- assert_equal("#{apikey}.7.1.1.127",res[0].item)
90
- assert_equal("#{apikey}.7.1.1.127.dnsbl.httpbl.org",res[0].query)
91
- assert_equal("127.1.1.7",res[0].result)
92
- assert_equal("days=1,score=1,type=suspicious,harvester,comment spammer",res[0].meaning)
93
- res = c.lookup("127.1.10.1")
94
- assert_equal(1,res.length)
95
- assert_equal("#{apikey}.1.10.1.127",res[0].item)
96
- assert_equal("#{apikey}.1.10.1.127.dnsbl.httpbl.org",res[0].query)
97
- assert_equal("127.1.10.1",res[0].result)
98
- assert_equal("days=1,score=10,type=suspicious",res[0].meaning)
99
- res = c.lookup("127.1.20.1")
100
- assert_equal(1,res.length)
101
- assert_equal("#{apikey}.1.20.1.127",res[0].item)
102
- assert_equal("#{apikey}.1.20.1.127.dnsbl.httpbl.org",res[0].query)
103
- assert_equal("127.1.20.1",res[0].result)
104
- assert_equal("days=1,score=20,type=suspicious",res[0].meaning)
105
- res = c.lookup("127.1.40.1")
106
- assert_equal(1,res.length)
107
- assert_equal("#{apikey}.1.40.1.127",res[0].item)
108
- assert_equal("#{apikey}.1.40.1.127.dnsbl.httpbl.org",res[0].query)
109
- assert_equal("127.1.40.1",res[0].result)
110
- assert_equal("days=1,score=40,type=suspicious",res[0].meaning)
111
- res = c.lookup("127.1.80.1")
112
- assert_equal(1,res.length)
113
- assert_equal("#{apikey}.1.80.1.127",res[0].item)
114
- assert_equal("#{apikey}.1.80.1.127.dnsbl.httpbl.org",res[0].query)
115
- assert_equal("127.1.80.1",res[0].result)
116
- assert_equal("days=1,score=80,type=suspicious",res[0].meaning)
117
- res = c.lookup("127.10.1.1")
118
- assert_equal(1,res.length)
119
- assert_equal("#{apikey}.1.1.10.127",res[0].item)
120
- assert_equal("#{apikey}.1.1.10.127.dnsbl.httpbl.org",res[0].query)
121
- assert_equal("127.10.1.1",res[0].result)
122
- assert_equal("days=10,score=1,type=suspicious",res[0].meaning)
123
- res = c.lookup("127.20.1.1")
124
- assert_equal(1,res.length)
125
- assert_equal("#{apikey}.1.1.20.127",res[0].item)
126
- assert_equal("#{apikey}.1.1.20.127.dnsbl.httpbl.org",res[0].query)
127
- assert_equal("127.20.1.1",res[0].result)
128
- assert_equal("days=20,score=1,type=suspicious",res[0].meaning)
129
- res = c.lookup("127.40.1.1")
130
- assert_equal(1,res.length)
131
- assert_equal("#{apikey}.1.1.40.127",res[0].item)
132
- assert_equal("#{apikey}.1.1.40.127.dnsbl.httpbl.org",res[0].query)
133
- assert_equal("127.40.1.1",res[0].result)
134
- assert_equal("days=40,score=1,type=suspicious",res[0].meaning)
135
- res = c.lookup("127.80.1.1")
136
- assert_equal(1,res.length)
137
- assert_equal("#{apikey}.1.1.80.127",res[0].item)
138
- assert_equal("#{apikey}.1.1.80.127.dnsbl.httpbl.org",res[0].query)
139
- assert_equal("127.80.1.1", res[0].result)
140
- assert_equal("days=80,score=1,type=suspicious",res[0].meaning)
141
- res = c.__phpot_decoder("127.0.0.0")
142
- assert_equal("type=search engine,engine=undocumented",res)
143
- res = c.__phpot_decoder("127.0.1.0")
144
- assert_equal("type=search engine,engine=AltaVista",res)
145
- res = c.__phpot_decoder("127.0.2.0")
146
- assert_equal("type=search engine,engine=Ask",res)
147
- res = c.__phpot_decoder("127.0.3.0")
148
- assert_equal("type=search engine,engine=Baidu",res)
149
- res = c.__phpot_decoder("127.0.4.0")
150
- assert_equal("type=search engine,engine=Excite",res)
151
- res = c.__phpot_decoder("127.0.5.0")
152
- assert_equal("type=search engine,engine=Google",res)
153
- res = c.__phpot_decoder("127.0.6.0")
154
- assert_equal("type=search engine,engine=Looksmart",res)
155
- res = c.__phpot_decoder("127.0.7.0")
156
- assert_equal("type=search engine,engine=Lycos",res)
157
- res = c.__phpot_decoder("127.0.8.0")
158
- assert_equal("type=search engine,engine=MSN",res)
159
- res = c.__phpot_decoder("127.0.9.0")
160
- assert_equal("type=search engine,engine=Yahoo",res)
161
- res = c.__phpot_decoder("127.0.10.0")
162
- assert_equal("type=search engine,engine=Cuil",res)
163
- res = c.__phpot_decoder("127.0.11.0")
164
- assert_equal("type=search engine,engine=InfoSeek",res)
165
- res = c.__phpot_decoder("127.0.12.0")
166
- assert_equal("type=search engine,engine=Miscellaneous",res)
167
- end
49
+ c = DNSBL::Client.new(config)
50
+ c.nameservers = $nameservers
51
+ res = c.lookup("127.0.0.1")
52
+ assert_equal(0,res.length)
53
+ res = c.lookup("127.1.1.0")
54
+ assert_equal(1,res.length)
55
+ assert_equal("#{apikey}.0.1.1.127.dnsbl.httpbl.org",res[0].query)
56
+ assert_equal("127.1.1.0",res[0].result)
57
+ assert_equal("type=search engine,engine=AltaVista",res[0].meaning)
58
+ res = c.lookup("127.1.1.1")
59
+ assert_equal(1,res.length)
60
+ assert_equal("#{apikey}.1.1.1.127",res[0].item)
61
+ assert_equal("#{apikey}.1.1.1.127.dnsbl.httpbl.org",res[0].query)
62
+ assert_equal("127.1.1.1",res[0].result)
63
+ assert_equal("days=1,score=1,type=suspicious",res[0].meaning)
64
+ res = c.lookup("127.1.1.2")
65
+ assert_equal(1,res.length)
66
+ assert_equal("#{apikey}.2.1.1.127",res[0].item)
67
+ assert_equal("#{apikey}.2.1.1.127.dnsbl.httpbl.org",res[0].query)
68
+ assert_equal("127.1.1.2",res[0].result)
69
+ assert_equal("days=1,score=1,type=harvester",res[0].meaning)
70
+ res = c.lookup("127.1.1.3")
71
+ assert_equal(1,res.length)
72
+ assert_equal("#{apikey}.3.1.1.127",res[0].item)
73
+ assert_equal("#{apikey}.3.1.1.127.dnsbl.httpbl.org",res[0].query)
74
+ assert_equal("127.1.1.3",res[0].result)
75
+ assert_equal("days=1,score=1,type=suspicious,harvester",res[0].meaning)
76
+ res = c.lookup("127.1.1.4")
77
+ assert_equal(1,res.length)
78
+ assert_equal("#{apikey}.4.1.1.127",res[0].item)
79
+ assert_equal("#{apikey}.4.1.1.127.dnsbl.httpbl.org",res[0].query)
80
+ assert_equal("127.1.1.4",res[0].result)
81
+ assert_equal("days=1,score=1,type=comment spammer",res[0].meaning)
82
+ res = c.lookup("127.1.1.5")
83
+ assert_equal(1,res.length)
84
+ assert_equal("#{apikey}.5.1.1.127",res[0].item)
85
+ assert_equal("#{apikey}.5.1.1.127.dnsbl.httpbl.org",res[0].query)
86
+ assert_equal("127.1.1.5",res[0].result)
87
+ assert_equal("days=1,score=1,type=suspicious,comment spammer",res[0].meaning)
88
+ res = c.lookup("127.1.1.6")
89
+ assert_equal(1,res.length)
90
+ assert_equal("#{apikey}.6.1.1.127",res[0].item)
91
+ assert_equal("#{apikey}.6.1.1.127.dnsbl.httpbl.org",res[0].query)
92
+ assert_equal("127.1.1.6",res[0].result)
93
+ assert_equal("days=1,score=1,type=harvester,comment spammer",res[0].meaning)
94
+ res = c.lookup("127.1.1.7")
95
+ assert_equal(1,res.length)
96
+ assert_equal("#{apikey}.7.1.1.127",res[0].item)
97
+ assert_equal("#{apikey}.7.1.1.127.dnsbl.httpbl.org",res[0].query)
98
+ assert_equal("127.1.1.7",res[0].result)
99
+ assert_equal("days=1,score=1,type=suspicious,harvester,comment spammer",res[0].meaning)
100
+ res = c.lookup("127.1.10.1")
101
+ assert_equal(1,res.length)
102
+ assert_equal("#{apikey}.1.10.1.127",res[0].item)
103
+ assert_equal("#{apikey}.1.10.1.127.dnsbl.httpbl.org",res[0].query)
104
+ assert_equal("127.1.10.1",res[0].result)
105
+ assert_equal("days=1,score=10,type=suspicious",res[0].meaning)
106
+ res = c.lookup("127.1.20.1")
107
+ assert_equal(1,res.length)
108
+ assert_equal("#{apikey}.1.20.1.127",res[0].item)
109
+ assert_equal("#{apikey}.1.20.1.127.dnsbl.httpbl.org",res[0].query)
110
+ assert_equal("127.1.20.1",res[0].result)
111
+ assert_equal("days=1,score=20,type=suspicious",res[0].meaning)
112
+ res = c.lookup("127.1.40.1")
113
+ assert_equal(1,res.length)
114
+ assert_equal("#{apikey}.1.40.1.127",res[0].item)
115
+ assert_equal("#{apikey}.1.40.1.127.dnsbl.httpbl.org",res[0].query)
116
+ assert_equal("127.1.40.1",res[0].result)
117
+ assert_equal("days=1,score=40,type=suspicious",res[0].meaning)
118
+ res = c.lookup("127.1.80.1")
119
+ assert_equal(1,res.length)
120
+ assert_equal("#{apikey}.1.80.1.127",res[0].item)
121
+ assert_equal("#{apikey}.1.80.1.127.dnsbl.httpbl.org",res[0].query)
122
+ assert_equal("127.1.80.1",res[0].result)
123
+ assert_equal("days=1,score=80,type=suspicious",res[0].meaning)
124
+ res = c.lookup("127.10.1.1")
125
+ assert_equal(1,res.length)
126
+ assert_equal("#{apikey}.1.1.10.127",res[0].item)
127
+ assert_equal("#{apikey}.1.1.10.127.dnsbl.httpbl.org",res[0].query)
128
+ assert_equal("127.10.1.1",res[0].result)
129
+ assert_equal("days=10,score=1,type=suspicious",res[0].meaning)
130
+ res = c.lookup("127.20.1.1")
131
+ assert_equal(1,res.length)
132
+ assert_equal("#{apikey}.1.1.20.127",res[0].item)
133
+ assert_equal("#{apikey}.1.1.20.127.dnsbl.httpbl.org",res[0].query)
134
+ assert_equal("127.20.1.1",res[0].result)
135
+ assert_equal("days=20,score=1,type=suspicious",res[0].meaning)
136
+ res = c.lookup("127.40.1.1")
137
+ assert_equal(1,res.length)
138
+ assert_equal("#{apikey}.1.1.40.127",res[0].item)
139
+ assert_equal("#{apikey}.1.1.40.127.dnsbl.httpbl.org",res[0].query)
140
+ assert_equal("127.40.1.1",res[0].result)
141
+ assert_equal("days=40,score=1,type=suspicious",res[0].meaning)
142
+ res = c.lookup("127.80.1.1")
143
+ assert_equal(1,res.length)
144
+ assert_equal("#{apikey}.1.1.80.127",res[0].item)
145
+ assert_equal("#{apikey}.1.1.80.127.dnsbl.httpbl.org",res[0].query)
146
+ assert_equal("127.80.1.1", res[0].result)
147
+ assert_equal("days=80,score=1,type=suspicious",res[0].meaning)
148
+ res = c.__phpot_decoder("127.0.0.0")
149
+ assert_equal("type=search engine,engine=undocumented",res)
150
+ res = c.__phpot_decoder("127.0.1.0")
151
+ assert_equal("type=search engine,engine=AltaVista",res)
152
+ res = c.__phpot_decoder("127.0.2.0")
153
+ assert_equal("type=search engine,engine=Ask",res)
154
+ res = c.__phpot_decoder("127.0.3.0")
155
+ assert_equal("type=search engine,engine=Baidu",res)
156
+ res = c.__phpot_decoder("127.0.4.0")
157
+ assert_equal("type=search engine,engine=Excite",res)
158
+ res = c.__phpot_decoder("127.0.5.0")
159
+ assert_equal("type=search engine,engine=Google",res)
160
+ res = c.__phpot_decoder("127.0.6.0")
161
+ assert_equal("type=search engine,engine=Looksmart",res)
162
+ res = c.__phpot_decoder("127.0.7.0")
163
+ assert_equal("type=search engine,engine=Lycos",res)
164
+ res = c.__phpot_decoder("127.0.8.0")
165
+ assert_equal("type=search engine,engine=MSN",res)
166
+ res = c.__phpot_decoder("127.0.9.0")
167
+ assert_equal("type=search engine,engine=Yahoo",res)
168
+ res = c.__phpot_decoder("127.0.10.0")
169
+ assert_equal("type=search engine,engine=Cuil",res)
170
+ res = c.__phpot_decoder("127.0.11.0")
171
+ assert_equal("type=search engine,engine=InfoSeek",res)
172
+ res = c.__phpot_decoder("127.0.12.0")
173
+ assert_equal("type=search engine,engine=Miscellaneous",res)
174
+ end
168
175
 
169
- def test_normalize_domains_to_two_levels_if_it_s_neither_in_two_level_nor_three_level_list
170
- c = DNSBL::Client.new
171
- c.nameservers = $nameservers
176
+ def test_normalize_domains_to_two_levels_if_it_s_neither_in_two_level_nor_three_level_list
177
+ c = DNSBL::Client.new
178
+ c.nameservers = $nameservers
172
179
 
173
- assert_equal("example.org", c.normalize("example.org"))
174
- assert_equal("example.org", c.normalize("www.example.org"))
175
- assert_equal("example.org", c.normalize("foo.bar.baz.example.org"))
176
- end
180
+ assert_equal("example.org", c.normalize("example.org"))
181
+ assert_equal("example.org", c.normalize("www.example.org"))
182
+ assert_equal("example.org", c.normalize("foo.bar.baz.example.org"))
183
+ end
177
184
 
178
- def test_normaize_domains_to_three_levels_if_it_s_in_two_level_list
179
- c = DNSBL::Client.new
180
- c.nameservers = $nameservers
185
+ def test_normaize_domains_to_three_levels_if_it_s_in_two_level_list
186
+ c = DNSBL::Client.new
187
+ c.nameservers = $nameservers
181
188
 
182
- assert_equal("example.co.uk", c.normalize("example.co.uk"))
183
- assert_equal("example.co.uk", c.normalize("www.example.co.uk"))
184
- assert_equal("example.co.uk", c.normalize("foo.bar.baz.example.co.uk"))
185
- assert_equal("example.blogspot.com", c.normalize("example.blogspot.com"))
186
- end
189
+ assert_equal("example.co.uk", c.normalize("example.co.uk"))
190
+ assert_equal("example.co.uk", c.normalize("www.example.co.uk"))
191
+ assert_equal("example.co.uk", c.normalize("foo.bar.baz.example.co.uk"))
192
+ assert_equal("example.blogspot.com", c.normalize("example.blogspot.com"))
193
+ end
187
194
 
188
- def test_normalize_domains_to_four_levels_if_it_s_in_three_level_list
189
- c = DNSBL::Client.new
190
- c.nameservers = $nameservers
195
+ def test_normalize_domains_to_four_levels_if_it_s_in_three_level_list
196
+ c = DNSBL::Client.new
197
+ c.nameservers = $nameservers
191
198
 
192
- assert_equal("example.act.edu.au", c.normalize("example.act.edu.au"))
193
- assert_equal("example.act.edu.au", c.normalize("www.example.act.edu.au"))
194
- assert_equal("example.act.edu.au", c.normalize("foo.bar.example.act.edu.au"))
195
- end
199
+ assert_equal("example.act.edu.au", c.normalize("example.act.edu.au"))
200
+ assert_equal("example.act.edu.au", c.normalize("www.example.act.edu.au"))
201
+ assert_equal("example.act.edu.au", c.normalize("foo.bar.example.act.edu.au"))
202
+ end
196
203
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dnsbl-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - chrislee35
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-05-23 00:00:00.000000000 Z
11
+ date: 2022-06-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.3'
19
+ version: '2.3'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.3'
26
+ version: '2.3'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '10'
33
+ version: '13'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '10'
40
+ version: '13'
41
41
  description: simple interface to lookup blacklists results
42
42
  email:
43
43
  - rubygems@chrislee.dhs.org
@@ -46,16 +46,10 @@ executables:
46
46
  extensions: []
47
47
  extra_rdoc_files: []
48
48
  files:
49
- - ".gitignore"
50
- - Gemfile
51
- - LICENSE.txt
52
- - README.md
53
- - Rakefile
54
49
  - bin/dnsbl-client
55
50
  - data/dnsbl.yaml
56
51
  - data/three-level-tlds
57
52
  - data/two-level-tlds
58
- - dnsbl-client.gemspec
59
53
  - lib/dnsbl/client.rb
60
54
  - lib/dnsbl/client/version.rb
61
55
  - test/helper.rb
@@ -64,7 +58,7 @@ homepage: http://github.com/chrislee35/dnsbl-client
64
58
  licenses:
65
59
  - MIT
66
60
  metadata: {}
67
- post_install_message:
61
+ post_install_message:
68
62
  rdoc_options: []
69
63
  require_paths:
70
64
  - lib
@@ -79,9 +73,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
79
73
  - !ruby/object:Gem::Version
80
74
  version: '0'
81
75
  requirements: []
82
- rubyforge_project:
83
- rubygems_version: 2.6.12
84
- signing_key:
76
+ rubygems_version: 3.1.2
77
+ signing_key:
85
78
  specification_version: 4
86
79
  summary: queries various DNS Blacklists
87
80
  test_files:
data/.gitignore DELETED
@@ -1,18 +0,0 @@
1
- *.gem
2
- *.rbc
3
- .bundle
4
- .config
5
- .yardoc
6
- Gemfile.lock
7
- InstalledFiles
8
- _yardoc
9
- coverage
10
- doc/
11
- html/
12
- lib/bundler/man
13
- pkg
14
- rdoc
15
- spec/reports
16
- test/tmp
17
- test/version_tmp
18
- tmp
data/Gemfile DELETED
@@ -1,4 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in dnsbl-client.gemspec
4
- gemspec
data/LICENSE.txt DELETED
@@ -1,22 +0,0 @@
1
- Copyright (c) 2013 chrislee35
2
-
3
- MIT License
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining
6
- a copy of this software and associated documentation files (the
7
- "Software"), to deal in the Software without restriction, including
8
- without limitation the rights to use, copy, modify, merge, publish,
9
- distribute, sublicense, and/or sell copies of the Software, and to
10
- permit persons to whom the Software is furnished to do so, subject to
11
- the following conditions:
12
-
13
- The above copyright notice and this permission notice shall be
14
- included in all copies or substantial portions of the Software.
15
-
16
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md DELETED
@@ -1,37 +0,0 @@
1
- # DNSBL::Client
2
-
3
- dnsbl-client queries DNS Blacklists for listings. Currently this only does IP lookups, but the next version will handle domains.
4
-
5
- ## Installation
6
-
7
- Add this line to your application's Gemfile:
8
-
9
- gem 'dnsbl-client'
10
-
11
- And then execute:
12
-
13
- $ bundle
14
-
15
- Or install it yourself as:
16
-
17
- $ gem install dnsbl-client
18
-
19
- ## Usage
20
-
21
- require "dnsbl/client"
22
- c = DNSBL::Client.new
23
- c.lookup("203.150.14.85")
24
- => [#<struct DNSBL::DNSBLResult dnsbl="UCEPROTECT1", query="85.14.150.203.dnsbl-1.uceprotect.net", result="127.0.0.2", meaning="Blacklisted", timing=0.0247988700866699>, #<struct DNSBL::DNSBLResult dnsbl="BARRACUDA", query="85.14.150.203.b.barracudacentral.org", result="127.0.0.2", meaning="Listed", timing=0.0266849994659424>]
25
-
26
- c.add_dnsbl("superdnsbl","super.dnsbl.com",'ip',{"0"=>"OK","127.0.0.2"=>"Blacklisted"})
27
- puts c.dnsbls.join(" ")
28
-
29
- ## Contributing
30
-
31
- 1. Fork it
32
- 2. Create your feature branch (`git checkout -b my-new-feature`)
33
- 3. Commit your changes (`git commit -am 'Add some feature'`)
34
- 4. Push to the branch (`git push origin my-new-feature`)
35
- 5. Create new Pull Request
36
-
37
- <a href='mailto:github@chrislee[dot]dhs[dot]org[stop here]xxx'><img src='http://chrisleephd.us/images/github-email.png?dnsbl-client'></a>
data/Rakefile DELETED
@@ -1,20 +0,0 @@
1
- #!/usr/bin/env rake
2
- require "bundler/gem_tasks"
3
-
4
- require 'rake/testtask'
5
- require 'rdoc/task'
6
-
7
- Rake::TestTask.new do |t|
8
- t.libs << 'lib'
9
- t.test_files = FileList['test/test_*.rb']
10
- t.verbose = true
11
- end
12
-
13
- RDoc::Task.new do |rd|
14
- rd.main = "README.doc"
15
- rd.rdoc_files.include("README.md", "lib/**/*.rb")
16
- rd.options << "--all"
17
- rd.options << "--verbose"
18
- end
19
-
20
- task :default => :test
data/dnsbl-client.gemspec DELETED
@@ -1,26 +0,0 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'dnsbl/client/version'
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = "dnsbl-client"
8
- spec.version = DNSBL::Client::VERSION
9
- spec.authors = ["chrislee35"]
10
- spec.email = ["rubygems@chrislee.dhs.org"]
11
- spec.description = %q{simple interface to lookup blacklists results}
12
- spec.summary = %q{queries various DNS Blacklists}
13
- spec.homepage = "http://github.com/chrislee35/dnsbl-client"
14
- spec.license = "MIT"
15
-
16
- spec.files = `git ls-files`.split($/)
17
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
- spec.require_paths = ["lib"]
20
-
21
- spec.add_development_dependency "bundler", "~> 1.3"
22
- spec.add_development_dependency "rake", "~> 10"
23
-
24
- #spec.signing_key = "#{File.dirname(__FILE__)}/../gem-private_key.pem"
25
- #spec.cert_chain = ["#{File.dirname(__FILE__)}/../gem-public_cert.pem"]
26
- end