def connectionLost(self, reason):
        """
        Fires on pre-authentication disconnects
        """
        self.setTimeout(None)
        TelnetTransport.connectionLost(self, reason)

        # close transport on backend
        if self.client and self.client.transport:
            self.client.transport.loseConnection()

        # signal that we're closing to the handler
        self.telnetHandler.close()

        if self.pool_interface:
            # free VM from pool (VM was used if auth was performed successfully)
            self.pool_interface.send_vm_free(self.telnetHandler.authDone)

            # close transport connection to pool
            self.pool_interface.transport.loseConnection()

        if self.startTime is not None:  # startTime is not set when auth fails
            duration = time.time() - self.startTime
            log.msg(eventid='cowrie.session.closed',
                    format='Connection lost after %(duration)d seconds',
                    duration=duration)
Beispiel #2
0
    def connectionMade(self):
        """
        """
        self.transportId = uuid.uuid4().hex[:12]
        sessionno = self.transport.sessionno

        self.startTime = time.time()
        try:
            self.setTimeout(CONFIG.getint('honeypot',
                                          'authentication_timeout'))
        except NoOptionError:
            self.setTimeout(120)

        log.msg(
            eventid='cowrie.session.connect',
            format=
            'New connection: %(src_ip)s:%(src_port)s (%(dst_ip)s:%(dst_port)s) [session: %(session)s]',
            src_ip=self.transport.getPeer().host,
            src_port=self.transport.getPeer().port,
            dst_ip=self.transport.getHost().host,
            dst_port=self.transport.getHost().port,
            session=self.transportId,
            sessionno='T{0}'.format(str(sessionno)),
            protocol='telnet')
        TelnetTransport.connectionMade(self)
Beispiel #3
0
 def connectionLost(self, reason):
     """
     Fires on pre-authentication disconnects
     """
     self.setTimeout(None)
     TelnetTransport.connectionLost(self, reason)
     duration = time.time() - self.startTime
     log.msg(eventid='cowrie.session.closed',
         format='Connection lost after %(duration)d seconds',
         duration=duration)
Beispiel #4
0
 def connectionLost(self, reason):
     """
     Fires on pre-authentication disconnects
     """
     self.setTimeout(None)
     TelnetTransport.connectionLost(self, reason)
     duration = time.time() - self.startTime
     log.msg(eventid='cowrie.session.closed',
             format='Connection lost after %(duration)d seconds',
             duration=duration)
Beispiel #5
0
    def connectionMade(self):
        self.transportId = uuid.uuid4().hex[:8]
        sessionno = self.transport.sessionno
        self.startTime = time.time()
        self.setTimeout(300)

        log.msg(eventid='cowrie.session.connect',
           format='New connection: %(src_ip)s:%(src_port)s (%(dst_ip)s:%(dst_port)s) [session: T%(sessionno)s]',
           src_ip=self.transport.getPeer().host, src_port=self.transport.getPeer().port,
           dst_ip=self.transport.getHost().host, dst_port=self.transport.getHost().port,
           session=self.transportId, sessionno='T'+str(sessionno))
        TelnetTransport.connectionMade(self)
Beispiel #6
0
    def makeService(self, options):

        backendServices = service.MultiService()

        clientManager = core.EngineClientManager()  #sessions
        clientManager.setServiceParent(backendServices)

        processManager = core.EngineProcessManager()
        processManager.setServiceParent(backendServices)

        backend = core.Backend(processManager, clientManager)
        backend.updateEngineTypes()

        backendEngineBus = core.EngineBus(backend)

        eng_proxy_factory = server.Site(BackendRoot(backend, backendEngineBus))
        internet.TCPServer(
            options['port'], eng_proxy_factory,
            interface=options['host']).setServiceParent(backendServices)

        if options['devel_mode']:
            from twisted.conch.manhole import ColoredManhole
            from twisted.conch.insults import insults
            from twisted.conch.telnet import TelnetTransport, TelnetBootstrapProtocol
            from twisted.internet import protocol

            f = protocol.ServerFactory()
            f.protocol = lambda: TelnetTransport(TelnetBootstrapProtocol,
                                                 insults.ServerProtocol,
                                                 ColoredManhole, globals())
            telnet_manhole = internet.TCPServer(6024, f)
            telnet_manhole.setServiceParent(backendServices)

        return backendServices
Beispiel #7
0
def _makeService(args):
    checker = checkers.InMemoryUsernamePasswordDatabaseDontUse(
        admin="password")

    f = protocol.ServerFactory()
    f.protocol = lambda: TelnetTransport(
        TelnetBootstrapProtocol, insults.ServerProtocol, args[
            'protocolFactory'], *args.get('protocolArgs', ()),
        **args.get('protocolKwArgs', {}))
    tsvc = internet.TCPServer(args['telnet'], f)

    def chainProtocolFactory():
        return insults.ServerProtocol(args['protocolFactory'],
                                      *args.get('protocolArgs', ()),
                                      **args.get('protocolKwArgs', {}))

    rlm = TerminalRealm()
    rlm.chainedProtocolFactory = chainProtocolFactory
    ptl = portal.Portal(rlm, [checker])
    f = ConchFactory(ptl)
    #csvc = internet.TCPServer(args['ssh'], f)

    m = service.MultiService()
    tsvc.setServiceParent(m)
    #csvc.setServiceParent(m)
    return m
Beispiel #8
0
 def _buildProtocol(self):
     return TelnetTransport(
         TelnetBootstrapProtocol,
         insults.ServerProtocol,
         _ManholeShell,
         dict(self.namespace),
     )
Beispiel #9
0
 def run_interface(config):
     factory = ServerFactory()
     factory.protocol = lambda: TelnetTransport(JunctionTelnetInterface)
     port = int(config['App']['TelnetInterfacePort'])
     logging.info("starting telnet cli interface on port %d" % port)
     service = TCPServer(port, factory)
     service.startService()
Beispiel #10
0
    def makeService(self, options):
        """
        This service is like the desktop, but is not responsible for
        controlling the kernel server process.
        """
        from codenode.frontend.search import search
        search.create_index()

        web_app_service = service.MultiService()


        web_resource = webResourceFactory(settings.MEDIA_ROOT)
        serverlog = options['server_log']
        web_resource_factory = server.Site(web_resource, logPath=serverlog)

        frontend_server = internet.TCPServer(options['port'], 
                                    web_resource_factory, 
                                    interface=options['host'])
        frontend_server.setServiceParent(web_app_service)

        if options['devel_mode']:
            from twisted.conch.manhole import ColoredManhole
            from twisted.conch.insults import insults
            from twisted.conch.telnet import TelnetTransport, TelnetBootstrapProtocol
            from twisted.internet import protocol

            f = protocol.ServerFactory()
            f.protocol = lambda: TelnetTransport(TelnetBootstrapProtocol,
                                            insults.ServerProtocol,
                                            ColoredManhole, globals())
            telnel_manhole = internet.TCPServer(6023, f)
            telnel_manhole.setServiceParent(web_app_service)
        return web_app_service
Beispiel #11
0
def make_service(args):
    def chain_protocol_factory():
        return insults.ServerProtocol(args['protocolFactory'],
                                      *args.get('protocolArgs', ()),
                                      **args.get('protocolKwArgs', {}))

    m = service.MultiService()

    # Telnet manhole
    if True:
        f = protocol.ServerFactory()
        f.protocol = lambda: TelnetTransport(
            TelnetBootstrapProtocol, insults.ServerProtocol, args[
                'protocolFactory'], *args.get('protocolArgs', ()),
            **args.get('protocolKwArgs', {}))
        tsvc = internet.TCPServer(args['telnet'], f)  # @UndefinedVariable
        tsvc.setServiceParent(m)

    # SSH manhole
    if False:
        checker = checkers.InMemoryUsernamePasswordDatabaseDontUse(
            user="******")
        rlm = TerminalRealm()
        rlm.chainedProtocolFactory = chain_protocol_factory
        ptl = portal.Portal(rlm, [checker])
        f = ConchFactory(ptl)
        csvc = internet.TCPServer(args['ssh'], f)  # @UndefinedVariable
        csvc.setServiceParent(m)

    return m
Beispiel #12
0
def start(_settings, _backend, telnet_port=8023):
    """
    Start telnet server
    """
    global settings
    global backend
    backend = _backend

    # Settings
    settings = _settings()

    # Thread sensitive interface for stdout/stdin
    std.setup()

    # Telnet
    telnet_factory = ServerFactory()
    telnet_factory.protocol = lambda: TelnetTransport(TelnetDeployer)

    # Handle signals
    def handle_sigint(signal, frame):
        if active_sessions:
            print 'Running, %i active session(s).' % len(active_sessions)
        else:
            print 'No active sessions, exiting'
            reactor.stop()

    signal.signal(signal.SIGINT, handle_sigint)

    # Run the reactor!
    print 'Listening telnet on localhost:%s...' % telnet_port

    reactor.listenTCP(telnet_port, telnet_factory)
    reactor.run()
