This class tracks information about passwords to be used by the simulator. Specifically, it reads in a password distribution for simulating user's password choices.
Exemplo n.º 1
0
        //public void ReduceMemoryUsage(object sender, MemoryUsageLimiter.ReduceMemoryUsageEventParameters parameters)
        //{
        //_ipHistoryCache.RecoverSpace(parameters.FractionOfMemoryToTryToRemove);
        //}

        public Simulator(DebugLogger logger, string path, ExperimentalConfiguration myExperimentalConfiguration, SimulatedPasswords simPasswords)
        {
            _simPasswords = simPasswords;
            _logger       = logger;
            _AttackAttemptsWithValidPasswords = //System.IO.TextWriter.Synchronized
                                                new ConcurrentStreamWriter(path + "AttackAttemptsWithValidPasswords.txt");
            //(new StreamWriter(new FileStream(path + "AttackAttemptsWithValidPasswords.txt", FileMode.CreateNew, FileAccess.Write)));
            _LegitimateAttemptsWithValidPasswords = //System.IO.TextWriter.Synchronized
                                                    new ConcurrentStreamWriter(path + "LegitimateAttemptsWithValidPasswords.txt");
            //(new StreamWriter(new FileStream(path + "LegitiamteAttemptsWithValidPasswords.txt", FileMode.CreateNew, FileAccess.Write)));
            _OtherAttempts = //System.IO.TextWriter.Synchronized
                             new ConcurrentStreamWriter(path + "OtherAttempts.txt");
            //(new StreamWriter(new FileStream(path + "OtherAttempts.txt", FileMode.CreateNew, FileAccess.Write)));
            _logger.WriteStatus("Entered Simulator constructor");
            _experimentalConfiguration = myExperimentalConfiguration;
            BlockingAlgorithmOptions options = _experimentalConfiguration.BlockingOptions;

            _logger.WriteStatus("Creating binomial ladder");
            _binomialLadderFilter =
                new BinomialLadderFilter(options.NumberOfBitsInBinomialLadderFilter_N, options.HeightOfBinomialLadder_H);
            _ipHistoryCache        = new ConcurrentDictionary <IPAddress, SimIpHistory>(); // new SelfLoadingCache<IPAddress, SimIpHistory>(address => new SimIpHistory(options.NumberOfFailuresToTrackForGoingBackInTimeToIdentifyTypos));
            _userAccountController = new SimulatedUserAccountController();

            //_memoryUsageLimiter = new MemoryUsageLimiter();
            //_memoryUsageLimiter.OnReduceMemoryUsageEventHandler += ReduceMemoryUsage;

            _recentIncorrectPasswords = new AgingMembershipSketch(16, 128 * 1024);

            _logger.WriteStatus("Exiting Simulator constructor");
        }
 /// <summary>
 /// The attempt generator needs to know about the experimental configuration and have access to the sets of simulated accounts,
 /// IP addresses, and simulated passwords.
 /// </summary>
 /// <param name="experimentalConfiguration"></param>
 /// <param name="simAccounts"></param>
 /// <param name="ipPool"></param>
 /// <param name="simPasswords"></param>
 public SimulatedLoginAttemptGenerator(ExperimentalConfiguration experimentalConfiguration, SimulatedAccounts simAccounts, IpPool ipPool, SimulatedPasswords simPasswords)
 {
     _simAccounts = simAccounts;
     _experimentalConfiguration = experimentalConfiguration;
     _ipPool = ipPool;
     _simPasswords = simPasswords;
 }
 /// <summary>
 /// The attempt generator needs to know about the experimental configuration and have access to the sets of simulated accounts,
 /// IP addresses, and simulated passwords.
 /// </summary>
 /// <param name="experimentalConfiguration"></param>
 /// <param name="simAccounts"></param>
 /// <param name="ipPool"></param>
 /// <param name="simPasswords"></param>
 public SimulatedLoginAttemptGenerator(ExperimentalConfiguration experimentalConfiguration, SimulatedAccounts simAccounts, IpPool ipPool, SimulatedPasswords simPasswords)
 {
     _simAccounts = simAccounts;
     _experimentalConfiguration = experimentalConfiguration;
     _ipPool       = ipPool;
     _simPasswords = simPasswords;
 }
