Page 1 of 1

5 Cents tip for today [ Portscanner ]

Posted: Sat Feb 28, 2004 1:24 pm
by newdep
;; Quick and dirty portscanner on tcp
;; because there is no timeout regulation for remote portsscan
;; it could take ages to return nil or true
;; the timeout depends on the remote tcp socket behaviour.
;;
(define (scan host startport endport )
(set 'cnt startport )
(until (> cnt endport)
(println "Scanning - " host " -")
(if (set 'scanned (net-connect host cnt ))
(begin
(println "port :" cnt " -> open")
(net-close scanned)))
(inc 'cnt))
)

(scan "remote.host" 4000 5500)
(exit)

;; eof ;;

Posted: Sat Feb 28, 2004 1:57 pm
by Lutz
Thanks, works great - with your permission can I put this in th 'Tips&Tricks' section on http://newlisp.org/news/ ?

I can put 'Contributed by Norman ???' on it but would need your last name, or if you prefer you can stay anonymous or only with your first name?

Lutz

Posted: Sat Feb 28, 2004 3:11 pm
by newdep
Hello Lutz,

A nice, yes please use it as an example or tip,
just put my first name with it ;-) I have too many hits on my last name ;-)

Enjoy the examples...

Norman..

Correction

Posted: Sat Feb 28, 2004 3:30 pm
by newdep
** correct version **

;; Quick and dirty portscanner on tcp
;; because there is no timeout regulation for remote portsscan is could
;; take ages
;; to return nil or true, the timeout depends on the remote tcp socket
;; behaviour.
;;
(define (scan host startport endport )
(set 'cnt startport )
(println "Scanning - " host " -")
(until (> cnt endport)
(if (set 'scanned (net-connect host cnt ))
(begin
(println "port :" cnt " -> open")
(net-close scanned)))
(inc 'cnt))
)

(scan "some.host" 4000 5500)
(exit)

;; eof ;;