예제 #1
0
    def onConfirmActive(self, pdu: ConfirmActivePDU):
        """
        Disable drawing orders and other unimplemented features.
        :param pdu: the confirm active PDU
        """

        # Force RDP server to send bitmap events instead of order events.
        pdu.parsedCapabilitySets[
            CapabilityType.
            CAPSTYPE_ORDER].orderFlags = OrderFlag.NEGOTIATEORDERSUPPORT | OrderFlag.ZEROBOUNDSDELTASSUPPORT
        pdu.parsedCapabilitySets[
            CapabilityType.CAPSTYPE_ORDER].orderSupport = b"\x00" * 32

        # Disable virtual channel compression
        if CapabilityType.CAPSTYPE_VIRTUALCHANNEL in pdu.parsedCapabilitySets:
            pdu.parsedCapabilitySets[
                CapabilityType.
                CAPSTYPE_VIRTUALCHANNEL].flags = VirtualChannelCompressionFlag.VCCAPS_NO_COMPR

        # Override the bitmap cache capability set with null values.
        if CapabilityType.CAPSTYPE_BITMAPCACHE in pdu.parsedCapabilitySets:
            pdu.parsedCapabilitySets[
                CapabilityType.CAPSTYPE_BITMAPCACHE] = Capability(
                    CapabilityType.CAPSTYPE_BITMAPCACHE, b"\x00" * 36)

        # Disable surface commands
        if CapabilityType.CAPSETTYPE_SURFACE_COMMANDS in pdu.parsedCapabilitySets:
            pdu.parsedCapabilitySets[
                CapabilityType.CAPSETTYPE_SURFACE_COMMANDS].cmdFlags = 0
예제 #2
0
    def parseCapabilitySets(self, capabilitySetsRaw, numberCapabilities):
        stream = BytesIO(capabilitySetsRaw)
        capabilitySets = {}
        # Do minimum parsing for every capability
        for i in range(numberCapabilities):
            capabilitySetType = Uint16LE.unpack(stream.read(2))
            lengthCapability = Uint16LE.unpack(stream.read(2))
            capabilityData = stream.read(lengthCapability - 4)
            capability = Capability(capabilitySetType, capabilityData)
            capabilitySets[CapabilityType(capabilitySetType)] = capability

        # Fully parse the General capability set
        capabilitySets[CapabilityType.CAPSTYPE_GENERAL] = \
            self.parseGeneralCapability(capabilitySets[CapabilityType.CAPSTYPE_GENERAL].rawData)

        # Fully parse the Glyph cache capability set
        if CapabilityType.CAPSTYPE_GLYPHCACHE in capabilitySets:
            capabilitySets[CapabilityType.CAPSTYPE_GLYPHCACHE] = \
                self.parseGlyphCacheCapability(capabilitySets[CapabilityType.CAPSTYPE_GLYPHCACHE].rawData)

        # If present, fully parse the offscreen cache capability set
        if CapabilityType.CAPSTYPE_OFFSCREENCACHE in capabilitySets:
            capabilitySets[CapabilityType.CAPSTYPE_OFFSCREENCACHE] = \
                self.parseOffscreenCacheCapability(capabilitySets[CapabilityType.CAPSTYPE_OFFSCREENCACHE].rawData)

        # If present, fully parse the surface commands cache capability set
        if CapabilityType.CAPSETTYPE_SURFACE_COMMANDS in capabilitySets:
            capabilitySets[CapabilityType.CAPSETTYPE_SURFACE_COMMANDS] = \
                self.parseSurfaceCommandsCapability(capabilitySets[CapabilityType.CAPSETTYPE_SURFACE_COMMANDS].rawData)

        # Fully parse the Bitmap capability set
        capabilitySets[CapabilityType.CAPSTYPE_BITMAP] = \
            self.parseBitmapCapability(capabilitySets[CapabilityType.CAPSTYPE_BITMAP].rawData)

        # Fully parse the Order capability set
        capabilitySets[
            CapabilityType.CAPSTYPE_ORDER] = self.parseOrderCapability(
                capabilitySets[CapabilityType.CAPSTYPE_ORDER].rawData)

        # Fully parse the VirtualChannel capability set
        if CapabilityType.CAPSTYPE_VIRTUALCHANNEL in capabilitySets:
            capabilitySets[
                CapabilityType.
                CAPSTYPE_VIRTUALCHANNEL] = self.parseVirtualChannelCapability(
                    capabilitySets[
                        CapabilityType.CAPSTYPE_VIRTUALCHANNEL].rawData)

        # Fully parse the Pointer capability set
        if CapabilityType.CAPSTYPE_POINTER in capabilitySets:
            capabilitySets[
                CapabilityType.CAPSTYPE_POINTER] = self.parsePointerCapability(
                    capabilitySets[CapabilityType.CAPSTYPE_POINTER].rawData)

        return capabilitySets
