Example #1
0
    def __init__(self,
                 colorDepth,
                 privateKeyFileName=None,
                 certificateFileName=None):
        """
        @param privateKeyFileName: file contain server private key
        @param certficiateFileName: file that contain public key
        @param colorDepth: 15, 16, 24
        """
        self._isReady = False
        #list of observer
        self._serverObserver = []
        #build RDP protocol stack
        self._pduLayer = pdu_layer.Server(self)
        #secure layer
        self._secLayer = sec.Server(self._pduLayer)
        #multi channel service
        self._mcsLayer = mcs.Server(self._secLayer)
        #transport pdu layer
        self._x224Layer = x224.Server(self._mcsLayer, privateKeyFileName,
                                      certificateFileName, False)
        #transport packet (protocol layer)
        self._tpktLayer = tpkt.TPKT(self._x224Layer)

        #fastpath stack
        self._pduLayer.initFastPath(self._secLayer)
        self._secLayer.initFastPath(self._tpktLayer)
        #set color depth of session
        self.setColorDepth(colorDepth)
    def test_tpkt_layer_recv_fastpath_ext_length(self):
        """
        @summary: test receive in fastpath case with extended length
        """
        class FastPathLayer(tpkt.IFastPathListener):
            def setFastPathSender(self, fastPathSender):
                pass

            def recvFastPath(self, secflag, fastPathS):
                fastPathS.readType(
                    type.String("test_tpkt_layer_recv_fastpath_ext_length",
                                constant=True))
                raise TPKTTest.TPKT_PASS()

        message = type.String("test_tpkt_layer_recv_fastpath_ext_length")

        s = type.Stream()
        s.writeType(
            (type.UInt8(tpkt.Action.FASTPATH_ACTION_FASTPATH),
             type.UInt16Be((type.sizeof(message) + 3) | 0x8000), message))

        layer = tpkt.TPKT(None)
        layer.initFastPath(FastPathLayer())
        layer.connect()
        self.assertRaises(TPKTTest.TPKT_PASS, layer.dataReceived, s.getvalue())
    def test_tpkt_layer_connect(self):
        """
        @summary: test forward connect event to presentation layer
        """
        class Presentation(object):
            def connect(self):
                raise TPKTTest.TPKT_PASS()

        layer = tpkt.TPKT(Presentation())
        self.assertRaises(TPKTTest.TPKT_PASS, layer.connect)
Example #4
0
 def __init__(self):
     #list of observer
     self._clientObserver = []
     #PDU layer
     self._pduLayer = pdu_layer.Client(self)
     #secure layer
     self._secLayer = sec.Client(self._pduLayer)
     #multi channel service
     self._mcsLayer = mcs.Client(self._secLayer)
     #transport pdu layer
     self._x224Layer = x224.Client(self._mcsLayer)
     #transport packet (protocol layer)
     self._tpktLayer = tpkt.TPKT(self._x224Layer)
     #fastpath stack
     self._pduLayer.initFastPath(self._secLayer)
     self._secLayer.initFastPath(self._tpktLayer)
     #is pdu layer is ready to send
     self._isReady = False
    def test_tpkt_layer_recv(self):
        """
        @summary: test receive in classic case
        """
        class Presentation(object):
            def connect(self):
                pass

            def recv(self, data):
                data.readType(
                    type.String("test_tpkt_layer_recv", constant=True))
                raise TPKTTest.TPKT_PASS()

        message = type.String("test_tpkt_layer_recv")

        s = type.Stream()
        s.writeType(
            (type.UInt8(tpkt.Action.FASTPATH_ACTION_X224), type.UInt8(),
             type.UInt16Be(type.sizeof(message) + 4), message))

        layer = tpkt.TPKT(Presentation())
        layer.connect()
        self.assertRaises(TPKTTest.TPKT_PASS, layer.dataReceived, s.getvalue())