23 de Mayo de 2017, 05:33:00 pm
  • WPSdb - Base de Datos de Pines Online

Autor Tema: Geolocalizaciín de una IP  (Leído 3137 veces)

Desconectado D3M0N

  • Founder
  • Usuario
  • *
  • Mensajes: 3.075
  • Reputación: +244/-2
  • El Mate, La Netbook y Wi-Fi del Vecino!
  • awards Usuario con más de 2000 Posts! Miembro registrado desde 2010 Usuario Registrado
    • Arg-Wireless.com.ar
    • Awards
Geolocalizaciín de una IP
« en: 07 de Septiembre de 2011, 07:59:53 pm »
Un script que me encontrí por cierto foro programado en Python, para geolocalizar una IP. Solo copiamos el siguiente cídigo y lo guardamos como "geoedge.py"


Código: [Seleccionar]
#!/usr/bin/env python
#Geoedge v0.1
#Coded by laramies
#cmartorella@edge-security.com
#Remember that maxmind allows just 25 queries per day. Don't abuse ;)

import sys
import re
import httplib

def banner():
print "*************************************"
print "*Geoedge v0.2 *"
print "*Coded by Christian Martorella *"
print "*cmartorella@edge-security.com *"
print "*************************************"

def usage():
banner()
print "\n"
print "Usage:"
print " python geoedge.py host/ip\n"
return

if len(sys.argv) < host="sys.argv[1]" cmd="sys.argv[1]" body="ips=" h =" httplib.HTTP(" headers =" h.getreply()" response="h.file.read()" limit="re.compile(" res="re.compile(" style="">.*")
results=res.findall(response)
res=[]
for x in results:
x=x.replace("","")
x=x.replace("","")
res.append(x)

print "Information for "+host+ " by Maxmind"
print "===========================================\n"
print "IP/Host: "+host
country=re.sub("<.*nk>\">","",res[1])
country2=country.replace("","")
country=re.sub("<.*middle\" >","",country2)
print "Country: " +country +","+res[2]
print "City: " + res[4] +","+res[5]
print "Coordinates: "+ res[7] + "," + res[8]
print "Provider: "+ res[9] + "," + res[10]
print "Google Maps Link: " + "http://maps.google.com/maps?q="+res[7]+", "+res[8]
print "Mapquest Link: " + "http://www.mapquest.es/mq/maps/latlong.do?pageId=latlong&latLongType=decimal&txtLatitude="+res[7]+"&txtLongitude="+res[8]
print "\n"
except:
print "Connection error...\n"

print "Searching in Geoiptool....\n"
try:

h = httplib.HTTP("www.geoiptool.com")
h.putrequest('GET',"/es/?IP="+host )
h.putheader('Host', 'www.geoiptool.com')
h.putheader('User-agent', 'Internet Explorer 6.0 ')
h.endheaders()
returncode, returnmsg, headers = h.getreply()
response=h.file.read()

res=re.compile(".*")
results=res.findall(response)
res=[]

for x in results:
x=x.replace("","")
x=x.replace("","")
res.append(x)

print "Information by Geoiptool"
print "========================\n"
print "IP/Host: "+res[0]
country=re.sub("<.*nk\">","",res[1])
country=country.replace("","")
country=re.sub("<.*middle\" >","",country)
print "Country: " + country + ","+ res[2]
city=re.sub("<.*nk\">","",res[3])
city=city.replace("","")
print "City: " + city + ","+ res[4]
print "Coordinates: " + res[8] + ","+res[7]
print "\n"
except:
print "Connection error..\n"

La sintaxis de uso es la siguiente:

Código: [Seleccionar]
python geoedge.py google.com

En donde google.com es el host o la IP.
  • Antenas: Antena Komarov (Prototype), Antena Belgrain (MOD), Antenas 4, 5, 9dBi (omnis)
  • Sistemas Operativos: Microsoft Windows 7 Enterprice (x64), Ubuntu 14.10.1 LTS Desktop Edition 64-bit
  • Sistemas Operativos que utilizo para Auditar: Ubuntu 14.10.1 LTS Desktop Edition 64-bit
  • Dispositivos Inalambricos: Alfa AWUS036H 1W (USB); TP-Link TL-WN722N (USB); Ubiquiti Nanostation M2; Mikrotik RB951Ui-2HnD