示例#1
0
文件: mcs.py 项目: ChrisTruncer/rdpy
 def recvChannelJoinConfirm(self, data):
     """
     @summary: Receive a channel join confirm from server
     client automata function
     @param data: {Stream}
     """
     opcode = UInt8()
     data.readType(opcode)
     
     if not self.readMCSPDUHeader(opcode.value, DomainMCSPDU.CHANNEL_JOIN_CONFIRM):
         raise InvalidExpectedDataException("Invalid MCS PDU : CHANNEL_JOIN_CONFIRM expected")
     
     confirm = per.readEnumerates(data)
     
     userId = per.readInteger16(data, Channel.MCS_USERCHANNEL_BASE)
     if self._userId != userId:
         raise InvalidExpectedDataException("Invalid MCS User Id")
     
     channelId = per.readInteger16(data)
     #must confirm global channel and user channel
     if (confirm != 0) and (channelId == Channel.MCS_GLOBAL_CHANNEL or channelId == self._userId):
         raise InvalidExpectedDataException("Server must confirm static channel")
     
     if confirm == 0:
         serverNet = self._serverSettings.getBlock(gcc.MessageType.SC_NET)
         for i in range(0, serverNet.channelCount.value):
             if channelId == serverNet.channelIdArray[i].value:
                 self._channels[channelId] = self._virtualChannels[i][1] 
     
     self.connectNextChannel()
示例#2
0
文件: mcs.py 项目: ChrisTruncer/rdpy
    def recvData(self, data):
        """
        @summary: Main receive method
        @param data: {Stream} 
        """
        opcode = UInt8()
        data.readType(opcode)
        
        if self.readMCSPDUHeader(opcode.value, DomainMCSPDU.DISCONNECT_PROVIDER_ULTIMATUM):
            log.info("MCS DISCONNECT_PROVIDER_ULTIMATUM")
            self._transport.close()
            return
        
        #client case
        elif not self.readMCSPDUHeader(opcode.value, self._receiveOpcode):
            raise InvalidExpectedDataException("Invalid expected MCS opcode receive data")
        
        #server user id
        per.readInteger16(data, Channel.MCS_USERCHANNEL_BASE)
        
        channelId = per.readInteger16(data)
        
        per.readEnumerates(data)       
        per.readLength(data)
        
        #channel id doesn't match a requested layer
        if not self._channels.has_key(channelId):
            log.error("receive data for an unconnected layer")
            return

        self._channels[channelId].recv(data) 
示例#3
0
    def recvChannelJoinRequest(self, data):
        """
        @summary: Receive for each client channel a request
        Send Channel Join Confirm or Connect upper layer when all channel are joined
        @param data: {Stream}
        
        """
        opcode = UInt8()
        data.readType(opcode)

        if not self.readMCSPDUHeader(opcode.value,
                                     DomainMCSPDU.CHANNEL_JOIN_REQUEST):
            raise InvalidExpectedDataException(
                "Invalid MCS PDU : CHANNEL_JOIN_REQUEST expected")

        userId = per.readInteger16(data, Channel.MCS_USERCHANNEL_BASE)
        if self._userId != userId:
            raise InvalidExpectedDataException("Invalid MCS User Id")

        channelId = per.readInteger16(data)
        #actually algo support virtual channel but RDPY have no virtual channel
        confirm = 0 if channelId in self._channels.keys(
        ) or channelId == self._userId else 1
        self.sendChannelJoinConfirm(channelId, confirm)
        self._nbChannelConfirmed += 1
        if self._nbChannelConfirmed == self._serverSettings.getBlock(
                gcc.MessageType.SC_NET).channelCount.value + 2:
            self.allChannelConnected()
示例#4
0
    def recvChannelJoinConfirm(self, data):
        """
        @summary: Receive a channel join confirm from server
        client automata function
        @param data: {Stream}
        """
        opcode = UInt8()
        data.readType(opcode)

        if not self.readMCSPDUHeader(opcode.value,
                                     DomainMCSPDU.CHANNEL_JOIN_CONFIRM):
            raise InvalidExpectedDataException(
                "Invalid MCS PDU : CHANNEL_JOIN_CONFIRM expected")

        confirm = per.readEnumerates(data)

        userId = per.readInteger16(data, Channel.MCS_USERCHANNEL_BASE)
        if self._userId != userId:
            raise InvalidExpectedDataException("Invalid MCS User Id")

        channelId = per.readInteger16(data)
        #must confirm global channel and user channel
        if (confirm != 0) and (channelId == Channel.MCS_GLOBAL_CHANNEL
                               or channelId == self._userId):
            raise InvalidExpectedDataException(
                "Server must confirm static channel")

        if confirm == 0:
            serverNet = self._serverSettings.getBlock(gcc.MessageType.SC_NET)
            for i in range(0, serverNet.channelCount.value):
                if channelId == serverNet.channelIdArray[i].value:
                    self._channels[channelId] = self._virtualChannels[i][1]

        self.connectNextChannel()
示例#5
0
    def recvData(self, data):
        """
        @summary: Main receive method
        @param data: {Stream} 
        """
        opcode = UInt8()
        data.readType(opcode)

        if self.readMCSPDUHeader(opcode.value,
                                 DomainMCSPDU.DISCONNECT_PROVIDER_ULTIMATUM):
            log.info("MCS DISCONNECT_PROVIDER_ULTIMATUM")
            self._transport.close()
            return

        #client case
        elif not self.readMCSPDUHeader(opcode.value, self._receiveOpcode):
            raise InvalidExpectedDataException(
                "Invalid expected MCS opcode receive data")

        #server user id
        per.readInteger16(data, Channel.MCS_USERCHANNEL_BASE)

        channelId = per.readInteger16(data)

        per.readEnumerates(data)
        per.readLength(data)

        #channel id doesn't match a requested layer
        if not self._channels.has_key(channelId):
            log.error("receive data for an unconnected layer")
            return

        self._channels[channelId].recv(data)
示例#6
0
def readConferenceCreateResponse(s):
    '''
    read response from server
    and return server settings read from this response
    @param s: Stream
    @return: ServerSettings 
    '''
    per.readChoice(s)
    per.readObjectIdentifier(s, t124_02_98_oid)
    per.readLength(s)
    per.readChoice(s)
    per.readInteger16(s, 1001)
    per.readInteger(s)
    per.readEnumerates(s)
    per.readNumberOfSet(s)
    per.readChoice(s)
    if not per.readOctetStream(s, h221_sc_key, 4):
        raise InvalidExpectedDataException("cannot read h221_sc_key")
    return readServerDataBlocks(s)
示例#7
0
文件: gcc.py 项目: anees042/rdpy
def readConferenceCreateResponse(s):
    '''
    read response from server
    and return server settings read from this response
    @param s: Stream
    @return: ServerSettings 
    '''
    per.readChoice(s)
    per.readObjectIdentifier(s, t124_02_98_oid)
    per.readLength(s)
    per.readChoice(s)
    per.readInteger16(s, 1001)
    per.readInteger(s)
    per.readEnumerates(s)
    per.readNumberOfSet(s)
    per.readChoice(s)
    if not per.readOctetStream(s, h221_sc_key, 4):
        raise InvalidExpectedDataException("cannot read h221_sc_key")
    return readServerDataBlocks(s)
示例#8
0
文件: gcc.py 项目: rafaeldrs/Darkbyte
def readConferenceCreateResponse(s):
    """
    @summary: Read response from server
    and return server settings read from this response
    @param s: Stream
    @return: ServerSettings 
    """
    per.readChoice(s)
    per.readObjectIdentifier(s, t124_02_98_oid)
    per.readLength(s)
    per.readChoice(s)
    per.readInteger16(s, 1001)
    per.readInteger(s)
    per.readEnumerates(s)
    per.readNumberOfSet(s)
    per.readChoice(s)
    if not per.readOctetStream(s, h221_sc_key, 4):
        raise InvalidExpectedDataException("cannot read h221_sc_key")

    length = per.readLength(s)
    serverSettings = Settings(readLen=CallableValue(length))
    s.readType(serverSettings)
    return serverSettings
示例#9
0
文件: gcc.py 项目: dnozay/rdpy
def readConferenceCreateResponse(s):
    """
    Read response from server
    and return server settings read from this response
    @param s: Stream
    @return: ServerSettings 
    """
    per.readChoice(s)
    per.readObjectIdentifier(s, t124_02_98_oid)
    per.readLength(s)
    per.readChoice(s)
    per.readInteger16(s, 1001)
    per.readInteger(s)
    per.readEnumerates(s)
    per.readNumberOfSet(s)
    per.readChoice(s)
    if not per.readOctetStream(s, h221_sc_key, 4):
        raise InvalidExpectedDataException("cannot read h221_sc_key")
    
    length = per.readLength(s)
    serverSettings = Settings(readLen = UInt32Le(length))
    s.readType(serverSettings)
    return serverSettings
示例#10
0
文件: mcs.py 项目: ChrisTruncer/rdpy
 def recvChannelJoinRequest(self, data):
     """
     @summary: Receive for each client channel a request
     Send Channel Join Confirm or Connect upper layer when all channel are joined
     @param data: {Stream}
     
     """
     opcode = UInt8()
     data.readType(opcode)
     
     if not self.readMCSPDUHeader(opcode.value, DomainMCSPDU.CHANNEL_JOIN_REQUEST):
         raise InvalidExpectedDataException("Invalid MCS PDU : CHANNEL_JOIN_REQUEST expected")
     
     userId = per.readInteger16(data, Channel.MCS_USERCHANNEL_BASE)
     if self._userId != userId:
         raise InvalidExpectedDataException("Invalid MCS User Id")
     
     channelId = per.readInteger16(data)
     #actually algo support virtual channel but RDPY have no virtual channel
     confirm = 0 if channelId in self._channels.keys() or channelId == self._userId else 1
     self.sendChannelJoinConfirm(channelId, confirm)
     self._nbChannelConfirmed += 1
     if self._nbChannelConfirmed == self._serverSettings.getBlock(gcc.MessageType.SC_NET).channelCount.value + 2:
         self.allChannelConnected()
示例#11
0
文件: mcs.py 项目: ChrisTruncer/rdpy
 def recvAttachUserConfirm(self, data):
     """
     @summary: Receive an attach user confirm
     Send Connect Channel
     @param data: {Stream}
     """
     opcode = UInt8()
     data.readType(opcode)
     
     if not self.readMCSPDUHeader(opcode.value, DomainMCSPDU.ATTACH_USER_CONFIRM):
         raise InvalidExpectedDataException("Invalid MCS PDU : ATTACH_USER_CONFIRM expected")
     
     if per.readEnumerates(data) != 0:
         raise InvalidExpectedDataException("Server reject user")
     
     self._userId = per.readInteger16(data, Channel.MCS_USERCHANNEL_BASE)
         
     self.connectNextChannel()
示例#12
0
文件: mcs.py 项目: zha0/rdpy
 def recvAttachUserConfirm(self, data):
     """
     @summary: Receive an attach user confirm
     Send Connect Channel
     @param data: {Stream}
     """
     opcode = UInt8()
     data.readType(opcode)
     
     if not self.readMCSPDUHeader(opcode.value, DomainMCSPDU.ATTACH_USER_CONFIRM):
         raise InvalidExpectedDataException("Invalid MCS PDU : ATTACH_USER_CONFIRM expected")
     
     if per.readEnumerates(data) != 0:
         raise InvalidExpectedDataException("Server reject user")
     
     self._userId = per.readInteger16(data, Channel.MCS_USERCHANNEL_BASE)
         
     self.connectNextChannel()