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