Skip to content

Instantly share code, notes, and snippets.

@thimslugga
Last active January 9, 2017 03:28
Show Gist options
  • Save thimslugga/4c5ef3494503ef0e09a85043599bbc90 to your computer and use it in GitHub Desktop.
Save thimslugga/4c5ef3494503ef0e09a85043599bbc90 to your computer and use it in GitHub Desktop.
Revised emerging threats list script
#!/bin/sh
NETGROUP="ET-A"
curl -O http://rules.emergingthreats.net/fwrules/emerging-Block-IPs.txt
getnetblocks() {
cat <<EOF
# Generated by ipset
-N geotmp nethash --hashsize 1024 --probes 4 --resize 20
EOF
cat /config/user-data/emerging-Block-IPs.txt|egrep '^[0-9]'|egrep '/' |sed -e "s/^/-A geotmp /"
}
getnetblocks > /config/user-data/netblock.txt
sudo ipset -! -R < /config/user-data/netblock.txt
sudo ipset -W geotmp ET-N
sudo ipset -X geotmp
getaddblocks() {
cat <<EOF
# Generated by ipset
-N geotmp nethash --hashsize 1024 --probes 4 --resize 20
EOF
cat /config/user-data/emerging-Block-IPs.txt|egrep '^[0-9]'|egrep -v '/' |sed -e "s/^/-A geotmp /"
}
getaddblocks > /config/user-data/addblock.txt
sudo ipset -! -R < /config/user-data/addblock.txt
sudo ipset -W geotmp ET-A
sudo ipset -X geotmp
RESULT="updated list for $NETGROUP"
logger -i -s $RESULT
rm /config/user-data/addblock.txt
rm /config/user-data/netblock.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment