Advertisement
metalx1000

Scan Network for Unknown Computers

Apr 7th, 2017
678
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.53 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. if [[ $EUID -ne 0 ]]; then
  4.   echo "You must be a root user"
  5.   echo "Trying to restart script as sudo"
  6.   sudo $0 $@
  7.   exit
  8. fi
  9.  
  10. #Color codes
  11. bold=`echo -en "\e[1m"`
  12. underline=`echo -en "\e[4m"`
  13. red=`echo -en "\e[31m"`
  14. blue=`echo -en "\e[34m"`
  15. normal=`echo -en "\e[0m"`
  16. blink=`echo -en "\e[5m"`
  17. purple=`echo -en "\e[35m"`
  18. reverse=`echo -en "\e[7m"`
  19.  
  20. #tmp files
  21. list="/tmp/maclist"
  22. found="/tmp/macfound"
  23. unknown="/tmp/macunknown"
  24. scan="/tmp/macscan"
  25.  
  26. rm "$list" "$found" "$unknown" "$scan"
  27. touch "$list" "$found" "$unknown" "$scan"
  28.  
  29. #Known List URL
  30. url="http://filmsbykris.com/personal/home/maclist.php?key=shopp3r"
  31.  
  32. clear
  33.  
  34. echo "Downloading list..."
  35. wget -q "$url" -O $list
  36.  
  37. echo "Scanning Network..."
  38. arp-scan -l > $scan
  39. cat $scan|\
  40.   awk '{print $2}'|\
  41.   grep ':'|\
  42.   while read l;
  43.   do
  44.     grep -i "$l" $list >> $found||echo "$l" >> $unknown
  45.   done
  46.  
  47. echo -e "\n\n${bold}${underline}Recognized Machines${normal}"
  48. cat $found |while read l
  49. do
  50.   IFS=' ' read -r -a a <<< "$l"
  51.   ip="$(grep -i "${a[2]}" $scan|awk '{print $1}' )"
  52.   echo -n "${blue}"
  53.   echo -n "${a[0]} "
  54.   echo -n "${normal}${bold}${purple}"
  55.   echo -n "$ip "
  56.   #echo -n "${a[1]} "
  57.   echo -n "${normal}${bold}"
  58.   echo -n "${a[2]}"
  59.   echo "${normal}"
  60. done|column -t
  61.  
  62. echo -e "\n\n${red}${underline}Unknown Machines${normal}"
  63. cat $unknown|while read l
  64. do
  65.   s="$(grep -i "$l" $scan)"
  66.   IFS=' ' read -r -a a <<< "$s"
  67.   echo -n "${bold}${blink}${red}${reverse}"
  68.   echo -n "${a[0]}"
  69.   echo -n "${a[1]}"
  70.   echo "${normal}"
  71. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement