├── README.md ├── asnips └── img ├── api-tokens.png └── help-menu.png /README.md: -------------------------------------------------------------------------------- 1 | ## GET All IPs of any company using ASN 2 |
3 | 4 | First Go On [Mxtoolbox](https://mxtoolbox.com) and register then grab a API key from [here](https://mxtoolbox.com/user/api) \ 5 | And **export MX_API=76193741-c335-4f56-b6hb-e5cfegbc9095** \ 6 | If You Keep Your API key in folder like me, You can add a simple if statment in .bashrc to export API keys. 7 |  8 | ```bash 9 | if [[ -f "${HOME}/.api_tokens/MXTOOL" ]]; then 10 | export MX_API="$(cat ${HOME}/.api_tokens/MXTOOL1 2> /dev/null)" 11 | fi 12 | ``` 13 | 14 | ## Usage: 15 | ```bash 16 | git clone https://github.com/mrrobot1o1/asnips.git 17 | cd asnips 18 | chmod +x asnips 19 | ./asnips -d tesla.com 20 | ./asnips -m AS394161 21 | ``` 22 |  23 | -------------------------------------------------------------------------------- /asnips: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ####################### 4 | # mrrobot1o1 # 5 | ####################### 6 | 7 | 8 | R='\033[0;31m' 9 | Y='\033[1;33m' 10 | G='\033[1;32m' 11 | W='\033[0m' 12 | 13 | display_help() { 14 | echo -e "${Y}Usage: ${G}asnips -d ${R}example.com${W}" >&2 15 | echo -e " ${G}asnips -m ${R}AS394161${W}" >&2 16 | echo 17 | echo -e " ${Y}-d, --domain${W} ${G}Get IPs using domains" 18 | echo -e " ${Y}-m, --manual${W} ${G}Get IPs using ASN number${W}" 19 | echo -e " ${Y}-h, --help${W} ${G}Help Menu.${W}" 20 | echo 21 | exit 1 22 | } 23 | 24 | 25 | while : 26 | do 27 | case "$1" in 28 | -d | --domain) 29 | if [ $# -ne 2 ]; then 30 | display_help 31 | else 32 | domain="$2" 33 | IP=$(host $domain | sed -n '1p' | awk '{print $NF}') 34 | ASN=$(curl -s http://ipinfo.io/$IP | jq .org | tr -d \" | awk '{print $1}') 35 | curl -s "https://api.mxtoolbox.com/api/v1/Lookup/ASN/?argument=$ASN&Authorization=$MX_API" | jq -r '.Information[] | ."CIDR Range"' 36 | fi 37 | shift 2 38 | ;; 39 | -m | --manual) 40 | if [ $# -ne 2 ]; then 41 | display_help 42 | else 43 | ASN="$2" 44 | curl -s "https://api.mxtoolbox.com/api/v1/Lookup/ASN/?argument=$ASN&Authorization=$MX_API" | jq -r '.Information[] | ."CIDR Range"' 45 | fi 46 | shift 2 47 | ;; 48 | -h | --help) 49 | display_help 50 | exit 0 51 | ;; 52 | -*) 53 | display_help 54 | exit 1 55 | ;; 56 | *) 57 | break 58 | ;; 59 | esac 60 | done 61 | -------------------------------------------------------------------------------- /img/api-tokens.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrrobot1o1/asnips/b20fa94f636ced3b45bab281d10e9017e4c94c1c/img/api-tokens.png -------------------------------------------------------------------------------- /img/help-menu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrrobot1o1/asnips/b20fa94f636ced3b45bab281d10e9017e4c94c1c/img/help-menu.png --------------------------------------------------------------------------------