Created
October 8, 2014 19:06
-
-
Save hackingbutlegal/8385da22c63840bdefe4 to your computer and use it in GitHub Desktop.
Enumerate a CIDR
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
ip=$( echo $1 | cut -d"/" -f1 ) | |
no=$( echo $1 | cut -d"/" -f2 ) | |
k=`expr 32 - $no` | |
nu=$(echo "2 ^ $k" | bc) | |
num=1 | |
new_ip=$( echo $ip | cut -d"." -f1-3 ) | |
while [[ $num -ne $nu ]] | |
do | |
echo $new_ip".$num" | |
(( num = num + 1 )) | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment