wmap 2.4.4

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.
Files changed (141) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +141 -0
  3. data/LICENSE.txt +15 -0
  4. data/README.rdoc +98 -0
  5. data/TODO +13 -0
  6. data/bin/deprime +21 -0
  7. data/bin/distrust +38 -0
  8. data/bin/googleBot +23 -0
  9. data/bin/prime +21 -0
  10. data/bin/refresh +26 -0
  11. data/bin/run_tests +16 -0
  12. data/bin/spiderBot +26 -0
  13. data/bin/trust +38 -0
  14. data/bin/updateAll +57 -0
  15. data/bin/wadd +25 -0
  16. data/bin/wadds +26 -0
  17. data/bin/wcheck +28 -0
  18. data/bin/wdel +25 -0
  19. data/bin/wdump +21 -0
  20. data/bin/wmap +151 -0
  21. data/bin/wscan +32 -0
  22. data/data/cidrs +2 -0
  23. data/data/deactivated_sites +1 -0
  24. data/data/domains +2 -0
  25. data/data/hosts +1 -0
  26. data/data/prime_hosts +1 -0
  27. data/data/sites +2 -0
  28. data/data/sub_domains +2 -0
  29. data/demos/bruter.rb +27 -0
  30. data/demos/dns_brutes.rb +28 -0
  31. data/demos/filter_cidr.rb +18 -0
  32. data/demos/filter_crawls.rb +5 -0
  33. data/demos/filter_domain.rb +25 -0
  34. data/demos/filter_geoip.rb +26 -0
  35. data/demos/filter_known_services.rb +59 -0
  36. data/demos/filter_netinfo.rb +23 -0
  37. data/demos/filter_prime.rb +25 -0
  38. data/demos/filter_profiler.rb +3 -0
  39. data/demos/filter_redirection.rb +19 -0
  40. data/demos/filter_site.rb +40 -0
  41. data/demos/filter_siteip.rb +31 -0
  42. data/demos/filter_status.rb +17 -0
  43. data/demos/filter_timestamp.rb +23 -0
  44. data/demos/filter_url.rb +19 -0
  45. data/demos/new_fnd.rb +66 -0
  46. data/demos/nmap_parser.pl +138 -0
  47. data/demos/site_format.rb +18 -0
  48. data/demos/whois_domain.rb +78 -0
  49. data/dicts/GeoIP.dat +0 -0
  50. data/dicts/GeoIPASNum.dat +0 -0
  51. data/dicts/GeoLiteCity.dat +0 -0
  52. data/dicts/ccsld.txt +2646 -0
  53. data/dicts/cctld.txt +243 -0
  54. data/dicts/gtld.txt +25 -0
  55. data/dicts/hostnames-dict.big +1402 -0
  56. data/dicts/hostnames-dict.txt +101 -0
  57. data/lib/wmap/cidr_tracker.rb +327 -0
  58. data/lib/wmap/dns_bruter.rb +308 -0
  59. data/lib/wmap/domain_tracker/sub_domain.rb +142 -0
  60. data/lib/wmap/domain_tracker.rb +342 -0
  61. data/lib/wmap/geoip_tracker.rb +72 -0
  62. data/lib/wmap/google_search_scraper.rb +177 -0
  63. data/lib/wmap/host_tracker/primary_host.rb +130 -0
  64. data/lib/wmap/host_tracker.rb +550 -0
  65. data/lib/wmap/network_profiler.rb +144 -0
  66. data/lib/wmap/port_scanner.rb +208 -0
  67. data/lib/wmap/site_tracker/deactivated_site.rb +85 -0
  68. data/lib/wmap/site_tracker.rb +937 -0
  69. data/lib/wmap/url_checker.rb +314 -0
  70. data/lib/wmap/url_crawler.rb +381 -0
  71. data/lib/wmap/utils/domain_root.rb +184 -0
  72. data/lib/wmap/utils/logger.rb +53 -0
  73. data/lib/wmap/utils/url_magic.rb +343 -0
  74. data/lib/wmap/utils/utils.rb +333 -0
  75. data/lib/wmap/whois.rb +76 -0
  76. data/lib/wmap.rb +227 -0
  77. data/logs/wmap.log +17 -0
  78. data/ruby_whois_patches/base_cocca2.rb +149 -0
  79. data/ruby_whois_patches/kero.yachay.pe.rb +120 -0
  80. data/ruby_whois_patches/whois.PublicDomainRegistry.com.rb +124 -0
  81. data/ruby_whois_patches/whois.above.com.rb +61 -0
  82. data/ruby_whois_patches/whois.adamsnames.tc.rb +107 -0
  83. data/ruby_whois_patches/whois.aeda.net.ae.rb +105 -0
  84. data/ruby_whois_patches/whois.ai.rb +112 -0
  85. data/ruby_whois_patches/whois.arnes.si.rb +121 -0
  86. data/ruby_whois_patches/whois.ascio.com.rb +91 -0
  87. data/ruby_whois_patches/whois.cnnic.cn.rb +123 -0
  88. data/ruby_whois_patches/whois.corporatedomains.com.rb +67 -0
  89. data/ruby_whois_patches/whois.crsnic.net.rb +108 -0
  90. data/ruby_whois_patches/whois.denic.de.rb +174 -0
  91. data/ruby_whois_patches/whois.dk-hostmaster.dk.rb +120 -0
  92. data/ruby_whois_patches/whois.dns.be.rb +134 -0
  93. data/ruby_whois_patches/whois.dns.lu.rb +129 -0
  94. data/ruby_whois_patches/whois.dns.pl.rb +150 -0
  95. data/ruby_whois_patches/whois.dns.pt.rb +119 -0
  96. data/ruby_whois_patches/whois.domain.kg.rb +126 -0
  97. data/ruby_whois_patches/whois.domainregistry.my.rb +123 -0
  98. data/ruby_whois_patches/whois.domreg.lt.rb +110 -0
  99. data/ruby_whois_patches/whois.dot.tk.rb +140 -0
  100. data/ruby_whois_patches/whois.hkirc.hk.rb +121 -0
  101. data/ruby_whois_patches/whois.isnic.is.rb +130 -0
  102. data/ruby_whois_patches/whois.je.rb +119 -0
  103. data/ruby_whois_patches/whois.jprs.jp.rb +137 -0
  104. data/ruby_whois_patches/whois.kenic.or.ke.rb +140 -0
  105. data/ruby_whois_patches/whois.markmonitor.com.rb +118 -0
  106. data/ruby_whois_patches/whois.melbourneit.com.rb +58 -0
  107. data/ruby_whois_patches/whois.nic.as.rb +96 -0
  108. data/ruby_whois_patches/whois.nic.at.rb +109 -0
  109. data/ruby_whois_patches/whois.nic.ch.rb +141 -0
  110. data/ruby_whois_patches/whois.nic.cl.rb +117 -0
  111. data/ruby_whois_patches/whois.nic.ec.rb +157 -0
  112. data/ruby_whois_patches/whois.nic.im.rb +120 -0
  113. data/ruby_whois_patches/whois.nic.it.rb +170 -0
  114. data/ruby_whois_patches/whois.nic.lv.rb +116 -0
  115. data/ruby_whois_patches/whois.nic.ly.rb +127 -0
  116. data/ruby_whois_patches/whois.nic.mu.rb +27 -0
  117. data/ruby_whois_patches/whois.nic.mx.rb +123 -0
  118. data/ruby_whois_patches/whois.nic.net.sa.rb +111 -0
  119. data/ruby_whois_patches/whois.nic.or.kr.rb +101 -0
  120. data/ruby_whois_patches/whois.nic.tel.rb +129 -0
  121. data/ruby_whois_patches/whois.nic.tr.rb +133 -0
  122. data/ruby_whois_patches/whois.nic.us.rb +129 -0
  123. data/ruby_whois_patches/whois.nic.ve.rb +135 -0
  124. data/ruby_whois_patches/whois.norid.no.rb +127 -0
  125. data/ruby_whois_patches/whois.pandi.or.id.rb +118 -0
  126. data/ruby_whois_patches/whois.psi-usa.info.rb +63 -0
  127. data/ruby_whois_patches/whois.registro.br.rb +109 -0
  128. data/ruby_whois_patches/whois.registrygate.com.rb +55 -0
  129. data/ruby_whois_patches/whois.rrpproxy.net.rb +61 -0
  130. data/ruby_whois_patches/whois.sgnic.sg.rb +130 -0
  131. data/ruby_whois_patches/whois.srs.net.nz.rb +166 -0
  132. data/ruby_whois_patches/whois.tucows.com.rb +70 -0
  133. data/ruby_whois_patches/whois.twnic.net.tw.rb +133 -0
  134. data/settings/discovery_ports +24 -0
  135. data/settings/google_keywords.txt +9 -0
  136. data/settings/google_locator.txt +23 -0
  137. data/test/domain_tracker_test.rb +31 -0
  138. data/test/utils_test.rb +168 -0
  139. data/version.txt +13 -0
  140. data/wmap.gemspec +49 -0
  141. metadata +202 -0
@@ -0,0 +1,112 @@
1
+ #--
2
+ # Ruby Whois
3
+ #
4
+ # An intelligent pure Ruby WHOIS client and parser.
5
+ #
6
+ # Copyright (c) 2009-2012 Simone Carletti <weppos@weppos.net>
7
+ #++
8
+
9
+
10
+ require 'whois/record/parser/base'
11
+
12
+
13
+ module Whois
14
+ class Record
15
+ class Parser
16
+
17
+ #
18
+ # = whois.ai parser
19
+ #
20
+ # Parser for the whois.ai server.
21
+ #
22
+ # NOTE: This parser is just a stub and provides only a few basic methods
23
+ # to check for domain availability and get domain status.
24
+ # Please consider to contribute implementing missing methods.
25
+ # See WhoisNicIt parser for an explanation of all available methods
26
+ # and examples.
27
+ #
28
+ class WhoisAi < Base
29
+
30
+ property_supported :status do
31
+ if available?
32
+ :available
33
+ else
34
+ :registered
35
+ end
36
+ end
37
+
38
+ property_supported :available? do
39
+ !!(content_for_scanner =~ /Domain (.+?) not registred/)
40
+ end
41
+
42
+ property_supported :registered? do
43
+ !available?
44
+ end
45
+
46
+ property_not_supported :created_on
47
+
48
+ property_not_supported :updated_on
49
+
50
+ property_not_supported :expires_on
51
+
52
+ property_supported :nameservers do
53
+ if content_for_scanner =~ /Nameservers\n((.+\n)+)\n/
54
+ $1.split("\n").select { |e| e =~ /Server Hostname/ }.map do |line|
55
+ Record::Nameserver.new(:name => line.split(":").last.strip)
56
+ end
57
+ end
58
+ end
59
+
60
+ # The following methods are implemented by Yang Li on 02/04/2013
61
+ # ----------------------------------------------------------------------------
62
+ property_supported :domain do
63
+ return $2.strip if content_for_scanner =~ /Complete Domain Name(.*):(.*)\n/i
64
+ end
65
+
66
+ property_not_supported :domain_id
67
+
68
+ property_not_supported :registrar
69
+
70
+ property_supported :admin_contacts do
71
+ build_contact("Administrative Contact", Whois::Record::Contact::TYPE_ADMIN)
72
+ end
73
+
74
+ property_supported :registrant_contacts do
75
+ build_contact("Organization Using Domain Name", Whois::Record::Contact::TYPE_REGISTRANT)
76
+ end
77
+
78
+ property_supported :technical_contacts do
79
+ build_contact("Technical Contact", Whois::Record::Contact::TYPE_TECHNICAL)
80
+ end
81
+
82
+ property_supported :billing_contacts do
83
+ build_contact("Billing Contact", Whois::Record::Contact::TYPE_BILLING)
84
+ end
85
+
86
+ private
87
+
88
+ def build_contact(element, type)
89
+ reg=Record::Contact.new(:type => type)
90
+ if content_for_scanner =~ /#{element}\n((^\s.+\n)+)/i
91
+ $1.scan(/^(.+):(.+)\n/).map do |entry|
92
+ reg["id"]=entry[1].strip if entry[0] =~ /NIC Handle/i
93
+ reg["name"]=entry[1].strip if entry[0] =~ /Name \(Last\, First\)/i
94
+ reg["organization"]=entry[1].strip if entry[0]=~ /Organization Name/i
95
+ reg["address"]=entry[1].strip if entry[0]=~ /Street Address/i
96
+ reg["city"]= entry[1].strip if entry[0]=~ /City/i
97
+ reg["zip"]=entry[1].strip if entry[0]=~ /Postal Code/i
98
+ reg["state"]=entry[1].strip if entry[0]=~ /State/i
99
+ reg["country"]=entry[1].strip if entry[0]=~ /Country/i
100
+ reg["phone"]=entry[1].strip if entry[0]=~ /Phone\sNumber/i
101
+ reg["fax"]=entry[1].strip if entry[0]=~ /Fax\sNumber/i
102
+ reg["email"]=entry[1].strip if entry[0]=~ /E-Mailbox/i
103
+ end
104
+ end
105
+ return reg
106
+ end
107
+ # ----------------------------------------------------------------------------
108
+
109
+ end
110
+ end
111
+ end
112
+ end
@@ -0,0 +1,121 @@
1
+ #--
2
+ # Ruby Whois
3
+ #
4
+ # An intelligent pure Ruby WHOIS client and parser.
5
+ #
6
+ # Copyright (c) 2009-2012 Simone Carletti <weppos@weppos.net>
7
+ #++
8
+
9
+
10
+ require 'whois/record/parser/base'
11
+
12
+
13
+ module Whois
14
+ class Record
15
+ class Parser
16
+
17
+ #
18
+ # = whois.arnes.si parser
19
+ #
20
+ # Parser for the whois.arnes.si server.
21
+ #
22
+ # NOTE: This parser is just a stub and provides only a few basic methods
23
+ # to check for domain availability and get domain status.
24
+ # Please consider to contribute implementing missing methods.
25
+ # See WhoisNicIt parser for an explanation of all available methods
26
+ # and examples.
27
+ #
28
+ class WhoisArnesSi < Base
29
+
30
+ property_supported :status do
31
+ if content_for_scanner =~ /status:\s+(.+)\n/
32
+ case $1.downcase
33
+ when "ok" then :registered
34
+ else
35
+ Whois.bug!(ParserError, "Unknown status `#{$1}'.")
36
+ end
37
+ else
38
+ :available
39
+ end
40
+ end
41
+
42
+ property_supported :available? do
43
+ !!(content_for_scanner =~ /% No entries found/)
44
+ end
45
+
46
+ property_supported :registered? do
47
+ !available?
48
+ end
49
+
50
+
51
+ property_supported :created_on do
52
+ if content_for_scanner =~ /created:\s+(.*)\n/
53
+ Time.parse($1)
54
+ end
55
+ end
56
+
57
+ property_not_supported :updated_on
58
+
59
+ property_supported :expires_on do
60
+ if content_for_scanner =~ /expire:\s+(.*)\n/
61
+ Time.parse($1)
62
+ end
63
+ end
64
+
65
+ property_supported :nameservers do
66
+ content_for_scanner.scan(/nameserver:\s+(.+)\n/).flatten.map do |name|
67
+ Record::Nameserver.new(:name => name)
68
+ end
69
+ end
70
+
71
+ # The following methods are implemented by Yang Li on 01/24/2013
72
+ # ----------------------------------------------------------------------------
73
+ property_supported :domain do
74
+ return $1 if content_for_scanner =~ /domain:\s+(.*)\n/i
75
+ end
76
+
77
+ property_not_supported :domain_id
78
+
79
+ property_supported :registrar do
80
+ reg=Record::Registrar.new
81
+ content_for_scanner.scan(/^(registrar.*):\s+(.+)\n/).map do |entry|
82
+ reg["name"] = entry[1] if entry[0] == "registrar"
83
+ reg["organization"] = entry[1] if entry[0] == "registrar"
84
+ reg["url"] = entry[1] if entry[0] =~ /url/i
85
+ end
86
+ return reg
87
+ end
88
+
89
+ property_not_supported :admin_contacts
90
+
91
+ property_supported :registrant_contacts do
92
+ build_contact("Domain holder", Whois::Record::Contact::TYPE_REGISTRANT)
93
+ end
94
+
95
+ property_supported :technical_contacts do
96
+ build_contact("Tech", Whois::Record::Contact::TYPE_TECHNICAL)
97
+ end
98
+
99
+ property_not_supported :billing_contacts
100
+
101
+ private
102
+
103
+ def build_contact(element, type)
104
+ reg=Record::Contact.new(:type => type)
105
+ if content_for_scanner =~ /^#{element}:\n((.+\n)+)\n/i
106
+ line_num=1
107
+ $1.split(%r{\n}).each do |line|
108
+ line=line.strip unless line.nil?
109
+ reg["name"]=line if line_num==1
110
+ reg["organization"]=line if line_num==1
111
+ line_num=line_num+1
112
+ end
113
+ end
114
+ return reg
115
+ end
116
+ # ----------------------------------------------------------------------------
117
+
118
+ end
119
+ end
120
+ end
121
+ end
@@ -0,0 +1,91 @@
1
+ #--
2
+ # Ruby Whois
3
+ #
4
+ # An intelligent pure Ruby WHOIS client and parser.
5
+ #
6
+ # Copyright (c) 2009-2012 Simone Carletti <weppos@weppos.net>
7
+ #++
8
+
9
+ require 'whois/record/parser/base'
10
+
11
+ module Whois
12
+ class Record
13
+ class Parser
14
+
15
+ # Parser for the whois.ascio.com server, added by Yang Li 02/05/2013.
16
+ class WhoisAscioCom < Base
17
+
18
+ property_supported :created_on do
19
+ if content_for_scanner =~ /^Record created:\s+(.+)\n/
20
+ Time.parse($1)
21
+ end
22
+ end
23
+
24
+ property_supported :updated_on do
25
+ if content_for_scanner =~ /^Record last updated:\s+(.+)\n/
26
+ Time.parse($1)
27
+ end
28
+ end
29
+
30
+ property_supported :expires_on do
31
+ if content_for_scanner =~ /Record expires:\s+(.+)\n/
32
+ Time.parse($1)
33
+ end
34
+ end
35
+
36
+ property_supported :nameservers do
37
+ if content_for_scanner =~ /^Domain servers in listed order:\n((.+\n)+)/
38
+ $1.split(%r{\n}).map do |line|
39
+ Record::Nameserver.new(:name => line.strip.split(%r{\s+})[0])
40
+ end
41
+ end
42
+ end
43
+
44
+ property_supported :domain do
45
+ return $1 if content_for_scanner =~ /Domain name:\s+(.+)\n/i
46
+ end
47
+
48
+ property_not_supported :domain_id
49
+
50
+ property_supported :admin_contacts do
51
+ build_contact("Administrative contact", Whois::Record::Contact::TYPE_ADMIN)
52
+ end
53
+
54
+ property_supported :registrant_contacts do
55
+ build_contact("Registrant", Whois::Record::Contact::TYPE_REGISTRANT)
56
+ end
57
+
58
+ property_supported :technical_contacts do
59
+ build_contact("Technical contact", Whois::Record::Contact::TYPE_TECHNICAL)
60
+ end
61
+
62
+ property_not_supported :billing_contacts
63
+
64
+ private
65
+
66
+ def build_contact(element, type)
67
+ reg=Record::Contact.new(:type => type)
68
+ if content_for_scanner =~ /^#{element}:\n((.+\n)+)\n/i
69
+ line_num=1
70
+ $1.split(%r{\n}).each do |line|
71
+ line=line.strip unless line.nil?
72
+ reg["id"]=line.split('(')[1].split(')')[0] if line_num==1
73
+ reg["name"]=line.split('(')[0] if line_num==1
74
+ reg["organization"]=line.strip if line_num==2
75
+ reg["address"]=line if line_num==3
76
+ reg["city"]=line if line_num==5
77
+ reg["country_code"]=line if line_num==6
78
+ reg["email"]=line if line=~ /.+\@.+\.\w/
79
+ reg["phone"]=line.split('Fax:')[0] if line=~ /Fax/
80
+ reg["fax"]=line.split('Fax:')[1] if line=~ /Fax/
81
+ line_num=line_num+1
82
+ end
83
+ end
84
+ return reg
85
+ end
86
+ # ----------------------------------------------------------------------------
87
+
88
+ end
89
+ end
90
+ end
91
+ end
@@ -0,0 +1,123 @@
1
+ #--
2
+ # Ruby Whois
3
+ #
4
+ # An intelligent pure Ruby WHOIS client and parser.
5
+ #
6
+ # Copyright (c) 2009-2012 Simone Carletti <weppos@weppos.net>
7
+ #++
8
+
9
+
10
+ require 'whois/record/parser/base'
11
+ require 'whois/record/scanners/whois.cnnic.cn.rb'
12
+
13
+
14
+ module Whois
15
+ class Record
16
+ class Parser
17
+
18
+ # Parser for the whois.cnnic.cn server.
19
+ class WhoisCnnicCn < Base
20
+ include Scanners::Nodable
21
+
22
+
23
+ property_not_supported :disclaimer
24
+
25
+
26
+ property_supported :domain do
27
+ node("Domain Name", &:downcase)
28
+ end
29
+
30
+ property_supported :domain_id do
31
+ node("ROID")
32
+ end
33
+
34
+
35
+ property_not_supported :referral_whois
36
+
37
+ property_not_supported :referral_url
38
+
39
+
40
+ property_supported :status do
41
+ Array.wrap node("Domain Status")
42
+ end
43
+
44
+ property_supported :available? do
45
+ !!node("status:available")
46
+ end
47
+
48
+ property_supported :registered? do
49
+ reserved? || !available?
50
+ end
51
+
52
+ # NEWPROPERTY
53
+ def reserved?
54
+ !!node("status:reserved")
55
+ end
56
+
57
+
58
+ property_supported :created_on do
59
+ node("Registration Date") { |value| Time.parse(value) }
60
+ end
61
+
62
+ property_not_supported :updated_on
63
+
64
+ property_supported :expires_on do
65
+ node("Expiration Date") { |value| Time.parse(value) }
66
+ end
67
+
68
+
69
+ property_supported :registrar do
70
+ node("Sponsoring Registrar") do |value|
71
+ Record::Registrar.new(
72
+ :id => value,
73
+ :name => value
74
+ )
75
+ end
76
+ end
77
+
78
+ property_supported :registrant_contacts do
79
+ build_contact("Registrant", Whois::Record::Contact::TYPE_REGISTRANT)
80
+ end
81
+
82
+ property_not_supported :admin_contacts
83
+
84
+ property_not_supported :technical_contacts
85
+
86
+
87
+ property_supported :nameservers do
88
+ Array.wrap(node("Name Server")).map do |name|
89
+ Nameserver.new(:name => name.downcase)
90
+ end
91
+ end
92
+
93
+
94
+ # Initializes a new {Scanners::WhoisCnnicCn} instance
95
+ # passing the {#content_for_scanner}
96
+ # and calls +parse+ on it.
97
+ #
98
+ # @return [Hash]
99
+ def parse
100
+ Scanners::WhoisCnnicCn.new(content_for_scanner).parse
101
+ end
102
+
103
+
104
+ private
105
+ # Modified by Yang Li 01/24/2013
106
+ def build_contact(element, type)
107
+ n = node("#{element}")
108
+ o = node("#{element}")
109
+ e = node("#{element} Contact Email")
110
+ return if n.nil? && o.nil? && e.nil?
111
+
112
+ Record::Contact.new(
113
+ :type => type,
114
+ :name => n,
115
+ :organization => o,
116
+ :email => e
117
+ )
118
+ end
119
+
120
+ end
121
+ end
122
+ end
123
+ end
@@ -0,0 +1,67 @@
1
+ #--
2
+ # Ruby Whois
3
+ #
4
+ # An intelligent pure Ruby WHOIS client and parser.
5
+ #
6
+ # Copyright (c) 2009-2012 Simone Carletti <weppos@weppos.net>
7
+ #++
8
+
9
+ require 'whois/record/parser/base'
10
+
11
+ module Whois
12
+ class Record
13
+ class Parser
14
+
15
+ # Parser for the whois.corporatedomains.com server, added by Yang Li 02/05/2013.
16
+ class WhoisCorporatedomainsCom < Base
17
+
18
+ property_supported :registrar do
19
+ reg=Record::Registrar.new
20
+ content_for_scanner.scan(/Registrar(.+):\s+(.+)\n/).map do |entry|
21
+ reg["name"] = entry[1] if entry[0] =~ /Name/i
22
+ reg["organization"] = entry[1] if entry[0] =~ /Name/i
23
+ reg["url"] = entry[1] if entry[0] =~ /Homepage/i
24
+ end
25
+ return reg
26
+ end
27
+
28
+ property_supported :admin_contacts do
29
+ build_contact("Administrative contact", Whois::Record::Contact::TYPE_ADMIN)
30
+ end
31
+
32
+ property_supported :registrant_contacts do
33
+ build_contact("Registrant", Whois::Record::Contact::TYPE_REGISTRANT)
34
+ end
35
+
36
+ property_supported :technical_contacts do
37
+ build_contact("Technical contact", Whois::Record::Contact::TYPE_TECHNICAL)
38
+ end
39
+
40
+ property_not_supported :billing_contacts
41
+
42
+ # The following methods are implemented by Yang Li on 02/05/2013
43
+ private
44
+
45
+ def build_contact(element, type)
46
+ reg=Record::Contact.new(:type => type)
47
+ if content_for_scanner =~ /#{element}:\s*\n((.+\n)+)\n/i
48
+ line_num=1
49
+ $1.split(%r{\n}).each do |line|
50
+ reg["organization"]=line.strip if line_num==1
51
+ reg["name"]=line.strip if line_num==2
52
+ reg["address"]=line.strip if line_num==3
53
+ reg["city"]=line.strip if line_num==4
54
+ reg["country_code"]=line.strip if line_num==5
55
+ reg["email"]=line.split(':')[1].strip if line=~ /\w+\@\w+\.\w/
56
+ reg["phone"]=line.split(':')[1].strip if line=~ /Phone/
57
+ line_num=line_num+1
58
+ end
59
+ end
60
+ return reg
61
+ end
62
+ # ----------------------------------------------------------------------------
63
+
64
+ end
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,108 @@
1
+ #--
2
+ # Ruby Whois
3
+ #
4
+ # An intelligent pure Ruby WHOIS client and parser.
5
+ #
6
+ # Copyright (c) 2009-2012 Simone Carletti <weppos@weppos.net>
7
+ #++
8
+ require 'whois/record/parser/base'
9
+ require 'whois/record/scanners/verisign'
10
+
11
+
12
+ module Whois
13
+ class Record
14
+ class Parser
15
+
16
+ # Parser for the whois.crsnic.net server.
17
+ class WhoisCrsnicNet < Base
18
+ include Scanners::Ast
19
+
20
+ property_supported :disclaimer do
21
+ node("Disclaimer")
22
+ end
23
+
24
+ property_supported :domain do
25
+ node("Domain Name") { |raw| raw.downcase }
26
+ end
27
+
28
+ property_not_supported :domain_id
29
+
30
+ property_supported :referral_whois do
31
+ node("Whois Server")
32
+ end
33
+
34
+ property_supported :referral_url do
35
+ node("Referral URL") do |raw|
36
+ last_useful_item(raw)
37
+ end
38
+ end
39
+
40
+ property_supported :status do
41
+ node("Status")
42
+ end
43
+
44
+ property_supported :available? do
45
+ node("Registrar").nil?
46
+ end
47
+
48
+ property_supported :registered? do
49
+ !available?
50
+ end
51
+
52
+ property_supported :created_on do
53
+ node("Creation Date") { |raw| Time.parse(raw) }
54
+ end
55
+
56
+ property_supported :updated_on do
57
+ node("Updated Date") { |raw| Time.parse(raw) }
58
+ end
59
+
60
+ property_supported :expires_on do
61
+ node("Expiration Date") { |raw| Time.parse(raw) }
62
+ end
63
+
64
+ property_supported :registrar do
65
+ node("Registrar") do |raw|
66
+ Whois::Record::Registrar.new(
67
+ :name => last_useful_item(raw),
68
+ :organization => last_useful_item(raw),
69
+ :url => referral_url
70
+ )
71
+ end
72
+ end
73
+
74
+ property_supported :nameservers do
75
+ Array.wrap(node("Name Server")).reject { |value| value =~ / / }.map do |name|
76
+ Record::Nameserver.new(:name => name.downcase)
77
+ end
78
+ end
79
+
80
+ # Checks whether this response contains a message
81
+ # that can be reconducted to a "WHOIS Server Unavailable" status.
82
+ #
83
+ # @return [Boolean]
84
+ def response_unavailable?
85
+ !!node("response:unavailable")
86
+ end
87
+
88
+ # Initializes a new {Scanners::Verisign} instance
89
+ # passing the #{content_for_scanner}
90
+ # and calls +parse+ on it.
91
+ #
92
+ # @return [Hash]
93
+ def parse
94
+ Scanners::Verisign.new(content_for_scanner).parse
95
+ end
96
+
97
+ private
98
+
99
+ # In case of "SPAM Response", the response contains more than one item
100
+ # for the same value and the value becomes an Array.
101
+ def last_useful_item(values)
102
+ values.is_a?(Array) ? values.last : values
103
+ end
104
+
105
+ end
106
+ end
107
+ end
108
+ end