Last active
June 23, 2018 21:20
-
-
Save betmoar/e6cad8a89e74696aff49 to your computer and use it in GitHub Desktop.
iBlocklist to CIDR 24
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
| #!/bin/bash | |
| rm -f list* | |
| rm -f cidr* | |
| for url in $(curl -s https://www.iblocklist.com/lists.php \ | |
| | hxwls \ | |
| | egrep -B1 'star_[5]' \ | |
| | grep -v png \ | |
| | grep 'list=' \ | |
| | sed 's|/list.php?list=||g' \ | |
| | sed 's|^|http://list.iblocklist.com/?list=|g' \ | |
| | sed 's|$|\&fileformat=p2p\&archiveformat=gz|g'); do wget --no-verbose "${url}" -O - | gunzip \ | |
| | egrep -v '^#' \ | |
| | grep -v '^#\|^$\|^:' \ | |
| | sed 's/^.*://' \ | |
| | grep -aoEw -e "[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}" \ | |
| | grep -Ev '^(192\.168|10\.|172\.1[6789]\.|172\.2[0-9]\.|172\.3[01]\.|127\.0\.0\.1|0\.0\.0\.0)' >> list; done | |
| sort -t . -k 1,1n -k 2,2n -k 3,3n -k 4,4n -u list -o tmp | |
| cut -d'.' -f1,2,3 tmp \ | |
| | sed 's/$/.0\/24/' \ | |
| | sort -t . -k 1,1n -k 2,2n -k 3,3n -u >> cidr-24 | |
| rm -f tmp | |
| gzip -f list | |
| gzip -f cidr-24 | |
| echo "DONE" | |
| ls -lah list.gz | |
| ls -lah cidr-24.gz |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment