Beispiel #1
0
 def send(self, socket):
     command = Client.BINARY
     logger.info("~ sending ~ %r ~ %s" % (command, self.data))
     
     stream = BinaryStream(self.con)
     data = stream.write(self.sig, *self.data)
     if data:
         for d in data:
             stream.write_bytes(d)
     
     stream2 = BinaryStream(self.con)
     stream2.write('BI', self.command.id, len(stream))
     stream2.write_bytes(stream.data)
     
     data = stream2.data
     newstr = "id=" + self.con.to_mxit(self.con.id) + "\0cm=" + self.con.to_mxit(command.id) + "\0ms=" + data
     newstr = "ln=" + self.con.to_mxit(len(newstr)) + "\0" + newstr
     
     socket.sendall(newstr)
Beispiel #2
0
def read_mxm(data, password=None):
    if not data.startswith('MXM'):
        raise MxitException('Not an MXM file')
    
    stream = BinaryStream(None, data[3:])
    type, = stream.read('B')
    if type == 2:
        pass
    elif type == 6:
        if password:
            text = decrypt(password, stream.data)
            stream = BinaryStream(None, text)
        else:
            raise MxitException('Encrypted file, password required')
    else:
        raise MxitException('Unknown MXM file type')
    stream.read('I')    #should equal 4
    n, = stream.read('I')    # number of messages

    for i in range(n):
        a, b, sender, to, message, c = stream.read('IQSSSI')
        print "%s: %s" % (sender, message)