Projects STRLCPY aardwolf Commits 4dcd9120
🤬
  • ■ ■ ■ ■ ■ ■
    aardwolf/extensions/RDPECLIP/channel.py
    skipped 36 lines
    37 37   self.__requested_format = None
    38 38   self.__current_clipboard_data:RDP_CLIPBOARD_DATA_TXT = None
    39 39   self.__channel_fragment_buffer = b''
     40 + self.__channel_writer_lock = asyncio.Lock()
    40 41   
    41 42   async def start(self):
    42 43   try:
    skipped 181 lines
    224 225   raise err
    225 226  
    226 227   async def fragment_and_send(self, data):
    227  - try:
    228  - if self.compression_needed is True:
    229  - raise NotImplementedError('Compression not implemented!')
    230  - i = 0
    231  - while(i <= len(data)):
    232  - flags = CHANNEL_FLAG.CHANNEL_FLAG_SHOW_PROTOCOL
    233  - chunk = data[i:i+1400]
    234  - if i == 0:
    235  - flags |= CHANNEL_FLAG.CHANNEL_FLAG_FIRST
    236  - # the first fragment must contain the length of the total data we want to send
    237  - length = len(data)
    238  - else:
    239  - # if it's not the first fragment then the length equals to the chunk's length
    240  - length = None
     228 + async with self.__channel_writer_lock:
     229 + try:
     230 + if self.compression_needed is True:
     231 + raise NotImplementedError('Compression not implemented!')
     232 + i = 0
     233 + while(i <= len(data)):
     234 + flags = CHANNEL_FLAG.CHANNEL_FLAG_SHOW_PROTOCOL
     235 + chunk = data[i:i+1400]
     236 + if i == 0:
     237 + flags |= CHANNEL_FLAG.CHANNEL_FLAG_FIRST
     238 + # the first fragment must contain the length of the total data we want to send
     239 + length = len(data)
     240 + else:
     241 + # if it's not the first fragment then the length equals to the chunk's length
     242 + length = None
    241 243  
    242  - i+= 1400
    243  - if i >= len(data):
    244  - flags |= CHANNEL_FLAG.CHANNEL_FLAG_LAST
    245  - packet = CHANNEL_PDU_HEADER.serialize_packet(flags, chunk, length = length)
     244 + i+= 1400
     245 + if i >= len(data):
     246 + flags |= CHANNEL_FLAG.CHANNEL_FLAG_LAST
     247 + packet = CHANNEL_PDU_HEADER.serialize_packet(flags, chunk, length = length)
    246 248   
    247  - sec_hdr = None
    248  - if self.connection.cryptolayer is not None:
    249  - sec_hdr = TS_SECURITY_HEADER()
    250  - sec_hdr.flags = SEC_HDR_FLAG.ENCRYPT
    251  - sec_hdr.flagsHi = 0
     249 + sec_hdr = None
     250 + if self.connection.cryptolayer is not None:
     251 + sec_hdr = TS_SECURITY_HEADER()
     252 + sec_hdr.flags = SEC_HDR_FLAG.ENCRYPT
     253 + sec_hdr.flagsHi = 0
    252 254   
    253  - await self.send_channel_data(packet, sec_hdr, None, None, False)
     255 + await self.send_channel_data(packet, sec_hdr, None, None, False)
    254 256   
    255  - return True, False
    256  - except Exception as e:
    257  - traceback.print_exc()
    258  - return None,e
     257 + return True, False
     258 + except Exception as e:
     259 + traceback.print_exc()
     260 + return None,e
    259 261  
    260 262   
    261 263   async def process_user_data(self, data):
    skipped 22 lines
Please wait...
Page is in error, reload to recover