Example #1
0
 def write(self, bytes, noLog = False):
     transport = self.transport.session.conn.transport
     for i in transport.interactors:
         i.sessionWrite(bytes)
     if transport.ttylog_open and not noLog:
         ttylog.ttylog_write(transport.ttylog_file, len(bytes),
             ttylog.TYPE_OUTPUT, time.time(), bytes)
     insults.ServerProtocol.write(self, bytes)
Example #2
0
 def dataReceived(self, data, noLog = False):
     transport = self.transport.session.conn.transport
     if transport.ttylog_open and not noLog:
         ttylog.ttylog_write(transport.ttylog_file, len(data),
             ttylog.TYPE_INPUT, time.time(), data)
     if transport.stdinlog_open and not noLog:
         f = file( transport.stdinlog_file, 'ab' )
         f.write(data)
         f.close
     insults.ServerProtocol.dataReceived(self, data)
Example #3
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.ttylog_file,len(bytes), ttylog.TYPE_INTERACT, time.time(), bytes)
                    
                bytes = struct.pack('>Q',len(bytes)) + bytes
                
                self.interacting.client.sendPacket(94, bytes)
Example #4
0
 def keystrokeReceived(self, keyID, modifier):
     transport = self.terminal.transport.session.conn.transport
     if type(keyID) == type(''):
         ttylog.ttylog_write(transport.ttylog_file, len(keyID),
             ttylog.TYPE_INPUT, time.time(), keyID)
     recvline.HistoricRecvLine.keystrokeReceived(self, keyID, modifier)
Example #5
0
 def interactTTY(self, ttylog_file, data):
     ttylog.ttylog_write(ttylog_file, len(data), ttylog.TYPE_INTERACT, time.time(), data)
Example #6
0
 def outputTTY(self, ttylog_file, data):
     ttylog.ttylog_write(ttylog_file, len(data), ttylog.TYPE_OUTPUT, time.time(), data)
Example #7
0
 def inputTTY(self, ttylog_file, data):
     ttylog.ttylog_write(ttylog_file, len(data), ttylog.TYPE_INPUT, time.time(), data)
Example #8
0
 def write(self, bytes, noLog = False):
     if self.ttylog_open and not noLog:
         ttylog.ttylog_write(self.ttylog_file, len(bytes),
             ttylog.DIR_WRITE, time.time(), bytes)
     insults.ServerProtocol.write(self, bytes)
Example #9
0
 def keystrokeReceived(self, keyID, modifier):
     if type(keyID) == type(''):
         ttylog.ttylog_write(self.terminal.ttylog_file, len(keyID),
             ttylog.DIR_READ, time.time(), keyID)
     recvline.HistoricRecvLine.keystrokeReceived(self, keyID, modifier)