HOW TO WORK WITH IP ADDRESSES OFFLINE (PYTHON)



Hello Freaks Anonymous here welcome to Anonhacks. Today I'm going to explain how to work with IP address during offline. So let's get into the topic. 

There is a module and lost file called GeoIP.dat. Usually Linux operating systems have this file pre-installed. In my case, Kali hasn't it pre-installed so i will tell you how to get this file and how to work with IPs offline.


1. Download The IP Database


Depending what you want to do you can download the database from here : https://www.miyuru.lk/geoiplegacy


I choose ipv4 db-ip-city.


sudo mkdir /usr/share/GeoIP/


sudo wget -N https://dl.miyuru.lk/geoip/dbip/city/dbip4.dat.gz -O /usr/share/GeoIP/GeoLite.dat.gz


sudo gunzip /usr/share/GeoIP/GeoLite.dat.gz


2. Install Python Module 


pip3 install pygeoip


3. Working with geoip


python3 # To start python3


import pygeoip

g = pygeoip.GeoIP("/usr/share/GeoIP/GeoLite.dat")

g.country_name_by_addr("205.185.223.142")


You can use different method to get information about an IP address.


Region Lookup 


g.region_by_addr("205.185.223.142")

g.region_by_name("google.com")


City Lookup 


g.record_by_addr("205.185.223.142")


Organization Lookup


g.org_by_name("dell.com")


Timezone Lookup


g.time_zone_by_addr("205.185.223.142")

g.time_zone_by_name("dell.com")


ISP Lookup


g.isp_by_name("dell.com")


ASN Lookup 


g.asn_by_name("dell.com")


Please note that if you get an error like : pygeoip.GeoIPError, then go for another geoip.dat from their website.


That's it, if you have any enquiries ping me on Telegram or Instagram. 

Admin

No comments: