Created
July 19, 2014 09:10
-
-
Save danielmiessler/16d016dfb01410f195de to your computer and use it in GitHub Desktop.
Get GeoLocation from a list of IP Addresses
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
cat /var/log/apache2/ | awk '{print $1}' > ips.txt | |
uniq ips.txt > uniques.txt | |
IPS='cat uniques.txt' | |
echo "" > ./ipinfo.csv | |
for i in $IPS | |
do | |
echo "$i,'host $i | awk '{print $5}'','geoiplookup $i | cut -d "," -f2 | sed -e 's/^[ \t]*//'','geoiplookup -f /usr/share/GeoIP/GeoLiteCity.dat $i | cut -d "," -f3 | sed -e 's/^[ \t]*//'','geoiplookup -f /usr/share/GeoIP/GeoLiteCity.dat $i | cut -d "," -f4 | sed -e 's/^[ \t]*//''" >> ipinfo.csv | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment