Created
November 27, 2016 14:18
-
-
Save 83leej/96e99077fcd23b329fa8a2d183b7289b to your computer and use it in GitHub Desktop.
just a simple script that grabs two file if they are currently not there, allows checking for IP ranges by providing a simple name such as 'godaddy' or 'digitalocean', it then returns the results and provides a file name rangelist with the found ranges.
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/bash | |
NAMETOCHECK=$1 | |
if [ ! -d asninfo ]; then | |
mkdir asninfo; | |
echo "Created: asninfo/"; | |
fi | |
if [ ! -f asninfo/data-used-autnums.txt ]; then | |
curl http://thyme.apnic.net/current/data-used-autnums -o asninfo/data-used-autnums.txt | |
fi | |
if [ ! -f asninfo/data-raw-table.txt ]; then | |
curl http://thyme.apnic.net/current/data-raw-table -o asninfo/data-raw-table.txt | |
fi | |
echo "" | |
echo "#######################" | |
echo "ASN names for $NAMETOCHECK" | |
echo "" | |
grep -wi "$NAMETOCHECK" asninfo/data-used-autnums.txt > templist | |
ASNFOUND=0 | |
COUNTER=0 | |
rm rangelist | |
touch rangelist | |
while read ASN NAME | |
do | |
let ASNFOUND=ASNFOUND+1 | |
echo " ------- [ $ASN ] ---------" | |
echo " -- $NAME" | |
echo " -- RANGES FOR ASN: $ASN" | |
grep -wi $ASN asninfo/data-raw-table.txt > templist2 | |
while read RANGE ASN2 | |
do | |
echo " --- $RANGE" | |
let COUNTER=COUNTER+1 | |
echo "$RANGE" >> rangelist | |
done <templist2 | |
rm templist2 | |
done <templist | |
rm templist | |
echo " ------- [ FINISHED ] ---------" | |
echo " Found $ASNFOUND ASN match for $NAMETOCHECK" | |
echo " Total $COUNTER IP Ranges Found" | |
echo " Exported to file: rangelist" | |
echo "" | |
echo " IP Range Extractor By ctrlbox.com" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment