#!/usr/bin/env ruby
# www.railsmine.net
require 'open-uri'
if ARGV.size < 1
puts '[-] Usage: ruby whois.rb [domain_name]'
exit 1
end
puts '-----------------------------------------------'
puts '[+] Whois tool - whois.rb'
puts "-----------------------------------------------\n\n"
begin
domain_name = ARGV[0]
open("http://reports.internic.net/cgi/whois?whois_nic=#{domain_name}&type=domain") {|page|
page.each_line {|line|
if (line =~ /Domain Name:/)
puts "[+]#{line}"
end
if (line =~ /Registrar:/)
puts "[+]#{line}"
end
if (line =~ /Name Server:/)
puts "[+]#{line}"
end
if (line =~ /Whois Server:/)
puts "[+]#{line}"
end
if (line =~ /Referral URL:/)
puts "[+]#{line}"
end
if (line =~ /Status:/)
puts "[+]#{line}"
end
if (line =~ /Updated Date:/)
puts "[+]#{line}"
end
if (line =~ /Creation Date:/)
puts "[+]#{line}"
end
if (line =~ /Expiration Date:/)
puts "[+]#{line}"
end
}
}
rescue OpenURI::HTTPError => error_msg
puts "[-] Oops! Bad status code: #{error_msg}. Please try again."
rescue Timeout::Error
puts '[-] 0ops! Timeout, Check your internet connection.'
end
Sunday, February 19, 2012
Ruby Whois Script - whois.rb
Description: My old script. Client for the whois directory service.
Subscribe to:
Post Comments (Atom)
You are well aware of such gems as https://github.com/weppos/whois, aren't you? Have a look on their usefull gem public_suffix_service, too?
ReplyDeleteyes I know Whois gem. I just want to re-share my old script.
DeleteWow that needs refactoring! Copy/Paste horror in Ruby is like eating raw chicken because you're too lazy too grill it.
ReplyDeleteI have made a php whois script http://mkj.co.in/?p=52
ReplyDelete