Friday, February 8, 2013

Geo-Location a domain


Using MaxMind and Pygeoip

wget -N -q http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz

gzip -d GeoLiteCity.dat.gz
ls -alh GeoLiteCity.dat
wget http://pygeoip.googlecode.com/files/pygeoip-0.1.3.zip
unzip pygeoip-0.1.3.zip
cd pygeoip-0.1.3
wget http://svn.python.org/projects/sandbox/trunk/setuptools/ez_setup.py
wget http://pypi.python.org/packages/2.5/s/setuptools/setuptools-0.6c11-py2.5.egg
python setup.py build
sudo python setup.py install
cd ..

MacBook-Pro:security w$ python
Python 2.7.1 (r271:86832, Jul 31 2011, 19:30:53)
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pygeoip
>>> gip = pygeoip.GeoIP('GeoLiteCity.dat')
>>> rec = gip.record_by_name('yourdomain.com')
>>> for key,val in rec.items():
...   print "%s: %s" % (key,val)
...

Olivet University

No comments:

Post a Comment