[PATCH] mini port scanner for busybox - V4

Tito farmatito at tiscali.it
Fri Jun 15 21:16:51 UTC 2007


On Thursday 14 June 2007 23:27:04 Denis Vlasenko wrote:
> On Thursday 14 June 2007 16:12, Tito wrote:
> > > It's good that you added these comments,
> > > but explanation is not clear enough (at least for me).
> > > 
> > > Care to improve?
> > > --
> > > vda
> > > 
> > 
> > Here a new version of the patch with improved comments. Enjoy! ;-D
> > 
> > PS: fixed also a stupid typo in my_gettimeofday
> > if (!gettimeofday(&now, NULL)) ==> if (gettimeofday(&now, NULL))
> 
>                 s = xsocket(lsap->sa.sa_family, SOCK_STREAM, 0);
>                 ndelay_on(s);
>                 t1 = my_gettimeofday();
>                 connect(s, &lsap->sa, lsap->len);
> 
> Ok, here it can be successful, or can fail. You don't even look at return value.
> It is useless or what?
> 
> These questions need to be explained in order to have understandable code.
> 
> Ok. I did a small experiment, added a few debug prints,
> and changed it to start scanning from port 79.
> 
> # ./busybox pscan -p 80 195.66.192.167 2>2
> Scanning 195.66.192.167 ports 1 to 80
>  Port   Proto   State   Service
>    80   tcp     open    www
> 78 stealth, 1 closed, 1 open ports
> 
> logfile:
> 
> pscan: connect 45us: Operation now in progress
> pscan: write:-1 4us
> pscan: write:-1 2us
> <15759 more write errors snipped>
> pscan: connect 31us: Operation now in progress
> pscan: write:-1 2us
> <~140000 more write errors snipped>
> pscan: write:1 18us
> 
> I don't like write() flood, with accompanying horde of gettimeofday calls.
> 
> Maybe this? (please see attched).
> --
> vda
> 

Looks good to me, added some of the TODOs and changed all the time to msec.
Please check if i fully understood your code. Sorry no time for a patch right now,
sending the file I've changed. If needed patch will follow tomorrow. ;-)

Ciao,
Tito
PS: change usage.h to

#define pscan_trivial_usage \
       "[-p MIN_PORT][-P MAX_PORT][-t MIN_RTT][-T TIMEOUT] HOST"
#define pscan_full_usage \
       " Scan a host's ports printing all open ports." \
       "\n\nOptions:\n" \
       "	-p	scan from this port (default 1)\n" \
       "	-P	scan up to this port (default 1024)\n" \
       "	-t	minimum roundtrip time in msec (default 1000)"\
       "	-T	timeout in msecs (default 5000)"
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pscan.c
Type: text/x-csrc
Size: 4175 bytes
Desc: not available
Url : http://lists.busybox.net/pipermail/busybox/attachments/20070615/4d6d6321/attachment-0002.c 


More information about the busybox mailing list