Last active
September 5, 2021 21:00
-
-
Save m0rb/8e8dd731802f54b99eea044a105903ec to your computer and use it in GitHub Desktop.
This file contains 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
#!/bin/sh | |
# countryblock.sh -- yet another country blackholing script by morb | |
# psst, hey kid! wanna blackhole countries with the flick of a wrist? | |
CC=$1;[ -z $CC ]&&printf "Usage: $0 <country code>\nex:\n$0 cn #China\n"&&exit 1 | |
[ "$USER" != "root" ]&&printf "root required.\n"&&exit 1 | |
ZONE="http://www.ipdeny.com/ipblocks/data/countries/${CC}.zone" | |
curl -s $ZONE | xargs -I, ip route add blackhole , metric 999 |
I added the if statement to take the option "list" and it will print all available codes from the commandline so you don't have to visit the site. The SSL cert expired so used -k.
cool
check this out
$ awk '{FS="\t";print $1, $5}' /usr/share/libtimezonemap/countryInfo.txt
$ awk '{FS="\t";print $1, $3}' /usr/share/zoneinfo/zone.tab | sed '/^#/d'
That would work too, but there are some county codes (14) in the zone.tab that are not on the ipblocks website.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I added the if statement to take the option "list" and it will print all available codes from the commandline so you don't have to visit the site. The SSL cert expired so used -k.
full code: