Advertisement
GoodiesHQ

asn.sh

Jan 1st, 2016
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.44 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. if [ $# -eq 0 ]; then
  4.     echo "You must provide at least one ASN (multiple should be separated by space)."
  5.     exit 0
  6. fi
  7. result=""
  8. re='^[0-9]+$'   # simple regex to make sure that each ASN is a number
  9. for arg in "$@"; do
  10.     if [[ $arg =~ $re ]]; then
  11.         temp=$(whois -h whois.radb.net -- "-i origin AS${arg}" | grep -Eo "([0-9.]+){4}/[0-9]+")
  12.         result="$result $temp"
  13.     fi
  14. done
  15. for res in $result; do
  16.     echo -e "  deny $res;"
  17. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement