whois 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (9) hide show
  1. data/CHANGELOG +9 -0
  2. data/EXAMPLES +17 -0
  3. data/LICENSE +1020 -0
  4. data/NOTES +16 -0
  5. data/README +25 -0
  6. data/lib/data/ipv4.yaml +200 -0
  7. data/lib/server/server.rb +77 -0
  8. data/lib/whois.rb +115 -0
  9. metadata +61 -0
data/NOTES ADDED
@@ -0,0 +1,16 @@
1
+ = Whois Release Notes
2
+
3
+ == 0.2.0
4
+
5
+ It's my first version. This version is base to code of Whois unix program in C of Marco d'Itri.
6
+
7
+ In this programme a list of whois server is write and I create a parser for create a Yaml file
8
+ with this list. The parser is parse_list.rb[link://util/parse_list.rb].
9
+
10
+ The list of Whois Server, for each Ipv4 is in ipv4.yaml[link://lib/data/ipv4.yaml]. A Ruby Class
11
+ exist for all Whois Server check in this Yaml file. All Server are in server.rb[link://lib/server/server.rb]
12
+
13
+ == 0.1.O
14
+
15
+ It's the old version by Michael Neumann. Thank to him.
16
+ If you see his work, check out his class[link://old/whois.rb]
data/README ADDED
@@ -0,0 +1,25 @@
1
+ = Whois
2
+
3
+ Whois is a class for obtains information on whois with an Ipv4, Ipv6 and host.
4
+ This class send a whois-query to whois suitable server.
5
+ After parse information must be return
6
+
7
+ This library is start with work to Michael Neumann. Thank to him.
8
+ If you see his work, check out his class[link://old/whois.rb]
9
+
10
+ == Dependencies
11
+
12
+ * ruby 1.8.2
13
+
14
+ == Examples
15
+
16
+ If you are just starting, check out the EXAMPLES[link://files/EXAMPLES.html] file.
17
+
18
+ == Authors
19
+
20
+ Copyright (c) 2007 by Cyril Mougel (cyril.mougel@gmail.com)
21
+
22
+ == License
23
+
24
+ This library is distributed under the GPL. Please see the LICENSE file.
25
+
@@ -0,0 +1,200 @@
1
+ ---
2
+ 222.96.0.0/12: Nicor
3
+ 218.160.0.0/12: Twnic
4
+ 209.94.192.0/19: Lacnic
5
+ 155.232.0.0/13: Afrinic
6
+ 164.146.0.0/15: Afrinic
7
+ 202.16.0.0/14: Nicad
8
+ 218.216.0.0/13: Nicad
9
+ 202.0.0.0/7: Apnic
10
+ 192.71.0.0/16: Ripe
11
+ 61.112.0.0/12: Nicad
12
+ 141.64.0.0/12: Ripe
13
+ 43.0.0.0/8: V6nic
14
+ 211.112.0.0/13: Nicor
15
+ 211.20.0.0/15: Twnic
16
+ 202.224.0.0/11: Nicad
17
+ 151.100.0.0/16: Ripe
18
+ 160.124.0.0/16: Afrinic
19
+ 214.0.0.0/7: Arin
20
+ 210.242.0.0/15: Twnic
21
+ 61.192.0.0/12: Nicad
22
+ 163.156.0.0/14: Ripe
23
+ 171.16.0.0/12: Ripe
24
+ 200.128.0.0/9: Nicbr
25
+ 219.96.0.0/11: Nicad
26
+ 149.240.0.0/13: Ripe
27
+ 164.0.0.0/11: Ripe
28
+ 151.0.0.0/10: Ripe
29
+ 192.72.253.0/24: Arin
30
+ 221.144.0.0/12: Nicor
31
+ 203.66.0.0/16: Twnic
32
+ 202.11.0.0/16: Nicad
33
+ 0.0.0.0/1: Arin
34
+ 149.248.0.0/14: Ripe
35
+ 59.0.0.0/11: Nicor
36
+ 41.0.0.0/8: Afrinic
37
+ 149.204.0.0/16: Ripe
38
+ 218.232.0.0/13: Nicor
39
+ 218.224.0.0/13: Nicad
40
+ 210.248.0.0/13: Nicad
41
+ 210.204.0.0/14: Nicor
42
+ 202.24.0.0/15: Nicad
43
+ 200.0.0.0/7: Lacnic
44
+ 200.17.0.0/16: Nicbr
45
+ 125.128.0.0/11: Nicor
46
+ 150.254.0.0/16: Ripe
47
+ 164.32.0.0/13: Ripe
48
+ 211.192.0.0/10: Nicor
49
+ 203.69.0.0/16: Twnic
50
+ 192.118.0.0/16: Ripe
51
+ 202.39.128.0/17: Twnic
52
+ 220.149.0.0/16: Nicor
53
+ 212.0.0.0/7: Ripe
54
+ 211.128.0.0/13: Nicad
55
+ 211.120.0.0/13: Nicad
56
+ 210.71.128.0/16: Twnic
57
+ 203.140.0.0/15: Nicad
58
+ 96.0.0.0/3:
59
+ 196.0.0.0/6: Arin
60
+ 192.164.0.0/14: Ripe
61
+ 165.144.0.0/14: Afrinic
62
+ 155.240.0.0/16: Afrinic
63
+ 218.36.0.0/14: Nicor
64
+ 213.154.64.0/19: Afrinic
65
+ 210.240.0.0/16: Twnic
66
+ 210.128.0.0/11: Nicad
67
+ 210.59.128.0/17: Twnic
68
+ 223.0.0.0/8:
69
+ 219.248.0.0/13: Nicor
70
+ 211.72.0.0/16: Twnic
71
+ 203.74.0.0/15: Twnic
72
+ 203.0.0.0/10: Apnic
73
+ 196.0.0.0/8: Afrinic
74
+ 149.202.0.0/15: Ripe
75
+ 210.241.224.0/19: Twnic
76
+ 96.0.0.0/6: Arin
77
+ 171.32.0.0/15: Ripe
78
+ 220.64.0.0/11: Nicor
79
+ 219.240.0.0/15: Nicor
80
+ 210.0.0.0/7: Apnic
81
+ 211.16.0.0/14: Nicad
82
+ 210.92.0.0/14: Nicor
83
+ 202.32.0.0/14: Nicad
84
+ 220.103.0.0/16: Nicor
85
+ 211.75.0.0/16: Twnic
86
+ 202.20.128.0/17: Nicor
87
+ 208.0.0.0/7: Arin
88
+ 202.48.0.0/16: Nicad
89
+ 163.200.0.0/14: Afrinic
90
+ 61.208.0.0/13: Nicad
91
+ 139.24.0.0/14: Ripe
92
+ 62.0.0.0/8: Ripe
93
+ 222.232.0.0/13: Nicor
94
+ 61.84.0.0/15: Nicor
95
+ 194.0.0.0/7: Ripe
96
+ 126.0.0.0/8: Apnic
97
+ 150.183.0.0/16: Nicor
98
+ 141.80.0.0/14: Ripe
99
+ 163.195.0.0/16: Afrinic
100
+ 160.115.0.0/16: Afrinic
101
+ 211.32.0.0/11: Nicor
102
+ 192.72.0.0/16: Apnic
103
+ 164.40.0.0/16: Ripe
104
+ 210.61.0.0/16: Twnic
105
+ 160.120.0.0/14: Afrinic
106
+ 221.160.0.0/13: Nicor
107
+ 160.44.0.0/14: Ripe
108
+ 151.96.0.0/14: Ripe
109
+ 220.0.0.0/6: Apnic
110
+ 222.112.0.0/13: Nicor
111
+ 220.104.0.0/13: Nicad
112
+ 203.136.0.0/14: Nicad
113
+ 149.208.0.0/12: Ripe
114
+ 141.0.0.0/10: Ripe
115
+ 192.116.0.0/15: Ripe
116
+ 192.106.0.0/16: Ripe
117
+ 202.30.0.0/15: Nicor
118
+ 60.0.0.0/7: Apnic
119
+ 200.18.0.0/15: Nicbr
120
+ 160.220.0.0/16: Ripe
121
+ 124.0.0.0/7: Apnic
122
+ 58.0.0.0/7: Apnic
123
+ 218.0.0.0/7: Apnic
124
+ 204.0.0.0/14: Verio
125
+ 193.0.0.0/8: Ripe
126
+ 200.20.0.0/16: Nicbr
127
+ 192.162.0.0/16: Ripe
128
+ 202.15.0.0/16: Nicad
129
+ 163.196.0.0/14: Afrinic
130
+ 222.122.0.0/16: Nicor
131
+ 221.138.0.0/13: Nicor
132
+ 121.128.0.0/10: Nicor
133
+ 211.0.0.0/12: Nicad
134
+ 210.241.0.0/15: Twnic
135
+ 210.216.0.0/13: Nicor
136
+ 61.72.0.0/13: Nicor
137
+ 122.0.0.0/7: Apnic
138
+ 192.114.0.0/15: Ripe
139
+ 80.0.0.0/5: Ripe
140
+ 210.188.0.0/14: Nicad
141
+ 210.178.0.0/15: Nicor
142
+ 210.90.0.0/15: Nicor
143
+ 203.180.0.0/14: Nicad
144
+ 146.48.0.0/16: Ripe
145
+ 202.208.0.0/12: Nicad
146
+ 163.160.0.0/12: Ripe
147
+ 192.72.254.0/24: Arin
148
+ 213.154.32.0/19: Afrinic
149
+ 211.168.0.0/13: Nicor
150
+ 211.22.0.0/16: Twnic
151
+ 210.180.0.0/14: Nicor
152
+ 139.28.0.0/15: Ripe
153
+ 165.148.0.0/15: Afrinic
154
+ 222.120.0.0/15: Nicor
155
+ 220.96.0.0/14: Nicad
156
+ 216.0.0.0/8: Arin
157
+ 210.96.0.0/11: Nicor
158
+ 192.0.0.0/8: Arin
159
+ 133.0.0.0/8: Nicad
160
+ 149.206.0.0/15: Ripe
161
+ 160.116.0.0/14: Afrinic
162
+ 218.144.0.0/12: Nicor
163
+ 217.0.0.0/8: Ripe
164
+ 210.224.0.0/12: Nicad
165
+ 210.160.0.0/12: Nicad
166
+ 210.65.0.0/16: Twnic
167
+ 160.216.0.0/14: Ripe
168
+ 164.148.0.0/14: Afrinic
169
+ 189.0.0.0/8: Lacnic
170
+ 202.23.0.0/16: Nicad
171
+ 145.0.0.0/8: Ripe
172
+ 204.0.0.0/6: Arin
173
+ 165.143.0.0/16: Afrinic
174
+ 121.0.0.0/8: Apnic
175
+ 169.208.0.0/12: Apnic
176
+ 211.104.0.0/13: Nicor
177
+ 210.196.0.0/14: Nicad
178
+ 24.132.0.0/14: Ripe
179
+ 149.224.0.0/12: Ripe
180
+ 202.26.0.0/16: Nicad
181
+ 218.48.0.0/13: Nicor
182
+ 218.40.0.0/13: Nicad
183
+ 211.176.0.0/12: Nicor
184
+ 203.178.0.0/15: Nicad
185
+ 139.20.0.0/14: Ripe
186
+ 151.64.0.0/11: Ripe
187
+ 190.0.0.0/8: Lacnic
188
+ 200.96.0.0/13: Nicbr
189
+ 61.80.0.0/14: Nicor
190
+ 164.128.0.0/12: Ripe
191
+ 160.48.0.0/12: Ripe
192
+ 128.0.0.0/2: Arin
193
+ 141.84.0.0/15: Ripe
194
+ 210.62.252.0/22: Twnic
195
+ 203.224.0.0/11: Nicor
196
+ 77.0.0.0/8: Ripe
197
+ 88.0.0.0/6: Ripe
198
+ 188.0.0.0/8: Ripe
199
+ 202.13.0.0/16: Nicad
200
+ 78.0.0.0/7: Ripe
@@ -0,0 +1,77 @@
1
+ module Server
2
+
3
+ # Define if the module has or not the Class in this module
4
+ def self.class_exist? str
5
+ begin
6
+ self.class_eval str
7
+ return true
8
+ rescue NameError
9
+ return false
10
+ end
11
+ end
12
+
13
+ # Class For define a model of Server
14
+ class Server
15
+ attr_reader :server
16
+
17
+ end
18
+
19
+ # Class for the server Afrinic
20
+ class Afrinic < Server
21
+
22
+ def initialize
23
+ @server = 'whois.afrinic.net'
24
+ end
25
+ end
26
+
27
+ # Class for the Server Apnic
28
+ class Apnic < Server
29
+
30
+ def initialize
31
+ @server = 'whois.apnic.net'
32
+ end
33
+ end
34
+
35
+ # Class for the Server Ripe
36
+ class Ripe < Server
37
+ def initialize
38
+ @server = 'whois.ripe.net'
39
+ end
40
+ end
41
+
42
+ # Class for the Server Arin
43
+ class Arin < Server
44
+ def initialize
45
+ @server = 'whois.arin.net'
46
+ end
47
+ end
48
+
49
+ # Class for the Server Lacnic
50
+ class Lacnic < Server
51
+ def initialize
52
+ @server = 'whois.lacnic.net'
53
+ end
54
+ end
55
+
56
+ # Class for Server whois.nic.or.kr
57
+ class NicOr < Server
58
+ def initialize
59
+ @server = 'whois.nic.or.kr'
60
+ end
61
+ end
62
+
63
+ # Class for Server whois.nic.ad.jp
64
+ class NicAd < Server
65
+ def initialize
66
+ @server = 'whois.nic.ad.jp'
67
+ end
68
+ end
69
+
70
+ # Class for Server whois.nic.br
71
+ class NicBr < Server
72
+ def initialize
73
+ @server = 'whois.nic.br'
74
+ end
75
+ end
76
+
77
+ end
@@ -0,0 +1,115 @@
1
+ #!/usr/bin/ruby -w
2
+
3
+ require 'socket'
4
+ require 'resolv'
5
+ require 'ipaddr'
6
+ require 'yaml'
7
+ require 'server/server'
8
+
9
+ module Whois
10
+
11
+ class WhoisException < Exception
12
+ end
13
+
14
+ # Class to get all information about Host or IP with the Whois
15
+ class Whois
16
+
17
+ attr_reader :all
18
+ attr_reader :server
19
+ attr_reader :ip
20
+
21
+ # Initialize with a request. The request must be an IPv4
22
+ def initialize(request)
23
+ if /^\d+\.\d+\.\d+\.\d+$/ =~ request
24
+ ipv4_init request
25
+ unless self.server
26
+ raise WhoisException.new("no server found for this IPv4 : #{request}")
27
+ end
28
+ else
29
+ raise WhoisException.new('not implement now, only Ipv4')
30
+ end
31
+ end
32
+
33
+ # Ask of whois server
34
+ def search_whois
35
+ s = TCPsocket.open(self.server.server, 43)
36
+ s.write("#{self.ip.to_s}\n")
37
+ ret = ''
38
+ while s.gets do ret += $_ end
39
+ s.close
40
+ @all = ret
41
+ end
42
+
43
+ private
44
+
45
+ # Init value for a ipv4 request
46
+ def ipv4_init (ip)
47
+ @ip = IPAddr.new ip
48
+ @server = server_ipv4
49
+ end
50
+
51
+ # Define the server of Whois in IPV4 list of YAML
52
+ def server_ipv4
53
+ ipv4_list = YAML::load_file('data/ipv4.yaml')
54
+ # Search good Server class for this IP
55
+ ipv4_list.each do |ip, server|
56
+ ip_range = IPAddr.new ip
57
+ if ip_range.include? self.ip
58
+ return Object.instance_eval("Server::#{server}.new")
59
+ end
60
+ end
61
+ end
62
+ end
63
+ end
64
+
65
+
66
+ if $0 == __FILE__
67
+
68
+ #a = YAML::load_file('data/ipv4.yaml')
69
+ #b = a[41]
70
+ #b.init
71
+
72
+ # puts b.server
73
+
74
+ w = Whois::Whois.new '41.14.221.147'
75
+ puts w.search_whois
76
+
77
+ begin
78
+ w = Whois::Whois.new '42.14.221.147'
79
+ puts w.search_whois
80
+ rescue Whois::WhoisException
81
+ puts 'rescue'
82
+ end
83
+
84
+ # Test with Apnic Server
85
+ w = Whois::Whois.new '218.14.221.147'
86
+ puts w.search_whois
87
+
88
+ w = Whois::Whois.new '61.80.221.147'
89
+ puts w.search_whois
90
+
91
+ # Test whois Ripe Server
92
+ w = Whois::Whois.new '194.14.221.147'
93
+ puts w.search_whois
94
+
95
+ # Test whois Arin Server
96
+ w = Whois::Whois.new '216.14.221.147'
97
+ puts w.search_whois
98
+
99
+ # Test whois Lacnic Server
100
+ w = Whois::Whois.new '200.14.221.147'
101
+ puts w.search_whois
102
+
103
+ # ip = Resolv.getname '72.14.221.147'
104
+ # puts ip
105
+ #
106
+ # ip = Resolv.getaddress 'google.com'
107
+ # puts ip
108
+ #
109
+ # w = Whois::Whois.new '72.14.221.147'
110
+ # puts w.search_whois
111
+ #
112
+ w = Whois::Whois.new 'fg-in-f147.google.com'
113
+ puts w.search_whois
114
+ # puts w.all
115
+ end
metadata ADDED
@@ -0,0 +1,61 @@
1
+ --- !ruby/object:Gem::Specification
2
+ rubygems_version: 0.8.11
3
+ specification_version: 1
4
+ name: whois
5
+ version: !ruby/object:Gem::Version
6
+ version: 0.2.0
7
+ date: 2007-03-20 00:00:00 +01:00
8
+ summary: Whois provides a library for request whois server
9
+ require_paths:
10
+ - lib
11
+ email: cyril.mougel@gmail.com
12
+ homepage: whois.rubyforge.org
13
+ rubyforge_project: whois
14
+ description:
15
+ autorequire:
16
+ default_executable:
17
+ bindir: bin
18
+ has_rdoc: true
19
+ required_ruby_version: !ruby/object:Gem::Version::Requirement
20
+ requirements:
21
+ - - ">"
22
+ - !ruby/object:Gem::Version
23
+ version: 0.0.0
24
+ version:
25
+ platform: ruby
26
+ signing_key:
27
+ cert_chain:
28
+ authors:
29
+ - Cyril Mougel
30
+ files:
31
+ - lib/data
32
+ - lib/whois.rb
33
+ - lib/server
34
+ - lib/data/ipv4.yaml
35
+ - lib/server/server.rb
36
+ - README
37
+ - EXAMPLES
38
+ - CHANGELOG
39
+ - LICENSE
40
+ - NOTES
41
+ test_files: []
42
+
43
+ rdoc_options:
44
+ - --main
45
+ - README
46
+ - --title
47
+ - "'Whois RDoc'"
48
+ extra_rdoc_files:
49
+ - README
50
+ - EXAMPLES
51
+ - CHANGELOG
52
+ - LICENSE
53
+ - NOTES
54
+ executables: []
55
+
56
+ extensions: []
57
+
58
+ requirements: []
59
+
60
+ dependencies: []
61
+