#!/bin/bash # # $Id: psw,v 1.2 2002/04/17 22:16:02 Exp $ # PSW is a very basic ping sweeper written in bash. # Useful for the fast identification of active hosts # in a big network, for security evaluation tasks. # # Usage example: ./psw 192.168.0 1 254 # # Some vars log=psw.log ping=/sbin/ping # Command line network=$1 begin=$2 end=$3 count=0 # Local functions function green() { echo -e "\033[01;32m$@\033[00m" } function yellow() { echo -e "\033[01;33m$@\033[00m" } function red() { echo -e "\033[01;31m$@\033[00m" } function usage() { echo "" echo "PSW 0.1. Simple C class ping sweeper" echo "By Raptor " echo "" echo "usage : ./psw " echo "example: ./psw 192.168.0 1 254" echo "" exit 1 } # Input control if [ -z "$3" ]; then usage fi # Interactive logging echo "" echo "PSW 0.1. Simple C class ping sweeper" echo "By Raptor " echo "" yellow "[x] Starting with: ${network}.${begin}" echo "" # Perform the ping sweep while : do $ping -c 1 -w 5 $network.$begin 1>/dev/null 2>/dev/null # Check ping return value if [ $? -eq 0 ]; then green "${network}.${begin}" echo "${network}.${begin}" >> $log count=`expr $count + 1` else echo "${network}.${begin}" fi # Go for the next address if [ $begin -eq $end ]; then break else begin=`expr $begin + 1` fi done echo "" yellow "[x] Finished with: ${network}.${end}" red "[x] Final results: ${count} hosts found" echo "" exit 0