Beispiel #13
0
def makeService(factory, port, *args, **kw):
    f = protocol.ServerFactory()
    f.protocol = lambda: TelnetTransport(TelnetBootstrapProtocol, insults.
                                         ServerProtocol, factory, *args, **kw)
    tsvc = internet.TCPServer(port, f)

    return tsvc
Beispiel #14
0
    def connectionMade(self):
        self.transportId = uuid.uuid4().hex[:12]
        sessionno = self.transport.sessionno

        self.startTime = time.time()
        self.setTimeout(CONFIG.getint('honeypot', 'authentication_timeout', fallback=120))

        log.msg(eventid='cowrie.session.connect',
                format='New connection: %(src_ip)s:%(src_port)s (%(dst_ip)s:%(dst_port)s) [session: %(session)s]',
                src_ip=self.transport.getPeer().host,
                src_port=self.transport.getPeer().port,
                dst_ip=self.transport.getHost().host,
                dst_port=self.transport.getHost().port,
                session=self.transportId,
                sessionno='T{0}'.format(str(sessionno)),
                protocol='telnet')
        TelnetTransport.connectionMade(self)
Beispiel #15
0
def main(reason, *args):
    Log.w(main.listeningPort)
    if main.listeningPort:
        return
    f = protocol.ServerFactory()
    f.protocol = lambda: TelnetTransport(TelnetBootstrapProtocol, insults.
                                         ServerProtocol, ColoredManhole)
    main.listeningPort = reactor.listenTCP(8007, f, interface='localhost')
Beispiel #16
0
    def connectionLost(self, reason):
        """
        Fires on pre-authentication disconnects
        """
        self.setTimeout(None)
        TelnetTransport.connectionLost(self, reason)

        # close transport on backend
        self.client.transport.loseConnection()

        # signal that we're closing to the handler
        self.telnetHandler.close()

        duration = time.time() - self.startTime
        log.msg(eventid='cowrie.session.closed',
                format='Connection lost after %(duration)d seconds',
                duration=duration)
Beispiel #17
0
 def getService(self):
     r = Realm()
     p = portal.Portal(r)
     f = protocol.ServerFactory()
     f.canaryservice = self
     f.logger = self.logger
     f.banner = self.banner
     f.protocol = lambda: TelnetTransport(AlertAuthTelnetProtocol, p)
     return internet.TCPServer(self.port, f, interface=self.listen_addr)
Beispiel #18
0
    def connectionMade(self):
        self.transportId = uuid.uuid4().hex[:12]
        sessionno = self.transport.sessionno

        self.peer_ip = self.transport.getPeer().host
        self.peer_port = self.transport.getPeer().port + 1
        self.local_ip = self.transport.getHost().host
        self.local_port = self.transport.getHost().port

        log.msg(
            eventid="cowrie.session.connect",
            format=
            "New connection: %(src_ip)s:%(src_port)s (%(dst_ip)s:%(dst_port)s) [session: %(session)s]",
            src_ip=self.transport.getPeer().host,
            src_port=self.transport.getPeer().port,
            dst_ip=self.transport.getHost().host,
            dst_port=self.transport.getHost().port,
            session=self.transportId,
            sessionno="T{}".format(str(sessionno)),
            protocol="telnet",
        )

        TelnetTransport.connectionMade(self)

        # if we have a pool connect to it and later request a backend, else just connect to a simple backend
        # when pool is set we can just test self.pool_interface to the same effect of getting the config
        proxy_backend = CowrieConfig().get("proxy",
                                           "backend",
                                           fallback="simple")

        if proxy_backend == "pool":
            # request a backend
            d = self.factory.pool_handler.request_interface()
            d.addCallback(self.pool_connection_success)
            d.addErrback(self.pool_connection_error)
        else:
            # simply a proxy, no pool
            backend_ip = CowrieConfig().get("proxy", "backend_telnet_host")
            backend_port = CowrieConfig().getint("proxy",
                                                 "backend_telnet_port")
            self.connect_to_backend(backend_ip, backend_port)
Beispiel #19
0
    def connectionMade(self):
        self.transportId = uuid.uuid4().hex[:12]
        sessionno = self.transport.sessionno

        self.startTime = time.time()
        self.setTimeout(CowrieConfig().getint('honeypot',
                                              'authentication_timeout',
                                              fallback=120))

        log.msg(
            eventid='cowrie.session.connect',
            format=
            'New connection: %(src_ip)s:%(src_port)s (%(dst_ip)s:%(dst_port)s) [session: %(session)s]',
            src_ip=self.transport.getPeer().host,
            src_port=self.transport.getPeer().port,
            dst_ip=self.transport.getHost().host,
            dst_port=self.transport.getHost().port,
            session=self.transportId,
            sessionno='T{}'.format(str(sessionno)),
            protocol='telnet')
        TelnetTransport.connectionMade(self)
Beispiel #20
0
def start(port=None, host=None, telnet_vars=None):
    from twisted.internet import reactor

    port = int(port) if port else 6023
    host = host or '127.0.0.1'
    telnet_vars = telnet_vars or {}

    factory = protocol.ServerFactory()
    factory.protocol = lambda: TelnetTransport(TelnetBootstrapProtocol, insults
                                               .ServerProtocol, ColoredManhole,
                                               telnet_vars)
    return reactor.listenTCP(port, factory, interface=host)
Beispiel #21
0
    def connectionMade(self):
        self.transportId = uuid.uuid4().hex[:12]
        sessionno = self.transport.sessionno

        self.startTime = time.time()
        self.setTimeout(
            CowrieConfig.getint("honeypot", "authentication_timeout", fallback=120)
        )

        log.msg(
            eventid="cowrie.session.connect",
            format="New connection: %(src_ip)s:%(src_port)s (%(dst_ip)s:%(dst_port)s) [session: %(session)s]",
            src_ip=self.transport.getPeer().host,
            src_port=self.transport.getPeer().port,
            dst_ip=self.transport.getHost().host,
            dst_port=self.transport.getHost().port,
            session=self.transportId,
            sessionno="T{}".format(str(sessionno)),
            protocol="telnet",
        )
        TelnetTransport.connectionMade(self)
Beispiel #22
0
 def __init__(self):
     print "Starting up network server.."
     #self.protocol is the TYPE of protocol which gets created
     #it's only the function which gets called, not the actual protocol
     self.parent = 0
     self.child = ServerFactory()
     self.child.protocol = lambda: TelnetTransport(MyProtocol)
     self.protocol = self.child.protocol
     self.child.id = 1
     self.child.clList = {}
     self.child.parent = self
     self.clList = self.child.clList
     print "Factory, protocol and class initialisation done."
Beispiel #23
0
    def makeDebugCLIService(self, args):
        """
        This is dangerous, and should only ever be enabled by explicit user config and only for non-production use

        :param args:
        :return:
        """

        f = protocol.ServerFactory()
        f.protocol = lambda: TelnetTransport(
            TelnetBootstrapProtocol, insults.ServerProtocol, args[
                'protocolFactory'], *args.get('protocolArgs', ()),
            **args.get('protocolKwArgs', {}))
        return internet.TCPServer(args['telnet'], f)
Beispiel #24
0
    def connectionMade(self):
        self.transportId = uuid.uuid4().hex[:12]
        sessionno = self.transport.sessionno

        self.startTime = time.time()
        self.setTimeout(CowrieConfig().getint('honeypot',
                                              'authentication_timeout',
                                              fallback=120))

        self.peer_ip = self.transport.getPeer().host
        self.peer_port = self.transport.getPeer().port + 1
        self.local_ip = self.transport.getHost().host
        self.local_port = self.transport.getHost().port

        # connection to the backend starts here
        client_factory = client_transport.BackendTelnetFactory()
        client_factory.server = self

        reactor.connectTCP(self.honey_ip,
                           self.honey_port,
                           client_factory,
                           bindAddress=('0.0.0.0', 0),
                           timeout=10)

        log.msg(
            eventid='cowrie.session.connect',
            format=
            'New connection: %(src_ip)s:%(src_port)s (%(dst_ip)s:%(dst_port)s) [session: %(session)s]',
            src_ip=self.transport.getPeer().host,
            src_port=self.transport.getPeer().port,
            dst_ip=self.transport.getHost().host,
            dst_port=self.transport.getHost().port,
            session=self.transportId,
            sessionno='T{0}'.format(str(sessionno)),
            protocol='telnet')
        TelnetTransport.connectionMade(self)
Beispiel #25
0
def start(root_node,
          auth_backend=None,
          port=8023,
          logfile=None,
          extra_loggers=None):
    """
    Start telnet server
    """
    # Set logging
    if logfile:
        logging.basicConfig(filename=logfile, level=logging.DEBUG)
    else:
        logging.basicConfig(filename='/dev/stdout', level=logging.DEBUG)

    # Thread sensitive interface for stdout/stdin
    std.setup()

    # Telnet
    factory = ServerFactory()
    factory.connectionPool = set()  # List of currently, active connections
    factory.protocol = lambda: TelnetTransport(TelnetDeployer)
    factory.root_node = root_node()
    factory.auth_backend = auth_backend
    factory.extra_loggers = extra_loggers or []

    # Handle signals
    def handle_sigint(signal, frame):
        if factory.connectionPool:
            logging.info('Running, %i active session(s).' %
                         len(factory.connectionPool))
        else:
            logging.info('No active sessions, exiting')
            reactor.stop()

    signal.signal(signal.SIGINT, handle_sigint)

    # Run the reactor!
    logging.info(
        'Listening for incoming telnet connections on localhost:%s...' % port)

    # Set process name
    suffix = (' --log "%s"' % logfile if logfile else '')
    setproctitle('deploy:%s telnet-server --port %i%s' %
                 (root_node.__class__.__name__, port, suffix))

    # Run server
    reactor.listenTCP(port, factory)
    reactor.run()
Beispiel #26
0
    def make_manhole (self, xmpp_message, room, nick, message):
        """
        Open up a manhole and announce our currentl ip.
        """

        # control args.
        args = \
        {
            'protocolFactory' : ColoredManhole,
            'protocolArgs'    : (None,),
            'telnet'          : 6023,
            'ssh'             : 6022,
        }

        # protocol factory.
        def chainProtocolFactory():
            return insults.ServerProtocol(
                args['protocolFactory'],
                *args.get('protocolArgs', ()),
                **args.get('protocolKwArgs', {}))

        # server factory.
        f          = protocol.ServerFactory()
        f.protocol = lambda: TelnetTransport(TelnetBootstrapProtocol,
                                             insults.ServerProtocol,
                                             args['protocolFactory'],
                                             *args.get('protocolArgs', ()),
                                             **args.get('protocolKwArgs', {}))

        # checker, realms.
        checker                    = checkers.InMemoryUsernamePasswordDatabaseDontUse(pedram="iampedram")
        tsvc                       = internet.TCPServer(args['telnet'], f)
        rlm                        = TerminalRealm()
        rlm.chainedProtocolFactory = chainProtocolFactory
        ptl                        = portal.Portal(rlm, [checker])
        f                          = ConchFactory(ptl)
        csvc                       = internet.TCPServer(args['ssh'], f)
        m                          = service.MultiService()
        application                = service.Application("Interactive Python Interpreter")

        # scaffold.
        tsvc.setServiceParent(m)
        csvc.setServiceParent(m)
        m.setServiceParent(application)

        # determine IP address and announce.
        ipaddr = requests.get("http://ifconfig.me/all.json").json()['ip_addr']
        return "(successful) manhole opened @ %s" % ipaddr
Beispiel #27
0
def run():
    initialize_logger(logging.INFO)
    factory = ServerFactory()
    factory.protocol = lambda: TelnetTransport(MudTelnetProtocol)
    endpoints.serverFromString(reactor, "tcp:8023").listen(factory)

    round_timer = task.LoopingCall(game_loop.perform_round)
    round_timer.start(game_loop.ROUND_TIME)

    db_timer = task.LoopingCall(game_loop.save_databases)
    db_timer.start(game_loop.DB_SAVE_TIME)

    heal_timer = task.LoopingCall(game_loop.perform_heal)
    heal_timer.start(game_loop.HEAL_TIME)

    regen_timer = task.LoopingCall(game_loop.perform_regen)
    regen_timer.start(game_loop.REGEN_TIME)

    print "running on port 8023..."
    reactor.run()
Beispiel #28
0
def genSSHProtocol(args):
    checker = Auth.LDAPChecker(Settings.LDAPServer, Settings.LDAPManager,
                               Settings.LDAPPass, Settings.LDAPBase)
    f = protocol.ServerFactory()
    f.protocol = lambda: TelnetTransport(
        TelnetBootstrapProtocol, insults.ServerProtocol, args[
            'protocolFactory'], *args.get('protocolArgs', ()),
        **args.get('protocolKwArgs', {}))

    #tsvc = internet.TCPServer(args['telnet'], f)

    def chainProtocolFactory():
        return insults.ServerProtocol(args['protocolFactory'],
                                      *args.get('protocolArgs', ()),
                                      **args.get('protocolKwArgs', {}))

    rlm = TerminalRealm()
    rlm.chainedProtocolFactory = chainProtocolFactory
    ptl = portal.Portal(rlm, [checker])
    f = ConchFactory(ptl)
    return f
Beispiel #29
0
    def makeService(self, options):
        """
        This service is like the desktop, but is not responsible for
        controlling the kernel server process.
        """
        from codenode.frontend.search import search
        search.create_index()

        web_app_service = service.MultiService()

        if options['devel_mode']:
            staticfiles = os.path.join(lib_path, 'frontend', 'static')
        else:
            staticfiles = options['static_files']
        datafiles = options['env_path'] + "/data/plot_images"  #XXX
        #Temporary hack
        if not os.path.exists(datafiles):
            os.mkdir(datafiles)
        web_resource = webResourceFactory(staticfiles, datafiles)
        serverlog = options['server_log']
        web_resource_factory = server.Site(web_resource, logPath=serverlog)

        frontend_server = internet.TCPServer(options['port'],
                                             web_resource_factory,
                                             interface=options['host'])
        frontend_server.setServiceParent(web_app_service)

        if options['devel_mode']:
            from twisted.conch.manhole import ColoredManhole
            from twisted.conch.insults import insults
            from twisted.conch.telnet import TelnetTransport, TelnetBootstrapProtocol
            from twisted.internet import protocol

            f = protocol.ServerFactory()
            f.protocol = lambda: TelnetTransport(TelnetBootstrapProtocol,
                                                 insults.ServerProtocol,
                                                 ColoredManhole, globals())
            telnel_manhole = internet.TCPServer(6023, f)
            telnel_manhole.setServiceParent(web_app_service)
        return web_app_service
Beispiel #30
0
 def connectionMade(self):
     TelnetTransport.connectionMade(self)
     self.factory.open_channels.append(self.protocol)
Beispiel #31
0
 def connectionLost(self, reason):
     self.factory.open_channels.remove(self.protocol)
     TelnetTransport.connectionLost(self, reason)
    def telent_server_main(self):
        _q_s = self

        class CustomTelnetProtocol(TelnetProtocol):
            _state = None
            _user = None
            _pass = None

            def connectionMade(self):
                self._state = None
                self._user = None
                self._pass = None
                self.transport.write(b'PC login: '******'server': 'telnet_server',
                        'action': 'connection',
                        'ip': self.transport.getPeer().host,
                        'port': self.transport.getPeer().port
                    }
                ])

            def dataReceived(self, data):
                data = data.strip()
                if self._state == b'Username':
                    self._user = data
                    self._state = b"Password"
                    self.transport.write(b'Password: '******'Password':
                    self._pass = data
                    if self._user == _q_s.username and self._pass == _q_s.password:
                        _q_s.logs.info([
                            "servers", {
                                'server': 'telnet_server',
                                'action': 'login',
                                'status': 'success',
                                'ip': self.transport.getPeer().host,
                                'port': self.transport.getPeer().port,
                                'username': _q_s.username.decode('utf-8'),
                                'password': _q_s.password.decode('utf-8')
                            }
                        ])
                    else:
                        _q_s.logs.info([
                            "servers", {
                                'server': 'telnet_server',
                                'action': 'login',
                                'status': 'failed',
                                'ip': self.transport.getPeer().host,
                                'port': self.transport.getPeer().port,
                                'username': self._user.decode('utf-8'),
                                'password': self._pass.decode('utf-8')
                            }
                        ])
                    self.transport.loseConnection()
                else:
                    self.transport.loseConnection()

            def connectionLost(self, reason):
                self._state = None
                self._user = None
                self._pass = None

        factory = Factory()
        factory.protocol = lambda: TelnetTransport(CustomTelnetProtocol)
        reactor.listenTCP(port=self.port, factory=factory, interface=self.ip)
        reactor.run()
Beispiel #33
0
def main(*args, **kwargs):
    f = protocol.ServerFactory()
    f.protocol = lambda: TelnetTransport(TelnetBootstrapProtocol, insults.
                                         ServerProtocol, ColoredManhole)
    reactor.listenTCP(8007, f, interface='localhost')
Beispiel #34
0
 def buildProtocol(self, addr):
     p = TelnetTransport(TelnetClient)
     p.factory = self
     return p
Beispiel #35
0
 def protocol():
     return TelnetTransport(self.protocol, self)
Beispiel #36
0
 def buildProtocol(self, addr):
 	p = TelnetTransport(MaestroClientProtocol)
     p.factory = self
     return p