Advertisement
Doddy

LocateIP 0.3

Jan 1st, 2015
660
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 2.17 KB | None | 0 0
  1. #!usr/bin/ruby
  2. #LocateIP 0.3
  3. #(C) Doddy Hackman 2015
  4.  
  5. require "open-uri"
  6. require "net/http"  
  7. require "resolv"
  8.  
  9. # Functions
  10.  
  11. def get_ip(hostname)
  12.     begin
  13.         return Resolv.getaddress(hostname)
  14.     rescue
  15.         return "Error"
  16.     end
  17. end
  18.  
  19. def toma(web)
  20.     begin
  21.         return open(web, "User-Agent" => "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:25.0) Gecko/20100101 Firefox/25.0").read
  22.     rescue
  23.         return "Error"
  24.     end
  25. end
  26.  
  27. def response_code(web)
  28.     begin
  29.         return Net::HTTP.get_response(URI(web)) .code
  30.     rescue
  31.         return "404"
  32.     end
  33. end
  34.  
  35. def tomar(web,arg)
  36.     begin
  37.         headers = {"User-Agent" => "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:25.0) Gecko/20100101 Firefox/25.0"}
  38.         uri = URI(web)
  39.         http = Net::HTTP.new(uri.host, uri.port)
  40.         return http.post(uri.path,arg, headers).body
  41.     rescue
  42.         return "Error"
  43.     end
  44. end
  45.  
  46. def uso
  47.     print "\n[+] Sintax : ruby locateip.rb <target>\n"
  48. end
  49.  
  50. def  head
  51.     print "\n\n-- == LocateIP 0.3 == --\n\n"
  52. end
  53.  
  54. def copyright
  55.     print "\n\n-- == (C) Doddy Hackman 2015 == --\n\n"
  56. end
  57.  
  58. def locateip(target)
  59.  
  60.     print "\n[+] Getting IP ...\n"
  61.  
  62.     ip = get_ip(target)
  63.  
  64.     print "\n[+] IP : "+ip+"\n"
  65.  
  66.     web = "http://www.melissadata.com/lookups/iplocation.asp"
  67.     print "\n[+] Locating ...\n\n"
  68.  
  69.     code = tomar(web,"ipaddress="+ip+"&btn=Submit")
  70.  
  71.     if code=~/City<\/td><td align=(.*)><b>(.*)<\/b><\/td>/
  72.         print "[+] City : "+$2+"\n"
  73.     else
  74.         print "[+] City : Not Found\n"
  75.     end
  76.  
  77.     if code=~/Country<\/td><td align=(.*)><b>(.*)<\/b><\/td>/
  78.         print "[+] Country : "+$2+"\n"
  79.     else
  80.         print "[+] Country : Not Found\n"
  81.     end
  82.  
  83.     if code=~/State or Region<\/td><td align=(.*)><b>(.*)<\/b><\/td>/
  84.         print "[+] State or Region : "+$2+"\n";
  85.     else
  86.         print "[+] State of Region : Not Found\n"
  87.     end
  88.  
  89.     print "\n[+] Getting DNS ...\n\n"
  90.  
  91.     control = "0"
  92.  
  93.     code = toma("http://www.ip-adress.com/reverse_ip/"+ip)
  94.  
  95.     dnss = code.scan(/whois\/(.*?)\">Whois/)
  96.  
  97.     dnss.flatten.each do |dns|
  98.         begin
  99.             if dns != ""
  100.                 control = "1"
  101.                 print "[+] DNS Found : "+dns
  102.             end
  103.         end
  104.     end
  105.  
  106.     if control=="0"
  107.         print "\n[-] DNS Not Found\n"
  108.     end
  109. end
  110.  
  111. target = ARGV[0]
  112.  
  113. head()
  114.  
  115. if !target
  116.     uso()
  117. else
  118.     locateip(target)
  119. end
  120.  
  121. copyright()
  122.  
  123. #The End ?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement