from struct import unpack
from socket import AF_INET, inet_pton
def ip_private(_ip):
ip = unpack('!I',inet_pton(AF_INET,_ip))[0]
l = (
[2130706432, 4278190080],
[3232235520, 4294901760],
[2886729728, 4293918720],
[167772160, 4278190080]
)
for addr in l:
if (ip & addr[1]) == addr[0]:
return True
return False
Sencillo, ¿verdad?def main(_ip1,_ip2):
''' Main function, launch the main activities '''
''' You can download GeoIP databases from here: https://dev.maxmind.com/geoip/legacy/geolite '''
_ip3 = _ip1
_ip3_prev = ""
while (_ip3_prev <> _ip2):
if not ip_private(_ip3):
print _ip3
try:
_id = hosts(_ip3)
if _id:
geo('GeoIP/GeoLiteCity.dat', _ip3, _id)
ports(_ip3, _id)
except:
print 'Error on: %s' % _ip3
_ip3_prev = _ip3
_ip3 = ip_add(_ip3)
Para probarlo, podremos realizar un ejercicio tan sencillo como escanear los siguientes rangos de IP:
- ip1 = '192.167.255.255'
- ip2 = '192.168.2.255'
Saludos!
0 comentarios:
Publicar un comentario