newping.c


Newping is a PING-like utility that instead of ICMP, it uses TCP. The source which I tweaked is available from ftp://ftp.nec.com/pub/security/socks.cstc/util/newping.c.

Usage: newping [-q] [-d] [-u] [-p port] [-S string] host [timeout]

To compile use an ANSI C compiler (like gcc). If you want to use the SOCKS library, put -DSOCKS in the compiler flags.

My modified source code is here.

-- adamo@dblab.ntua.gr -.


Sample port scanner using either newping or *Hobbit*'s netcat:
#!/bin/ksh
 
[ -z ${3} ] && {
        echo usage: probe [host] [low port] [high port]
        exit 1
}
 
i=${2}
 
while [ ${i} -le ${3} ]
do
#nc -z ${1} ${i} ### if you want *Hobbit*'t netcat.
newping -q -p${i} ${1}
[ $? -eq 0 ] && {
        echo host ${1} port ${i} open
}
let i=i+1
done
 
exit 0