Exemple #1
0
    public int SnoopOn(string containerIdA, string containerIdB, string containerSnooping)
    {
        var tuple = _determinableTuple(containerIdA, containerIdB);

        if (!_networks.ContainsKey(tuple))
        {
            return((int)Errors.NotConnected);
        }

        var netName = _networks[tuple];

        VagrantController.DockerNetworkConnect(_containersIds[containerSnooping], netName);
        var ipa        = VagrantController.GetContainerIP(_containersIds[containerIdA], netName);
        var ipb        = VagrantController.GetContainerIP(_containersIds[containerIdB], netName);
        var ipAttacker = VagrantController.GetContainerIP(_containersIds[containerSnooping], netName);

        VagrantController.IptablesEavesdropOn(ipa, ipb, ipAttacker);
        return((int)Errors.OK);
    }
Exemple #2
0
    public int Connect(string containerIdA, string containerIdB)
    {
        if (!_containersIds.ContainsKey(containerIdA) || !_containersIds.ContainsKey(containerIdB))
        {
            return((int)Errors.NoSuchContainer);
        }

        var tuple = _determinableTuple(containerIdA, containerIdB);

        if (_networks.ContainsKey(tuple))
        {
            return((int)Errors.AlreadyConnected);
        }

        var netName = Convert.ToBase64String(new Guid().ToByteArray());

        _networks.Add(tuple, netName);

        VagrantController.DockerNetworkCreate(netName);
        VagrantController.DockerNetworkConnect(_containersIds[containerIdA], netName);
        VagrantController.DockerNetworkConnect(_containersIds[containerIdB], netName);

        return((int)Errors.OK);
    }