5 Cents tip for today [ Portscanner ]

Featuring the Dragonfly web framework
Locked
newdep
Posts: 2038
Joined: Mon Feb 23, 2004 7:40 pm
Location: Netherlands

5 Cents tip for today [ Portscanner ]

Post 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 ;;

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post 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

newdep
Posts: 2038
Joined: Mon Feb 23, 2004 7:40 pm
Location: Netherlands

Post 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..

newdep
Posts: 2038
Joined: Mon Feb 23, 2004 7:40 pm
Location: Netherlands

Correction

Post 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 ;;

Locked