elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Como proteger una cartera - billetera de Bitcoin


+  Foro de elhacker.net
|-+  Programación
| |-+  Scripting
| | |-+  [Ruby] LocateIP 0.3
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: [Ruby] LocateIP 0.3  (Leído 1,700 veces)
BigBear


Desconectado Desconectado

Mensajes: 545



Ver Perfil
[Ruby] LocateIP 0.3
« en: 27 Junio 2015, 01:18 am »

Un simple script en Ruby para localizar una IP y sus DNS.

Version consola :

Código
  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 ?
  124.  

Version Tk :

Código
  1. #!usr/bin/ruby
  2. #LocateIP 0.3
  3. #(C) Doddy Hackman 2015
  4.  
  5. require "tk"
  6. require "open-uri"
  7. require "net/http"
  8. require "resolv"
  9.  
  10. # Functions
  11.  
  12. def get_ip(hostname)
  13. begin
  14. return Resolv.getaddress(hostname)
  15. rescue
  16. return "Error"
  17. end
  18. end
  19.  
  20. def toma(web)
  21. begin
  22. return open(web, "User-Agent" => "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:25.0) Gecko/20100101 Firefox/25.0").read
  23. rescue
  24. return "Error"
  25. end
  26. end
  27.  
  28. def response_code(web)
  29. begin
  30. return Net::HTTP.get_response(URI(web)) .code
  31. rescue
  32. return "404"
  33. end
  34. end
  35.  
  36. def tomar(web,arg)
  37. begin
  38. headers = {"User-Agent" => "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:25.0) Gecko/20100101 Firefox/25.0"}
  39. uri = URI(web)
  40. http = Net::HTTP.new(uri.host, uri.port)
  41. return http.post(uri.path,arg, headers).body
  42. rescue
  43. return "Error"
  44. end
  45. end
  46.  
  47. #
  48.  
  49. window = TkRoot.new { title "LocateIP 0.3 (C) Doddy Hackman 2015" ; background "black" }
  50. window['geometry'] = '300x300-20+10'
  51.  
  52. TkLabel.new(window) do
  53. background "black"
  54. foreground "yellow"
  55. text "    Target : "
  56. place('relx'=>"0.1",'rely'=>"0.1")
  57. end
  58.  
  59. target = TkEntry.new(window){
  60. background "black"
  61. foreground "yellow"
  62. width 25
  63. place('relx'=>0.3,'rely'=>0.1)
  64. }
  65.  
  66. TkLabel.new(window) do
  67. background "black"
  68. foreground "yellow"
  69. text "Console"
  70. place('relx'=>0.4,'rely'=>0.2)
  71. end
  72.  
  73. console =TkText.new(window) do
  74. background "black"
  75. foreground "yellow"
  76. width 30
  77. height 10
  78. place('relx'=>0.1,'rely'=>0.3)
  79. end
  80.  
  81. TkButton.new(window) do
  82. text "Search"
  83.        background "black"
  84. foreground "yellow"
  85. width 17
  86. activebackground "yellow"
  87. highlightbackground  "yellow"
  88. command proc{
  89.  
  90. target = target.value.to_s
  91.  
  92. console.insert("end",  "[+] Getting IP ...\n")
  93.  
  94. ip = get_ip(target)
  95.  
  96. web = "http://www.melissadata.com/lookups/iplocation.asp"
  97.  
  98. console.insert("end", "\n[+] Locating ...\n\n")
  99.  
  100. code = tomar(web,"ipaddress="+ip+"&btn=Submit")
  101.  
  102. if code=~/City<\/td><td align=(.*)><b>(.*)<\/b><\/td>/
  103. console.insert("end", "[+] City : "+$2+"\n")
  104. else
  105. console.insert("end", "[+] City : Not Found\n")
  106. end
  107.  
  108. if code=~/Country<\/td><td align=(.*)><b>(.*)<\/b><\/td>/
  109. console.insert("end","[+] Country : "+$2+"\n")
  110. else
  111. console.insert("end", "[+] Country : Not Found\n")
  112. end
  113.  
  114. if code=~/State or Region<\/td><td align=(.*)><b>(.*)<\/b><\/td>/
  115. console.insert("end", "[+] State or Region : "+$2+"\n")
  116. else
  117. console.insert("end","[+] State of Region : Not Found\n")
  118. end
  119.  
  120. console.insert("end","\n[+] Getting DNS ...\n\n")
  121.  
  122. control = "0"
  123.  
  124. code = toma("http://www.ip-adress.com/reverse_ip/"+ip)
  125.  
  126. dnss = code.scan(/whois\/(.*?)\">Whois/)
  127.  
  128. dnss.flatten.each do |dns|
  129. begin
  130. if dns != ""
  131. control = "1"
  132. console.insert("end", "[+] DNS Found : "+dns)
  133. end
  134. end
  135. end
  136.  
  137. if control=="0"
  138. console.insert("end","\n[-] DNS Not Found\n")
  139. end
  140.  
  141. console.insert("end","\n\n[+] Finished")
  142.  
  143. }
  144. place('relx'=>0.3,'rely'=>0.9)
  145. end
  146.  
  147. Tk.mainloop
  148.  
  149. #The End ?
  150.  

Una imagen :



Eso es todo.


En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
[Introducing Ruby] Lo que debes saber sobre Ruby
Scripting
RyogiShiki 0 9,894 Último mensaje 4 Marzo 2011, 20:45 pm
por RyogiShiki
[Delphi] LocateIP 0.1
Programación General
BigBear 5 3,077 Último mensaje 12 Mayo 2013, 21:35 pm
por 0xFer
[Java] LocateIP 1.0
Java
BigBear 3 1,777 Último mensaje 9 Marzo 2014, 21:28 pm
por BigBear
[Delphi] LocateIP 0.5
Programación General
BigBear 0 1,786 Último mensaje 4 Abril 2014, 20:16 pm
por BigBear
[C#] LocateIP 0.2
.NET (C#, VB.NET, ASP)
BigBear 3 2,631 Último mensaje 7 Julio 2014, 20:23 pm
por BigBear
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines