How To Find Exact Location Of Any IP Address!
Step 1: Fire Up Kali & Open a Terminal
The first step, of course, is to fire up our our trusty Kali system, or in this case, any Linux distribution. Then, open a terminal.Step 2: Download the Database
Now we need to download the database from MaxMind, and we can get it by typing the following.kali > wget -N -qhttp://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
Then we need to unzip it.
kali> gzip -d GeoLiteCity.dat.gz
kali > ls -alh GeoLiteCity.dat
Step 3: Download & Install Pygeoip
Next, we need to install the Python script to read the database, pygeoip. We can download it by typing the following.kali > wget http://pygeoip.googlecode.com/files/pygeoip-0.1.3.zip
kali > unzip pygeoip-0.1.3.zip
kali > cd /pygeoip-0.1.3
kali > wgethttp://svn.python.org/projects/sandbox/trunk/setuptools/ez_setup.py
kali > wget http://pypi.python.org/packages/2.5/s/setuptools-0.6c11-py2.5.egg
kali > mv setuptools-0.6c11-py2.5.egg setuptools-0.7a1-py2.5.egg
kali > python setup.py build
kali > python setup.py install
kali > mv GeoLiteCity.dat /pygeoip-0.1.3/GeoLiteCity.dat
Step 4: Query the Database
Now that we have the database in place and the pygeoip script downloaded and installed, we can begin to query that database with pygeoip.First, we need to start a Python shell.
kali > python
Then, you will be greeted will the triple >>> indicating you are now in an interactive python shell. Let’s import the module and instantiate the class.
>>>import pygeoip
>>>gip = pygeopip.GeoIP(‘GeoLiteCity.dat’)
Next, we are ready to begin our query. Let’s see where Google is located.
>>>rec = gip.record_by_addr(‘64.233.161.99′)
>>>for key.val in rec.items():
… print “%s: %s” %(key,val)
…
Please note that it is critical to indent the “print”. If not, you will throw an error.
This little tool is great for locating any IP address in the world, albeit, it is a bit clunky. Maybe someone here in the Null Byte community with good Python skills would like to write an interactive script with a nice user interface where the user can simply enter the IP and get the record information?
