/
profile-godaddy
executable file
·64 lines (50 loc) · 1.62 KB
/
profile-godaddy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/env ruby
# encoding: UTF-8
$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/lib')
require 'pp'
require 'domain-profiler'
require 'rubygems'
require 'gchart'
require 'erb'
def fullname(name)
Name.new.full(name)
end
class Array
def lookup(host)
self.map{|name| Name.new.simplify(name,host) }.uniq
end
end
filename = ARGV[0]
file = File.new(filename)
hosts = {}
list_name = ARGV[1] ? ARGV[1] : 'REPLACE ME'
max_domain_length = 0
file.map {|host|
if match_data = host.match(/^#List:(.*)/)
list_name = match_data[1]
end
next if host.match(/^#/)
host.chomp!
profile = DomainProfiler.new(host)
if(host.length > max_domain_length)
max_domain_length = host.length
end
registrar = profile.whois.registrar.lookup(host)
dns_host = profile.dns.ns.map{|record| Name.new.shorten(record.answer) }.lookup(host)
ssl_issuer = profile.ssl.ca.lookup(host)
out = {}
out[:registrar] = (registrar[0] == :godaddy) ? 4 : 0
out[:dns_host] = (dns_host[0] == :godaddy) ? 2 : 0
out[:ssl_issuer] = (ssl_issuer[0] == :godaddy) ? 1 : 0
out[:sort_key] = out[:registrar] + out[:dns_host] + out[:ssl_issuer]
hosts[host] = out
}
# Turn the list of host data into a hash of type data
hosts.sort_by{ |hostname,data| data[:sort_key].to_s + hostname }.each do |hostname,data|
next unless data[:sort_key] > 0
puts "%s %s %s %s" % [hostname.ljust(max_domain_length,' '),
(data[:registrar] > 0) ? 'REGISTRAR' : ' ',
(data[:dns_host] > 0) ? 'DNS' : ' ',
(data[:ssl_issuer] > 0) ? 'SSL' : ' '
]
end