Advertisement
metalx1000

Maclogger - Client end

Feb 15th, 2018
910
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.83 KB | None | 0 0
  1. #!/bin/bash
  2. #Created by Kris Occhipinti Copyright 2018
  3. #http://filmsbykris.com
  4. #Licensed under AGPL - https://www.gnu.org/licenses/agpl-3.0.txt
  5.  
  6. func="$1"
  7. ip="<scanner IP Address>"
  8. port="9999"
  9. knownURL="<URL for Known Device List>"
  10. tmp="/tmp/maclog.tmp"
  11. log=""
  12.  
  13. function main(){
  14.   if [ "$func" = "known" ]
  15.   then
  16.     listKnown
  17.   elif [ "$func" = "help" ]
  18.   then
  19.     help
  20.   elif [ "$func" = "all" ]
  21.   then
  22.     all
  23.   elif [ "$func" = "devices" ]
  24.   then
  25.     deviceOnly
  26.   else
  27.     recent
  28.   fi
  29. }
  30.  
  31. function recent(){
  32.   wget -qO "$tmp" "http://$ip:$port$(getLast 1)"
  33.   getKnown
  34. }
  35.  
  36. function all(){
  37.   rm "$tmp"
  38.   echo -n "Getting all logs..."
  39.   wget -qO- "http://$ip:$port"|\
  40.     sed 's/<a/\n<a/g'|\
  41.     grep href|\
  42.     grep csv|\
  43.     cut -d\' -f2|while read line
  44.     do
  45.       echo -n "."
  46.       wget -qO- "http://$ip:$port$line" >> $tmp
  47.     done
  48.  
  49.   echo ""
  50.   getKnown
  51. }
  52.  
  53. function getKnown(){
  54.   wget "$knownURL" -qO-|\
  55.     tr '[:lower:]' '[:upper:]'|\
  56.     awk '{print $1 " " $3}'|while read line
  57.     do
  58.       set -- $line
  59.       #sed -i "s/$2/\\\e[7m$1\\\e[39m/g" "$tmp"
  60.       sed -i "s/$2/\\\e[7m$1\\\e[0m/g" "$tmp"
  61.     done
  62.  
  63.     echo -e "$(cat "$tmp")"
  64. }
  65.  
  66. function listKnown(){
  67.   echo "Known from $knownURL"
  68.   echo ""
  69.   wget "$knownURL" -qO-
  70. }
  71.  
  72. function getLast(){
  73.   wget -qO- "http://$ip:$port"|\
  74.     sed 's/<a/\n<a/g'|\
  75.     grep href|\
  76.     grep csv|\
  77.     cut -d\' -f2|\
  78.     tail -n $1
  79. }
  80.  
  81. function deviceOnly(){
  82.   wget -qO- "http://$ip:$port$(getLast 1)"|\
  83.     tr " " "\n"|\
  84.     grep -i '[0-9A-F]\{2\}\(:[0-9A-F]\{2\}\)\{5\}'|\
  85.     sort -u > "$tmp"
  86.   getKnown
  87. }
  88.  
  89. function help(){
  90.   echo "Usage:"
  91.   echo "$0  --  DEFAULT-View most recent logs."
  92.   echo "$0 known  --  LIST know devices"
  93.   echo "$0 all  --  LIST all logs"
  94.   echo "$0 devices  --  LIST Device MAC/Names Only"
  95. }
  96.  
  97. main
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement