def traceIP(target):
try:
base = GeoIP('GeoLiteCity.dat')
data = base.record_by_addr(target)
dnsName = socket.gethostbyaddr(target)[0]
formatedData = '''IP: {}
City: {}
State/Province: {}
Country: {}
Continent: {}
Zip/Postal code: {}
Timezone: {}
Latitude: {}
Longitude: {}
DNS name: {}'''.format(target, data['city'], data['region_code'], data['country_name'], data['continent'], data['postal_code'], data['time_zone'], str(data['latitude']), str(data['longitude']), dnsName)
print formatedData
# compares target to database and print results to console
askSave = raw_input('Save data? Y/n: ').lower()
if askSave == 'y':
ipFileName = raw_input('Filename: ')
with open(ipFileName, 'w') as fileName:
fileName.write(formatedData)
print 'Output saved as {}'.format(ipFileName)
else:
pass
# asks user if they want to save the output
pause()
main()
except socket.herror:
pass
评论列表
文章目录