Getting public IP address ranges for an organization

Small bash script to automate the work with Qrator Radar public API.

Qrator Radar

The idea is to get autonomous system (AS) number of the organization by it’s name and retrieve all related IPv4 Prefixes. Why you may need it? To be sure, for example, that you scan all the hosts of organization available from the Internet for vulnerability management, penetration testing or bug bounty activity. For smaller organizations that don’t have own AS that obviously will not work.

name="TEST"; as=`curl -s "$name" | egrep -o '/as[0-9]+' | egrep -o "[0-9]+" | head -n 1`; echo "name: $name (as$as)"; curl -s "$as?tab_id=current&page=1" | egrep -o '(1 \\/ [0-9]*|"pager":")' | awk 'BEGIN{a=1}{if($3==""){print 1}else{while(a<=$3){print a;a++}}}' | xargs -i curl -s "$as?tab_id=current&page={}" | egrep -o '[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*\\/[0-9]*' | sed 's|\\/|/|g' | sort -n | uniq
name: TEST (as32934)

You can search for this range at Shodan and get some scan results. That works only for registered users:

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.