#!/bin/msh
# ip.sh - router webinterface scanner
# Licence: GNU GPL v3 or later at your option
# Author:  Florian Bruhin (The Compiler) <florianbruh@gmail.com>
version="1.0"
# Copyright 2008 Florian Bruhin

# This program is part of the Wizzy-suite
#
# The Wizzy-suite is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# The Wizzy-suite is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with the Wizzy-suite.  If not, see <http://www.gnu.org/licenses/>.

begin=0
end=255
echo=yes
log="/home/ip.log" # Comment out to don't log
logstyle=append # overwrite/append
delim="========= DATE =========" #Delimiter for append, DATE gets replaced by current date and time

ct="$begin"

if [ -n "$log" ]; then
	[ "$logstyle" = overwrite ] && >"$log"
	echo "$delim" | sed "s/DATE/`date`/" >> "$log"
fi
while [ $ct -le $end ]; do
	if ping -c 1 192.168.$ct.1 > /dev/null; then
		line="IP FOUND: 192.168.$ct.1"
	else
		line="nothing at 192.168.$ct.1"
	fi
	[ "$echo" = yes ] && echo "$line"
	[ -n "$log" ] && echo "$line" >> "$log"
	ct=`expr $ct + 1`
done
