5 Cents tip for today [ Portscanner ]

Started by newdep, February 28, 2004, 05:24:19 AM

Previous topic - Next topic

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 ;;
-- (define? (Cornflakes))

Lutz

#1
Thanks, works great - with your permission can I put this in th 'Tips&Tricks' section on http://newlisp.org/news/">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

#2
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..
-- (define? (Cornflakes))

newdep

#3
** 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 ;;
-- (define? (Cornflakes))