Skip to content

Instantly share code, notes, and snippets.

@szepeviktor
Created February 27, 2014 00:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save szepeviktor/9242001 to your computer and use it in GitHub Desktop.
Save szepeviktor/9242001 to your computer and use it in GitHub Desktop.
Magyar IP cím tartomány generáló - maxmind.com & ip.ludost.net
#!/bin/bash
OUT="GeoIPhuWhois.txt"
OUT2="ip.ludost.txt"
if ! [ -f GeoIPCountryWhois.csv ]
then
wget -q http://geolite.maxmind.com/download/geoip/database/GeoIPCountryCSV.zip
7z x GeoIPCountryCSV.zip > /dev/null
fi
echo '<Files wp-login.php>
# GeoLite data created by MaxMind
# http://dev.maxmind.com/geoip/legacy/geolite/
order deny,allow
deny from all' > $OUT
grep ',"HU",' GeoIPCountryWhois.csv | \
cut -d"," -f1,2 | sed 's|^"\(.*\)","\(.*\)"$|\1 \2|' | \
while read r
do
range2cidr.awk $r | while read r2
do
echo " Allow from $r2"
done
done >> $OUT
########################
echo '<Files wp-login.php>' > $OUT2
wget -qO - --post-data="country=1&country_list=hu&format_template=apache-allow&format_name=&format_target=&format_default=" \
https://ip.ludost.net/cgi/process >> $OUT2
echo '</Files>' | tee -a $OUT2 >> $OUT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment