Skip to content

Instantly share code, notes, and snippets.

View danielmiessler's full-sized avatar
💭
Coding

Daniel Miessler danielmiessler

💭
Coding
View GitHub Profile
### Keybase proof
I hereby claim:
* I am danielmiessler on github.
* I am danielmiessler (https://keybase.io/danielmiessler) on keybase.
* I have a public key whose fingerprint is C7D4 8DA8 35A4 5E83 3FC6 0ECA 79CB A58E D1BB 075F
To claim this, I am signing this object:
@danielmiessler
danielmiessler / GeoHarvest.sh
Created July 19, 2014 09:10
Get GeoLocation from a list of IP Addresses
#!/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