Beispiel #1
0
    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)
Beispiel #2
0
    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
Beispiel #3
0
    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