This forum is in archive mode. You will not be able to post new content.

Author Topic: Analyzing a Geo-Location File  (Read 686 times)

0 Members and 1 Guest are viewing this topic.

learnerlly

  • Guest
Analyzing a Geo-Location File
« on: October 07, 2013, 03:50:22 AM »
So I am trying to make a Python script to analyze geo-location file based on somebody's IP address.

The format is like (i.e.):

"0.0.0.0","0.255.255.255","US","California","Los Angeles"
"1.0.0.0","1.0.0.255","AU","Queensland","Brisbane"
"1.0.1.0","1.0.3.255","CN","Fujian","Fuzhou"

I think that the first column is the IP address and the second one is the subnet mask.
How do I make a script in Python to analyze retrieve the location of the IP address quickly?

I did have an idea but it takes a bit longer than I thought:
I first take the first part of the IP address of the target as a parameter, locating all possibilities of the second part of the starter. Then I locate the second part of the target address and so forth. This method, for sure, is better than looking at the file line by line but I don't think it's the best way to do it.

The data file is attached so please help me. I may not explain it well so bear with me :P
« Last Edit: October 07, 2013, 03:59:32 AM by learnerlly »

Offline proxx

  • Avatarception
  • Global Moderator
  • Titan
  • *
  • Posts: 2803
  • Cookies: 256
  • ФФФ
    • View Profile
Re: Analyzing a Geo-Location File
« Reply #1 on: October 07, 2013, 06:18:41 AM »
Get geopip and the corrosponding geoip database.
Any major linux distro has it packaged.
See search engine for docs.

Manually I would say jam it in  a dictionary or list and iterate over it.
functions like find, count, in should do the trick.
« Last Edit: October 07, 2013, 06:19:52 AM by proxx »
Wtf where you thinking with that signature? - Phage.
This was another little experiment *evillaughter - Proxx.
Evilception... - Phage

 



Want to be here? Contact Ande, Factionwars or Kulverstukas on the forum or at IRC.