retro64xyz

370 1.3

Jan 31st, 2023
897
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.80 KB | Cybersecurity | 0 0
  1. #!/usr/bin/bash
  2.  
  3. CIDR=192.168.0
  4. STARTOCTET=0
  5. ENDOCTET=1
  6.  
  7. while getopts O:o: flag
  8. do
  9.     case "${flag}" in
  10.         O) filename=${OPTARG};;
  11.         o) filename=${OPTARG};;
  12.     esac
  13. done
  14.  
  15. echo "Please enter the starting octet..."
  16. read STARTOCTET
  17.  
  18. echo "Please enter the ending octet..."
  19. read ENDOCTET
  20.  
  21. [ -n "$STARTOCTET" ] && [ "$STARTOCTET" -eq "$STARTOCTET" ] 2>/dev/null
  22. if [ $? -ne 0 ]; then
  23.    echo $STARTOCTET is not number
  24.    exit 1
  25. fi
  26.  
  27. [ -n "$ENDOCTET" ] && [ "$ENDOCTET" -eq "$ENDOCTET" ] 2>/dev/null
  28. if [ $? -ne 0 ]; then
  29.    echo $ENDOCTET is not number
  30.    exit 1
  31. fi
  32.  
  33. if (( $ENDOCTET < $STARTOCTET));
  34. then
  35.     echo "Start octect must be earlier than ending octet"
  36.     exit 1
  37. fi
  38.  
  39. for i in $(seq $STARTOCTET $ENDOCTET)
  40. do
  41.     echo "scanning $i"
  42.     nmap -Pn -F $CIDR.$i >> $filename
  43. done
Advertisement
Add Comment
Please, Sign In to add comment