ulvis.paste.net

Paste Search Dynamic
Recent pastes
Network test
  1. #!/bin/bash
  2. RED='\033[0;31m'
  3. GREEN='\033[0;32m'
  4. NC='\033[0m'
  5. arr_rout=(51.1 52.1 53.1 54.1 65.2 75.2 85.2 95.2 105.2 115.2)
  6. arr_rout_net=(51 52 53 54 65 75 85 95 105 115)
  7.  
  8. printf "#---------------------#\n"
  9. printf "| TEST SCRIPT FOR PSA |\n"
  10. printf "|      SHEET 02       |\n"
  11. printf "|      TEAM  05       |\n"
  12. printf "#---------------------#\n\n"
  13.  
  14. printf "Testing connection to routers of other teams.\n"
  15. printf "\nPerforming network mapping from 192.168.0.0 to 192.168.11.255.\n      Please wait."
  16. NMAPRESULT="$(nmap -e enp0s8 -max-rtt-timeout 500ms -max-retries 2 -host-timeout 1000ms -nsP 192.168.1.0/24 192.168.2.0/24 192.168.3.0/24 192.168.4.0/24 192.168.6.0/24 192.168.7.0/24 192.168.8.0/24 192.168.9.0/24 192.168.10.0/24 192.168.11.0/24)"
  17. printf "   DONE!\n"
  18.  
  19.  
  20. for i in 1 2 3 4 6 7 8 9 10 11
  21. do
  22.         if (( i < 5 )); then
  23.                 ialt=$((i - 1))
  24.         else
  25.                 ialt=$((i - 2))
  26.         fi
  27.         printf "\nTeam $i Router (192.168.${arr_rout[${ialt}]})"
  28.         if ping -c 1 192.168.${arr_rout[${ialt}]} &> /dev/null
  29.         then
  30.                 printf " ${GREEN}found${NC}\n"
  31.                 COUNT=$(echo $NMAPRESULT | grep -o 192.168.${i}. | wc -l)
  32.                 if (( COUNT > 0 )); then
  33.                         printf "   Host Count of Team ${i}: $COUNT \n"
  34.                 else
  35.                         printf "   ${RED}Router seems not to be routing ICMP requests into the private subnet. 0 Hosts found.${NC}\n"
  36.                 fi
  37.         else
  38.                 printf " ${RED}unreachable${NC}\n"
  39.         fi
  40. done
  41.  
  42. printf "\n\nDONE!\n"
  43.  
Parsed in 0.014 seconds