Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #This is the Python script to query the MaxMind database!
- import pygeoip
- import socket
- gip = pygeoip.GeoIP('/root/pygeoip-0.1.3/GeoLiteCity.dat')
- print "Enter 1 to search for a URL or 2 to search for an IP address"
- userChoice = raw_input() #Get search type
- if userChoice == "1":
- print ""
- print "Enter URL"
- URL = raw_input() #Get requested URL from user
- ip = socket.gethostbyname(URL) #Retrieve URL's ip via socket
- print "Requested IP: "+ ip
- print ""
- rec = gip.record_by_addr(ip) #Query database
- for key,val in rec.items(): #Print results
- print "%s: %s"%(key,val)
- print ""
- elif userChoice == "2":
- print ""
- print "Enter IP"
- ip = raw_input() #Get requested IP from user
- rec = gip.record_by_addr(ip) #Query database
- for key,val in rec.items(): #Print results
- print "%s: %s"%(key,val)
- print ""
- else:
- print "That isn't an option" #In case of jackasses
- print ""
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement