#!/bin/sh
# shscanp.sh // SHell SCAN Ports
# gpl'd (c) 2006 sk

if [ $# -eq 3 ]; then
	IP=$1
	BEGIN=$2
	END=$3
elif [ $# -eq 2 ]; then
	BEGIN=$1
	BEGIN=$2
else
	echo "	Syntax: $0 <a.b.c> <start d> <end d>" > /dev/stderr
	exit 2
fi

let -a hosts
j=0
for((i=$BEGIN;i<=$END;i++)); do
	ping -w1 -c1 $IP.$i > /dev/stderr
	if [ $? -eq 0 ]; then
		hosts[$j]="$IP.$i"
		j=$[$j+1]
		printf "\tyesss..suxxess.. on $IP.$i (now we got ${#hosts[@]})\n"
	else
		printf "\tshit, it wasn't the .$i\n"
	fi
done
echo
echo "so now we got the following hosts..:"
if [ ${#hosts[@]} -eq 0 ]; then
	echo "..none. ;/"
	exit 1
fi	
for((i=0;i<${#hosts[@]};i++)); do
	echo ${hosts[$i]}
done


