def buildIOChannel(self, client: MCSServerChannel, server: MCSClientChannel): """ Build the MITM component for input and output. :param client: MCS channel for the client side :param server: MCS channel for the server side """ self.client.security = self.state.createSecurityLayer(ParserMode.SERVER, False) self.client.fastPath = self.state.createFastPathLayer(ParserMode.SERVER) self.server.security = self.state.createSecurityLayer(ParserMode.CLIENT, False) self.server.fastPath = self.state.createFastPathLayer(ParserMode.CLIENT) self.client.security.addObserver(SecurityLogger(self.getClientLog("security"))) self.client.fastPath.addObserver(FastPathLogger(self.getClientLog("fastpath"))) self.client.fastPath.addObserver(RecordingFastPathObserver(self.recorder, PlayerMessageType.FAST_PATH_INPUT)) self.server.security.addObserver(SecurityLogger(self.getServerLog("security"))) self.server.fastPath.addObserver(FastPathLogger(self.getServerLog("fastpath"))) self.server.fastPath.addObserver(RecordingFastPathObserver(self.recorder, PlayerMessageType.FAST_PATH_OUTPUT)) self.security = SecurityMITM(self.client.security, self.server.security, self.getLog("security"), self.config, self.state, self.recorder) self.fastPath = FastPathMITM(self.client.fastPath, self.server.fastPath) LayerChainItem.chain(client, self.client.security, self.client.slowPath) LayerChainItem.chain(server, self.server.security, self.server.slowPath) self.client.segmentation.attachLayer(SegmentationPDUType.FAST_PATH, self.client.fastPath) self.server.segmentation.attachLayer(SegmentationPDUType.FAST_PATH, self.server.fastPath)
def buildIOChannel(self, client: MCSServerChannel, server: MCSClientChannel): """ Build the MITM component for input and output. :param client: MCS channel for the client side :param server: MCS channel for the server side """ self.client.security = self.state.createSecurityLayer(ParserMode.SERVER, False) self.client.fastPath = self.state.createFastPathLayer(ParserMode.SERVER) self.server.security = self.state.createSecurityLayer(ParserMode.CLIENT, False) self.server.fastPath = self.state.createFastPathLayer(ParserMode.CLIENT) self.client.security.addObserver(SecurityLogger(self.getClientLog("security"))) self.client.fastPath.addObserver(FastPathLogger(self.getClientLog("fastpath"))) self.client.fastPath.addObserver(RecordingFastPathObserver(self.recorder, PlayerPDUType.FAST_PATH_INPUT)) self.server.security.addObserver(SecurityLogger(self.getServerLog("security"))) self.server.fastPath.addObserver(FastPathLogger(self.getServerLog("fastpath"))) self.server.fastPath.addObserver(RecordingFastPathObserver(self.recorder, PlayerPDUType.FAST_PATH_OUTPUT)) self.security = SecurityMITM(self.client.security, self.server.security, self.getLog("security"), self.config, self.state, self.recorder) self.fastPath = FastPathMITM(self.client.fastPath, self.server.fastPath, self.state, self.statCounter) if self.player.tcp.transport: self.attacker = AttackerMITM(self.client.fastPath, self.server.fastPath, self.player.player, self.log, self.state, self.recorder) if MCSChannelName.DEVICE_REDIRECTION in self.state.channelMap: deviceRedirectionChannel = self.state.channelMap[MCSChannelName.DEVICE_REDIRECTION] if deviceRedirectionChannel in self.channelMITMs: deviceRedirection: DeviceRedirectionMITM = self.channelMITMs[deviceRedirectionChannel] self.attacker.setDeviceRedirectionComponent(deviceRedirection) LayerChainItem.chain(client, self.client.security, self.client.slowPath) LayerChainItem.chain(server, self.server.security, self.server.slowPath) self.client.segmentation.attachLayer(SegmentationPDUType.FAST_PATH, self.client.fastPath) self.server.segmentation.attachLayer(SegmentationPDUType.FAST_PATH, self.server.fastPath) self.sendPayload()
def buildIOChannel(self, mcs: MCSLayer, userID: int, channelID: int) -> MCSServerChannel: encryptionMethod = self.serverData.security.encryptionMethod self.securityLayer = self.createSecurityLayer() self.securityLayer.createObserver( onClientInfoReceived=self.onClientInfoReceived, onSecurityExchangeReceived=self.onSecurityExchangeReceived, onLicensingDataReceived=self.onLicensingDataReceived) slowPathObserver = MITMSlowPathObserver( self.log, self.slowPathLayer, onConfirmActive=self.onConfirmActive) slowPathObserver.setDataHandler(SlowPathDataType.PDUTYPE2_INPUT, self.onInputPDUReceived) clientObserver = self.client.getChannelObserver(channelID) slowPathObserver.setPeer(clientObserver) self.slowPathLayer.addObserver(slowPathObserver) self.slowPathLayer.addObserver(RecordingSlowPathObserver( self.recorder)) fastPathParser = createFastPathParser(self.useTLS, encryptionMethod, self.crypter, ParserMode.SERVER) self.fastPathLayer = FastPathLayer(fastPathParser) fastPathObserver = MITMFastPathObserver(self.log, self.fastPathLayer) fastPathObserver.setPeer(self.client.getFastPathObserver()) self.fastPathLayer.addObserver(fastPathObserver) self.fastPathLayer.addObserver( RecordingFastPathObserver(self.recorder, PlayerMessageType.FAST_PATH_INPUT)) channel = MCSServerChannel(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 return channel
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