summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbigMAC.sh19
1 files changed, 11 insertions, 8 deletions
diff --git a/bigMAC.sh b/bigMAC.sh
index f29f39f..627d45c 100755
--- a/bigMAC.sh
+++ b/bigMAC.sh
@@ -9,13 +9,16 @@ for dep in "${deps[@]}"; do
fi
done
-
macs_file="macs.txt"
succ_file="tasty-macs.txt"
-interface="wlp2s0"
-timeperiod=$((1)) # timeperiod=$((60 * 60 * 3))
-date_format="echo \033[0;33m$(date '+%b %d %T')\033[0m"
+interface=$(ip route get 8.8.8.8 | awk '{print $5}') # usually wlp2s0
+
+timeperiod=$((20)) # timeperiod=$((60 * 60 * 3))
+
+function log {
+ printf "\033[0;33m%s\033[0m $1" "$(date '+%b %d %T')"
+}
function get_macs {
while true; do n=0
@@ -26,7 +29,7 @@ function get_macs {
fi
done <<< $(nmap -sn 192.168.0.* | awk '/^MAC Address:/{print $3}')
- ((n > 0)) && echo -e "$($date_format) Wrote $n new addresses to $macs_file" || true
+ ((n > 0)) && log "Wrote $n new addresses to $macs_file\n" || true
done
}
@@ -37,14 +40,14 @@ function set_ip_address {
sleep 2
}
-function taste-macs {
+function taste_macs {
while read -r addr; do
set_ip_address "$addr"
response=$(curl -s -o /dev/null -w "%{http_code}" --connect-timeout 5 192.168.0.1)
if [[ "$response" == "200" ]]; then
if ! grep -qF -- "$addr" "$succ_file" &> /dev/null; then
echo "$addr" >> "$succ_file"
- echo -e "$($date_format) Wrote '$addr' to $succ_file"
+ log "Wrote '$addr' to $succ_file"
fi
fi
done < "$macs_file"
@@ -54,5 +57,5 @@ function taste-macs {
while true; do
get_macs & sleep "$timeperiod"; kill $!
- taste-macs
+ taste_macs
done