Esempio n. 1
0
 def global_tcpip_forward(self, data):
     host_to_bind, port_to_bind = forwarding.unpackGlobal_tcpip_forward(data)
     if port_to_bind != 0:
         # Don't allow the port to bind to be specified
         return 0
     try:
         listener = reactor.listenTCP(port_to_bind, 
                                      forwarding.SSHListenForwardingFactory(self.conn,
                                                                            (host_to_bind, port_to_bind),
                                                                            forwarding.SSHListenServerForwardingChannel))
         # We don't set the 'interface' attribute because we want to listen on 0.0.0.0
         # Same effect as adding GatewayPorts yes to sshd_config
     except CannotListenError:
         return 0
     else:
         timeout = ServerConfig.session_timeout
         if timeout != 0:
             log.msg('Session timeout set to %d seconds' % timeout)
             timer = reactor.callLater(timeout, self._terminate_session)
         else:
             log.msg('Session duration is unlimited')
             timer = None
         port_to_bind = listener.getHost().port
         self.listeners[(host_to_bind, port_to_bind)] = Listener(listener, timer)
         return 1, struct.pack('>L', port_to_bind)
     finally:
         hostname = TunnelItServer().hostname
         self.conn.transport.sendDebug(">>> TunnelIt Remote Host: %s/%s" % (hostname[0], hostname[2][0]), alwaysDisplay=True)
         self.conn.transport.sendDebug(">>> TunnelIt Remote Port: %s" % port_to_bind, alwaysDisplay=True)
Esempio n. 2
0
 def global_cancel_tcpip_forward(self, data):
     host, port = forwarding.unpackGlobal_tcpip_forward(data)
     listener = self.listeners.get((host, port), None)
     if not listener:
         return 0
     del self.listeners[(host, port)]
     listener.stopListening()
     return 1
Esempio n. 3
0
 def global_cancel_tcpip_forward(self, data):
     hostToBind, portToBind = forwarding.unpackGlobal_tcpip_forward(data)
     listener = self.listeners.get((hostToBind, portToBind), None)
     if not listener:
         return 0
     del self.listeners[(hostToBind, portToBind)]
     self._runAsUser(listener.stopListening)
     return 1
Esempio n. 4
0
 def global_cancel_tcpip_forward(self, data):
     host, port = forwarding.unpackGlobal_tcpip_forward(data)
     listener = self.listeners.get((host, port), None)
     if not listener:
         return 0
     del self.listeners[(host, port)]
     listener.stopListening()
     return 1
Esempio n. 5
0
 def global_cancel_tcpip_forward(self, data):
     hostToBind, portToBind = forwarding.unpackGlobal_tcpip_forward(data)
     listener = self.listeners.get((hostToBind, portToBind), None)
     if not listener:
         return 0
     del self.listeners[(hostToBind, portToBind)]
     self._runAsUser(listener.stopListening)
     return 1
Esempio n. 6
0
 def global_cancel_tcpip_forward(self, data):
     hostToBind, portToBind = forwarding.unpackGlobal_tcpip_forward(data)
     listener = self.listeners.get((hostToBind, portToBind), None)
     if not listener:
         return 0
     del self.listeners[(hostToBind, portToBind)]
     if listener.disconnect_timer is not None:
         listener.disconnect_timer.cancel()
     listener.listener.stopListening()
     return 1
Esempio n. 7
0
    def global_cancel_tcpip_forward(self, data):
	
        hostToBind, portToBind = forwarding.unpackGlobal_tcpip_forward(data)
        print "forward cancel requested", portToBind
        
        listener = self.listeners.get((hostToBind, portToBind), None)
        if not listener:
            return 0
        
        del self.listeners[(hostToBind, portToBind)]
        listener.stopListening()
        return 1
Esempio n. 8
0
    def global_cancel_tcpip_forward(self, data):

        hostToBind, portToBind = forwarding.unpackGlobal_tcpip_forward(data)
        print "forward cancel requested", portToBind

        listener = self.listeners.get((hostToBind, portToBind), None)
        if not listener:
            return 0

        del self.listeners[(hostToBind, portToBind)]
        listener.stopListening()
        return 1
Esempio n. 9
0
 def global_tcpip_forward(self, data):
     host, port = forwarding.unpackGlobal_tcpip_forward(data)
     try: listener = reactor.listenTCP(port,
             forwarding.SSHListenForwardingFactory(self.conn,
                 (host, port),
                 forwarding.SSHListenServerForwardingChannel),
             interface = host)
     except:
         log.err()
         unittest.fail("something went wrong with remote->local forwarding")
         return 0
     else:
         self.listeners[(host, port)] = listener
         return 1
Esempio n. 10
0
 def global_tcpip_forward(self, data):
     host, port = forwarding.unpackGlobal_tcpip_forward(data)
     try:
         listener = reactor.listenTCP(
             port, forwarding.SSHListenForwardingFactory(
                 self.conn, (host, port),
                 forwarding.SSHListenServerForwardingChannel),
             interface=host)
     except:
         log.err(None, "something went wrong with remote->local forwarding")
         return 0
     else:
         self.listeners[(host, port)] = listener
         return 1
Esempio n. 11
0
 def global_tcpip_forward(self, data):
     hostToBind, portToBind = forwarding.unpackGlobal_tcpip_forward(data)
     from twisted.internet import reactor
     try: listener = self._runAsUser(
                         reactor.listenTCP, portToBind,
                         forwarding.SSHListenForwardingFactory(self.conn,
                             (hostToBind, portToBind),
                             forwarding.SSHListenServerForwardingChannel),
                         interface = hostToBind)
     except:
         return 0
     else:
         self.listeners[(hostToBind, portToBind)] = listener
         if portToBind == 0:
             portToBind = listener.getHost()[2] # the port
             return 1, struct.pack('>L', portToBind)
         else:
             return 1
Esempio n. 12
0
 def global_tcpip_forward(self, data):
     hostToBind, portToBind = forwarding.unpackGlobal_tcpip_forward(data)
     from twisted.internet import reactor
     try:
         listener = self._runAsUser(
             reactor.listenTCP,
             portToBind,
             forwarding.SSHListenForwardingFactory(
                 self.conn, (hostToBind, portToBind),
                 forwarding.SSHListenServerForwardingChannel),
             interface=hostToBind)
     except:
         return 0
     else:
         self.listeners[(hostToBind, portToBind)] = listener
         if portToBind == 0:
             portToBind = listener.getHost()[2]  # The port
             return 1, struct.pack('>L', portToBind)
         else:
             return 1