;;
;; Quick and Dirty Portforwarder TCP exmaple, no real error checking done.
;; connects one tcp port to the other, closed the listener port when client is
;; connected
;;
;; run the portforwarder, then connect with i.e. ssh localhost -p 2200
;; and you will be forwarded internal towards the 22 sshd port.
;;
;; Its pritty easy to include PortSniffing in this PortForwarder, just display
;; the cbuff and rbuff content, printable character, during io.
;;
;; This portforwarder does not run smoothly for http pages because
;; of the line-based protocol http.
;; setup a listener
(unless (set 'server (net-listen 2200 ))
(begin
(println (net-error))
(exit))
(println "Server started") )
;; setup a client session to localhost sshd port 22
(unless (set 'remote (net-connect "localhost" 22))
(begin
(println (net-error))
(exit))
(println "Remote opened") )
;; wait for connection and close the listener
(if (set 'client (net-accept server))
(begin
(net-close server)
(println "Client Connected" (net-peer client))) )
;; repeat until an error occeurs
(until (net-error)
(if (net-select client "read" 1000)
;; read data from client
(begin
( net-receive client 'cbuff (set 'csize (net-peek client)) )
( net-send remote 'cbuff csize )))
(if (net-select remote "read" 1000)
;; read data from remote
(begin
(net-receive remote 'rbuff (set 'isize (net-peek remote)) )
(net-send client 'rbuff isize)))
)
(println "Server Shutdown or " (net-error))
(exit)
Norman.
5 Cent tip for today [ TCP Port Forwarder ]
Addon, with some accesslisting on the portscanner with predefined ip addresses the portforwarder will have some basic security for access.
Still very easy to port my programs towards newlisp,
the portforwarder was done in a few minutes, which indirectly implies
that newlisp is quicky to learn and easy to use ;-) like it..!
Norman.
Still very easy to port my programs towards newlisp,
the portforwarder was done in a few minutes, which indirectly implies
that newlisp is quicky to learn and easy to use ;-) like it..!
Norman.