Ejemplo n.º 1
0
    def write(self, bytes, noLog=False):
        transport = self.transport.session.conn.transport
        for i in transport.interactors:
            i.sessionWrite(bytes)
        if self.ttylog_open and not noLog:
            ttylog.ttylog_write(transport.ttylog_file, len(bytes), ttylog.TYPE_OUTPUT, time.time(), bytes)

        insults.ServerProtocol.write(self, bytes)
Ejemplo n.º 2
0
 def write(self, bytes, noLog=False):
     transport = self.transport.session.conn.transport
     for i in transport.interactors:
         i.sessionWrite(bytes)
     if self.ttylog_open and not noLog:
         ttylog.ttylog_write(transport.ttylog_file, len(bytes),
                             ttylog.TYPE_OUTPUT, time.time(), bytes)
     insults.ServerProtocol.write(self, bytes)
Ejemplo n.º 3
0
    def dataReceived(self, data, noLog=False):
        transport = self.transport.session.conn.transport
        if self.ttylog_open and not noLog:
            ttylog.ttylog_write(transport.ttylog_file, len(data), ttylog.TYPE_INPUT, time.time(), data)
        if self.stdinlog_open and not noLog:
            log.msg("Saving %s bytes to stdin log: %s" % (len(data), self.stdinlog_file))
            f = file(self.stdinlog_file, "ab")
            f.write(data)
            f.close

        insults.ServerProtocol.dataReceived(self, data)
Ejemplo n.º 4
0
 def dataReceived(self, data, noLog=False):
     transport = self.transport.session.conn.transport
     if self.ttylog_open and not noLog:
         ttylog.ttylog_write(transport.ttylog_file, len(data),
                             ttylog.TYPE_INPUT, time.time(), data)
     if self.stdinlog_open and not noLog:
         log.msg("Saving stdin log: %s" % self.stdinlog_file)
         f = file(self.stdinlog_file, 'ab')
         f.write(data)
         f.close
     insults.ServerProtocol.dataReceived(self, data)
Ejemplo n.º 5
0
    def applicationDataReceived(self, bytes):
        # in command mode, we want to echo characters and buffer the input
        if not self.interacting:
            self.transport.write(bytes)
            if bytes in ('\r', '\n'):
                self.transport.write('\n')
                pieces = self.cmdbuf.split(' ', 1)
                self.cmdbuf = ''
                cmd, args = pieces[0], ''
                if len(pieces) > 1:
                    args = pieces[1]
                try:
                    func = getattr(self, 'cmd_' + cmd)
                except AttributeError:
                    self.transport.write('** Unknown command.\r\n')
                    return
                func(args)
            else:
                self.cmdbuf += bytes

        # in non-command mode we are passing input to the session we are
        # watching
        else:
            for c in bytes:
                if ord(c) == 27:  # escape
                    self.interacting.delInteractor(self)
                    self.interacting = None
                    self.transport.write(
                        '\r\n** Interactive session closed.\r\n')
                    return
            if not self.readonly:
                if type(bytes) == type(''):
                    ttylog.ttylog_write(
                        self.interacting.
                        terminal.transport.session.conn.transport.ttylog_file,
                        len(bytes), ttylog.TYPE_INTERACT, time.time(), bytes)
                for c in bytes:
                    recvline.HistoricRecvLine.keystrokeReceived(
                        self.interacting, c, None)
Ejemplo n.º 6
0
    def applicationDataReceived(self, bytes):
        # in command mode, we want to echo characters and buffer the input
        if not self.interacting:
            self.transport.write(bytes)
            if bytes in ('\r', '\n'):
                self.transport.write('\n')
                pieces = self.cmdbuf.split(' ', 1)
                self.cmdbuf = ''
                cmd, args = pieces[0], ''
                if len(pieces) > 1:
                    args = pieces[1]
                try:
                    func = getattr(self, 'cmd_' + cmd)
                except AttributeError:
                    self.transport.write('** Unknown command.\r\n')
                    return
                func(args)
            else:
                self.cmdbuf += bytes

        # in non-command mode we are passing input to the session we are
        # watching
        else:
            for c in bytes:
                if ord(c) == 27: # escape
                    self.interacting.delInteractor(self)
                    self.interacting = None
                    self.transport.write(
                        '\r\n** Interactive session closed.\r\n')
                    return
            if not self.readonly:
                if type(bytes) == type(''):
                    ttylog.ttylog_write(
                        self.interacting.terminal.transport.session.conn.transport.ttylog_file,
                        len(bytes), ttylog.TYPE_INTERACT, time.time(), bytes)
                for c in bytes:
                    recvline.HistoricRecvLine.keystrokeReceived(
                        self.interacting, c, None)