def buildDeviceRedirectionChannel(self, mcs: MCSLayer, userID: int, channelID: int) -> MCSClientChannel: """ :param mcs: The MCS Layer to transport traffic :param userID: The mcs user that builds the channel :param channelID: The channel ID to use to communicate in that channel :return: MCSClientChannel that handles the Device redirection virtual channel traffic from the server to the MITM. """ # Create all necessary layers channel = MCSClientChannel(mcs, userID, channelID) securityLayer = self.createSecurityLayer() virtualChannelLayer = VirtualChannelLayer( activateShowProtocolFlag=False) deviceRedirectionLayer = DeviceRedirectionLayer() Layer.chain(channel, securityLayer, virtualChannelLayer, deviceRedirectionLayer) # Create and link the MITM Observer for the client side to the device redirection layer. self.deviceRedirectionObserver = PassiveFileStealerClient( deviceRedirectionLayer, self.recorder, self.log) deviceRedirectionLayer.addObserver(self.deviceRedirectionObserver) self.channelObservers[channelID] = self.deviceRedirectionObserver return channel
def buildClipboardChannel(self, mcs: MCSLayer, userID: int, channelID: int) -> MCSClientChannel: """ :param mcs: The MCS Layer to transport traffic :param userID: The mcs user that builds the channel :param channelID: The channel ID to use to communicate in that channel :return: MCSClientChannel that handles the Clipboard virtual channel traffic from the server to the MITM. """ # Create all necessary layers channel = MCSClientChannel(mcs, userID, channelID) securityLayer = self.createSecurityLayer() virtualChannelLayer = VirtualChannelLayer() clipboardLayer = ClipboardLayer() Layer.chain(channel, securityLayer, virtualChannelLayer, clipboardLayer) # Create and link the MITM Observer for the client side to the clipboard layer. activeClipboardObserver = ActiveClipboardStealer( clipboardLayer, self.recorder, self.log) clipboardLayer.addObserver(activeClipboardObserver) self.channelObservers[channelID] = activeClipboardObserver return channel
def buildVirtualChannel(self, mcs, userID, channelID) -> MCSClientChannel: channel = MCSClientChannel(mcs, userID, channelID) securityLayer = self.createSecurityLayer() rawLayer = RawLayer() Layer.chain(channel, securityLayer, rawLayer) observer = MITMVirtualChannelObserver(rawLayer) rawLayer.addObserver(observer) self.channelObservers[channelID] = observer return channel
def onChannelJoinConfirm(self, pdu: MCSChannelJoinConfirmPDU): """ If the channel join was successful, build a client and a server MCS channel and call the callback. :param pdu: the confirmation PDU """ if pdu.result == 0: clientChannel = MCSServerChannel(self.client, pdu.initiator, pdu.channelID) serverChannel = MCSClientChannel(self.server, pdu.initiator, pdu.channelID) self.clientChannels[pdu.channelID] = clientChannel self.serverChannels[pdu.channelID] = serverChannel self.buildChannelCallback(clientChannel, serverChannel) self.client.sendPDU(pdu)
def buildIOChannel(self, mcs: MCSLayer, userID: int, channelID: int) -> MCSClientChannel: encryptionMethod = self.serverData.security.encryptionMethod self.securityLayer = self.createSecurityLayer() self.securityLayer.createObserver( onLicensingDataReceived=self.onLicensingDataReceived) slowPathObserver = MITMSlowPathObserver(self.log, self.slowPathLayer) self.slowPathLayer.addObserver(slowPathObserver) self.slowPathLayer.addObserver(RecordingSlowPathObserver( self.recorder)) self.channelObservers[channelID] = slowPathObserver fastPathParser = createFastPathParser(self.useTLS, encryptionMethod, self.crypter, ParserMode.CLIENT) self.fastPathLayer = FastPathLayer(fastPathParser) self.fastPathObserver = MITMFastPathObserver(self.log, self.fastPathLayer) self.fastPathLayer.addObserver(self.fastPathObserver) self.fastPathLayer.addObserver( RecordingFastPathObserver(self.recorder, PlayerMessageType.FAST_PATH_OUTPUT)) channel = MCSClientChannel(mcs, userID, channelID) Layer.chain(channel, self.securityLayer, self.slowPathLayer) self.segmentation.attachLayer(SegmentationPDUType.FAST_PATH, self.fastPathLayer) if self.useTLS: self.securityLayer.securityHeaderExpected = True elif encryptionMethod != 0: self.log.debug("Sending Security Exchange") self.slowPathLayer.previous.sendSecurityExchange( self.securitySettings.encryptClientRandom()) return channel