#!/bin/sh
# Tester for LAT's Garbiel network probe (e.g. SATAN) detector.
# 

PATH=/bin:/usr/bin:/usr/5bin:/usr/sbin:/usr/ucb
export PATH
SHELL=/bin/sh
export SHELL

echo This script sends a number of network probes to
echo simulate network probing of a program like SATAN.
echo ""

ostype=`uname`
if [ $ostype != "SunOS" ]; then
	echo "The $ostype operating system is not supported."
	exit
fi

osver=`uname -r`
case $osver in
	4.*)
		suffix=sol1
		;;
	5.*)
		suffix=sol2
		;;
	*)
		echo The $osver release of $ostype is not supported.
		exit
		;;
esac

echo Enter name of host to probe, or control-c to exit.
read host
echo ""
echo Probing host $host

# Determine name of ping program.
if [ -f /usr/sbin/ping ]; then
	pingpgm=/usr/sbin/ping
fi
if [ -f /usr/etc/ping ]; then
	pingpgm=/usr/etc/ping
fi
$pingpgm $host 2>&1 > /dev/null 
if test $? != "0"
then
	echo Host $host is not responding
	exit
fi
echo Continuing probes of $host

maxprobes=16
portlist=""
portlist="1 2 3 4 5 6 24 25 26"
portlist="$portlist 27 28 29 30 31 32 1000 5000"
i=0
for port in $portlist
do
	i=`expr $i + 1`
	echo "$i  Probing TCP port $port"
	( (sleep 2 ; echo quit) | telnet $host $port ) > /dev/null 2>&1
done

echo ""
maxpings=100
echo "Sending $maxpings pings to flush buffers on solaris 2 clients."
i=0
while /bin/true
do
	i=`expr $i + 1`
	$pingpgm $host 2>&1 > /dev/null
	if test $i -ge $maxpings
	then
		break
	fi
done

