示例#1
0
    def parseClientCoreData(self, stream):
        stream = StrictStream(stream)

        # 128 bytes minimum (excluding header)
        version = RDPVersion(Uint32LE.unpack(stream))
        desktopWidth = Uint16LE.unpack(stream)
        desktopHeight = Uint16LE.unpack(stream)
        colorDepth = ColorDepth(Uint16LE.unpack(stream))
        sasSequence = Uint16LE.unpack(stream)
        keyboardLayout = Uint32LE.unpack(stream)
        clientBuild = Uint32LE.unpack(stream)
        clientName = decodeUTF16LE(stream.read(32))
        keyboardType = Uint32LE.unpack(stream)
        keyboardSubType = Uint32LE.unpack(stream)
        keyboardFunctionKey = Uint32LE.unpack(stream)
        imeFileName = stream.read(64)

        core = ClientCoreData(version, desktopWidth, desktopHeight, colorDepth,
                              sasSequence, keyboardLayout, clientBuild,
                              clientName, keyboardType, keyboardSubType,
                              keyboardFunctionKey, imeFileName)

        # Optional data
        # The optional fields are read in order. If one of them is not present, then all subsequent fields are also not present.
        try:
            core.postBeta2ColorDepth = Uint16LE.unpack(stream)
            core.clientProductId = Uint16LE.unpack(stream)
            core.serialNumber = Uint32LE.unpack(stream)
            core.highColorDepth = HighColorDepth(Uint16LE.unpack(stream))
            core.supportedColorDepths = Uint16LE.unpack(stream)
            core.earlyCapabilityFlags = Uint16LE.unpack(stream)
            core.clientDigProductId = decodeUTF16LE(stream.read(64))
            core.connectionType = ConnectionType(Uint8.unpack(stream))
            core.pad1octet = stream.read(1)
            core.serverSelectedProtocol = Uint32LE.unpack(stream)
            core.desktopPhysicalWidth = Uint32LE.unpack(stream)
            core.desktopPhysicalHeight = Uint32LE.unpack(stream)
            core.desktopOrientation = DesktopOrientation(
                Uint16LE.unpack(stream))
            core.desktopScaleFactor = Uint32LE.unpack(stream)
            core.deviceScaleFactor = Uint32LE.unpack(stream)
        except EOFError:
            # The stream has reached the end, we don't have any more optional fields. This exception can be ignored.
            pass

        return core
示例#2
0
    def parseServerSecurityData(self, stream):
        stream = StrictStream(stream)
        encryptionMethod = EncryptionMethod(Uint32LE.unpack(stream))
        encryptionLevel = EncryptionLevel(Uint32LE.unpack(stream))
        serverRandom = None
        serverCertificate = None

        try:
            serverRandomLength = Uint32LE.unpack(stream)
            serverCertificateLength = Uint32LE.unpack(stream)
            serverRandom = stream.read(serverRandomLength)
            serverCertificate = stream.read(serverCertificateLength)
            serverCertificate = self.parseServerCertificate(serverCertificate)
        except EOFError:
            pass

        return ServerSecurityData(encryptionMethod, encryptionLevel, serverRandom, serverCertificate)