bugfix: when cron fires, scanner script should not start looping forever, instead, return after scan

This commit is contained in:
sandb 2010-02-20 02:36:59 +01:00
parent 4e6cac380c
commit ebff21147c

View File

@ -30,7 +30,6 @@ REGISTER=
IF='eth0'
OUT='http://yourserver.com/pamela/upload.php'
SLEEP='120'
USER=''
PASSWORD=''
@ -41,7 +40,6 @@ echo "Usage: pamela-scanner [OPTIONS]
-i INTERFACE Interface to arp-scan. Defaults to [$IF].
-o URL The url of the pamela upload script (including /upload.php).
Defaults to [$OUT].
-s TIME The time to sleep between scans in seconds. Defaults to [$SLEEP].
-r Register the script in cron every 2 minutes
-q Unregister the script from cron
-u Http-auth user. Defaults to [$USER].
@ -60,7 +58,7 @@ exit 1
function register {
echo "Registering pamela in cron: $PAM_CRON"
echo "*/2 * * * * root [ -x \"$PAM_SCRIPT\" ] && \"$PAM_SCRIPT\" -i \"$IF\" -o \"$OUT\" -s \"$SLEEP\" -u \"$USER\" -p \"$PASSWORD\" >> \"$PAM_LOG\"" > "$PAM_CRON"
echo "*/2 * * * * root [ -x \"$PAM_SCRIPT\" ] && \"$PAM_SCRIPT\" -i \"$IF\" -o \"$OUT\" -u \"$USER\" -p \"$PASSWORD\" >> \"$PAM_LOG\"" > "$PAM_CRON"
exit 0
}
@ -104,8 +102,6 @@ then
echo "ENOARPSCAN: Could not find arp-scan, please install it"
fi
while true
do
echo $(date)" scanning..."
NETMASK="$(ip -4 addr show "$IF" | egrep -o "brd [0-9\.]+" | egrep -o "[0-9\.]+")"
MACS=""
@ -123,6 +119,3 @@ do
echo "$RESULT"
fi
echo $(date)" Uploaded $NUM_MACS mac addresses..."
echo $(date)" sleeping..."
sleep "$SLEEP"
done