Ruby Whois Script - whois.rb
- Categories:
- ruby
Description: My old script. Client for the whois directory service.
#!/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") do |page|
    page.each_line do |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
    end
  end
rescue OpenURI::HTTPError => error_msg
  puts "[-] Oops! Bad status code: #{error_msg}. Please try again."
rescue Timeout::Error
  puts '[-] 0ops! Timeout, please check your internet connection.'
end