예제 #3
0
파일: SlowPathMITM.py 프로젝트: xuyi/pyrdp
    def onConfirmActive(self, pdu: ConfirmActivePDU):
        """
        Disable drawing orders and other unimplemented features.
        :param pdu: the confirm active PDU
        """

        if self.state.config.downgrade:

            # Disable surface commands
            if CapabilityType.CAPSETTYPE_SURFACE_COMMANDS in pdu.parsedCapabilitySets:
                pdu.parsedCapabilitySets[
                    CapabilityType.CAPSETTYPE_SURFACE_COMMANDS].cmdFlags = 0

            # Disable GDI if not explicitly requested.
            if not self.state.config.useGdi:
                # Force RDP server to send bitmap events instead of order events.
                pdu.parsedCapabilitySets[CapabilityType.CAPSTYPE_ORDER].orderFlags = \
                    OrderFlag.NEGOTIATEORDERSUPPORT | OrderFlag.ZEROBOUNDSDELTASSUPPORT
                pdu.parsedCapabilitySets[
                    CapabilityType.CAPSTYPE_ORDER].orderSupport = b"\x00" * 32

                # Override the bitmap cache capability set with null values.
                if CapabilityType.CAPSTYPE_BITMAPCACHE in pdu.parsedCapabilitySets:
                    pdu.parsedCapabilitySets[
                        CapabilityType.CAPSTYPE_BITMAPCACHE] = Capability(
                            CapabilityType.CAPSTYPE_BITMAPCACHE, b"\x00" * 36)
            else:
                # Disable NineGrid support (Not implemented in Player)
                if CapabilityType.CAPSTYPE_ORDER in pdu.parsedCapabilitySets:
                    orders = pdu.parsedCapabilitySets[
                        CapabilityType.CAPSTYPE_ORDER]
                    supported = bytearray(orders.orderSupport)
                    supported[Order.TS_NEG_DRAWNINEGRID_INDEX] = 0
                    orders.orderSupport = supported

                if CapabilityType.CAPSTYPE_DRAWNINEGRIDCACHE in pdu.parsedCapabilitySets:
                    pdu.parsedCapabilitySets[
                        CapabilityType.
                        CAPSTYPE_DRAWNINEGRIDCACHE].rawData = b"\x00" * 8

        # Disable virtual channel compression
        if CapabilityType.CAPSTYPE_VIRTUALCHANNEL in pdu.parsedCapabilitySets:
            pdu.parsedCapabilitySets[CapabilityType.CAPSTYPE_VIRTUALCHANNEL].flags = \
                VirtualChannelCompressionFlag.VCCAPS_NO_COMPR
예제 #4
0
파일: server.py 프로젝트: macdaliot/pyrdp
    def onConfirmActive(self, pdu):
        # Force RDP server to send bitmap events instead of order events.
        pdu.parsedCapabilitySets[CapabilityType.CAPSTYPE_ORDER].orderFlags = OrderFlag.NEGOTIATEORDERSUPPORT \
                                                                             | OrderFlag.ZEROBOUNDSDELTASSUPPORT
        pdu.parsedCapabilitySets[
            CapabilityType.CAPSTYPE_ORDER].orderSupport = b"\x00" * 32

        # Disable virtual channel compression
        if CapabilityType.CAPSTYPE_VIRTUALCHANNEL in pdu.parsedCapabilitySets:
            pdu.parsedCapabilitySets[
                CapabilityType.CAPSTYPE_VIRTUALCHANNEL].flags = 0

        # Override the bitmap cache capability set with null values.
        if CapabilityType.CAPSTYPE_BITMAPCACHE in pdu.parsedCapabilitySets:
            pdu.parsedCapabilitySets[CapabilityType.CAPSTYPE_BITMAPCACHE] =\
                Capability(CapabilityType.CAPSTYPE_BITMAPCACHE, b"\x00" * 36)

        # Disable surface commands
        if CapabilityType.CAPSETTYPE_SURFACE_COMMANDS in pdu.parsedCapabilitySets:
            pdu.parsedCapabilitySets[
                CapabilityType.CAPSETTYPE_SURFACE_COMMANDS].cmdFlags = 0