コード例 #1
0
    def unpack(self, buf):
        # TPKT header
        self.tpkt = tpkt.TPKT(buf)
        if self.tpkt.v != 3:
            raise dpkt.UnpackError('invalid TPKT version')
        if self.tpkt.rsvd != 0:
            raise dpkt.UnpackError('invalid TPKT reserved value')
        n = self.tpkt.len - self.tpkt.__hdr_len__
        if n > len(self.tpkt.data):
            raise dpkt.UnpackError('invalid TPKT length')
        buf = self.tpkt.data

        # Q.931 payload
        dpkt.Packet.unpack(self, buf)
        buf = buf[self.__hdr_len__:]
        self.ref_val = buf[:self.ref_len]
        buf = buf[self.ref_len:]
        self.type = struct.unpack('B', buf[:1])[0]
        buf = buf[1:]

        # Information Elements
        l = []
        while buf:
            ie = self.IE(buf)
            l.append(ie)
            buf = buf[len(ie):]
        self.data = l
コード例 #2
0
ファイル: rdp.py プロジェクト: whitecheeks33/Dictator
    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)
コード例 #3
0
ファイル: rdp.py プロジェクト: whitecheeks33/Dictator
 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
コード例 #4
0
 def buildProtocol(self, addr):
     return tpkt.TPKT(tpdu.TPDU(mcs.MCS(pdu.PDU(self._mode))));