Exemplo n.º 4
0
        public static void RunExperimentalSweep(ExperimentalConfiguration[] configurations)
        {
            foreach (ExperimentalConfiguration config in configurations)
            {
                DateTime now     = DateTime.Now;
                string   dirName = config.OutputPath + config.OutputDirectoryName;
                Directory.CreateDirectory(dirName);
                string path = dirName + @"\";

                // Now that all of the parameters of the sweep have been set, run the simulation
                //TextWriter dataWriter = System.IO.TextWriter.Synchronized(new StreamWriter(path + "data.txt"));
                TextWriter errorWriter = //TextWriter.Synchronized
                                         (new StreamWriter(new FileStream(path + "error.txt", FileMode.CreateNew, FileAccess.Write)));
                DebugLogger logger = new DebugLogger(errorWriter);
                try
                {
                    SimulatedPasswords simPasswords = new SimulatedPasswords(logger, config);
                    Simulator          simulator    = new Simulator(logger, path, config, simPasswords);
                    simulator.Run();
                }
                catch (Exception e)
                {
                    lock (errorWriter)
                    {
                        while (e != null)
                        {
                            errorWriter.WriteLine(e.Message);
                            errorWriter.WriteLine(e.StackTrace);
                            errorWriter.WriteLine(e);
                            e = e.InnerException;
                        }
                        errorWriter.Flush();
                    }
                }
            }
        }
Exemplo n.º 5
0
        public static void RunExperimentalSweep(ExperimentalConfiguration[] configurations)
        {
            foreach (ExperimentalConfiguration config in configurations)
            {
                DateTime now = DateTime.Now;
                string dirName = config.OutputPath + config.OutputDirectoryName;
                Directory.CreateDirectory(dirName);
                string path = dirName + @"\";

                // Now that all of the parameters of the sweep have been set, run the simulation
                //TextWriter dataWriter = System.IO.TextWriter.Synchronized(new StreamWriter(path + "data.txt"));
                TextWriter errorWriter = //TextWriter.Synchronized
                    (new StreamWriter(new FileStream(path + "error.txt", FileMode.CreateNew, FileAccess.Write)));
                DebugLogger logger = new DebugLogger(errorWriter);
                try
                {
                    SimulatedPasswords simPasswords = new SimulatedPasswords(logger, config);
                    Simulator simulator = new Simulator(logger, path, config, simPasswords);
                    simulator.Run();
                }
                catch (Exception e)
                {
                    lock (errorWriter)
                    {
                        while (e != null)
                        {
                            errorWriter.WriteLine(e.Message);
                            errorWriter.WriteLine(e.StackTrace);
                            errorWriter.WriteLine(e);
                            e = e.InnerException;
                        }
                        errorWriter.Flush();
                    }
                }
            }
        }
Exemplo n.º 6
0
 public SimulatedAccounts(IpPool ipPool, SimulatedPasswords simPasswords, DebugLogger logger)
 {
     _ipPool       = ipPool;
     _logger       = logger;
     _simPasswords = simPasswords;
 }
Exemplo n.º 7
0
        //public void ReduceMemoryUsage(object sender, MemoryUsageLimiter.ReduceMemoryUsageEventParameters parameters)
        //{
            //_ipHistoryCache.RecoverSpace(parameters.FractionOfMemoryToTryToRemove);
        //}

        public Simulator(DebugLogger logger, string path, ExperimentalConfiguration myExperimentalConfiguration, SimulatedPasswords simPasswords)
        {
            
            _simPasswords = simPasswords;
            _logger = logger;
            _AttackAttemptsWithValidPasswords = //System.IO.TextWriter.Synchronized 
                new ConcurrentStreamWriter(path + "AttackAttemptsWithValidPasswords.txt");
                //(new StreamWriter(new FileStream(path + "AttackAttemptsWithValidPasswords.txt", FileMode.CreateNew, FileAccess.Write)));
            _LegitimateAttemptsWithValidPasswords = //System.IO.TextWriter.Synchronized
                new ConcurrentStreamWriter(path + "LegitimateAttemptsWithValidPasswords.txt");
            //(new StreamWriter(new FileStream(path + "LegitiamteAttemptsWithValidPasswords.txt", FileMode.CreateNew, FileAccess.Write)));
            _OtherAttempts = //System.IO.TextWriter.Synchronized
                new ConcurrentStreamWriter(path + "OtherAttempts.txt");
                //(new StreamWriter(new FileStream(path + "OtherAttempts.txt", FileMode.CreateNew, FileAccess.Write)));
            _logger.WriteStatus("Entered Simulator constructor");
            _experimentalConfiguration = myExperimentalConfiguration;
            BlockingAlgorithmOptions options = _experimentalConfiguration.BlockingOptions;
            
            _logger.WriteStatus("Creating binomial ladder");
            _binomialLadderFilter =
                new BinomialLadderFilter(options.NumberOfBitsInBinomialLadderFilter_N, options.HeightOfBinomialLadder_H);
            _ipHistoryCache = new ConcurrentDictionary<IPAddress, SimIpHistory>(); // new SelfLoadingCache<IPAddress, SimIpHistory>(address => new SimIpHistory(options.NumberOfFailuresToTrackForGoingBackInTimeToIdentifyTypos));
            _userAccountController = new SimulatedUserAccountController();

            //_memoryUsageLimiter = new MemoryUsageLimiter();
            //_memoryUsageLimiter.OnReduceMemoryUsageEventHandler += ReduceMemoryUsage;

            _recentIncorrectPasswords = new AgingMembershipSketch(16, 128 * 1024);

            _logger.WriteStatus("Exiting Simulator constructor");
        }
Exemplo n.º 8
0
 public SimulatedAccounts(IpPool ipPool, SimulatedPasswords simPasswords, DebugLogger logger)
 {
     _ipPool = ipPool;
     _logger = logger;
     _simPasswords = simPasswords;
 }
Exemplo n.º 9
0
        public static async Task RunExperimentalSweep(
            ExperimentalConfigurationFunction configurationDelegate,
            IParameterSweeper[] parameterSweeps = null,
            int startingTest = 0)
        {
            int totalTests = parameterSweeps == null ? 1 :
                             // Get the legnths of each dimension of the multi-dimensional parameter sweep
                             parameterSweeps.Select(ps => ps.GetParameterCount())
                             // Calculates the product of the number of parameters in each dimension
                             .Aggregate((runningProduct, nextFactor) => runningProduct * nextFactor);

            ExperimentalConfiguration baseConfig = new ExperimentalConfiguration();

            configurationDelegate(baseConfig);


            DateTime now     = DateTime.Now;
            string   dirName = baseConfig.OutputPath + baseConfig.OutputDirectoryName + "_Run_" + now.Month + "_" + now.Day + "_" + now.Hour + "_" + now.Minute;

            if (parameterSweeps != null)
            {
                Directory.CreateDirectory(dirName);
            }
            for (int testIndex = startingTest; testIndex < totalTests; testIndex++)
            {
                // Start with the default configuration from the provided configuration factory
                ExperimentalConfiguration config = new ExperimentalConfiguration();
                configurationDelegate(config);

                // Next set the parameters for this test in the swwep
                string path = dirName + (parameterSweeps == null ? "" : ("\\Expermient" + testIndex.ToString()));
                Directory.CreateDirectory(path);
                path += @"\";
                int parameterIndexer = testIndex;
                if (parameterSweeps != null)
                {
                    for (int dimension = parameterSweeps.Length - 1; dimension >= 0; dimension--)
                    {
                        IParameterSweeper sweep = parameterSweeps[dimension];
                        int parameterIndex      = parameterIndexer % sweep.GetParameterCount();
                        parameterIndexer /= sweep.GetParameterCount();
                        sweep.SetParameter(config, parameterIndex);
                        path += "_" + sweep.GetParameterString(parameterIndex).Replace(".", "_");
                    }
                }

                // Now that all of the parameters of the sweep have been set, run the simulation
                //TextWriter dataWriter = System.IO.TextWriter.Synchronized(new StreamWriter(path + "data.txt"));
                TextWriter errorWriter =  //TextWriter.Synchronized
                                         (new StreamWriter(new FileStream(path + "error.txt", FileMode.CreateNew, FileAccess.Write)));
                DebugLogger logger = new DebugLogger(errorWriter);
                try
                {
                    SimulatedPasswords simPasswords = new SimulatedPasswords(logger, config);
                    Simulator          simulator    = new Simulator(logger, path, config, simPasswords);
                    await simulator.Run();
                }
                catch (Exception e)
                {
                    while (e != null)
                    {
                        errorWriter.WriteLine(e.Message);
                        errorWriter.WriteLine(e.StackTrace);
                        errorWriter.WriteLine(e);
                        e = e.InnerException;
                    }
                    errorWriter.Flush();
                }
            }
        }