Exemplo n.º 1
0
        public SimulatedPasswords(DebugLogger logger, ExperimentalConfiguration config)
        {
            _logger = logger;
            _logger.WriteStatus("Loading popular password file");
            LoadPasswordSelector(config.PasswordFrequencyFile);
            if (config.PopularPasswordsToRemoveFromDistribution > 0)
            {
                _passwordSelector = _passwordSelector.TrimToRemoveInitialItems(config.PopularPasswordsToRemoveFromDistribution);
            }

            _logger.WriteStatus("Loading passwords known to be common by the algorithm before the attack");
            LoadKnownPopularPasswords(config.PreviouslyKnownPopularPasswordFile);
            _logger.WriteStatus("Creating common password selector");
            _commonPasswordSelector = _passwordSelector.TrimToInitialItems(
                    (int)config.NumberOfPopularPasswordsForAttackerToExploit);
            _logger.WriteStatus("Finished creating common password selector");

            _logger.WriteStatus("Creating list of most common passwords");
            OrderedListOfMostCommonPasswords =
                _passwordSelector.GetItems();
            _logger.WriteStatus("Finished creating list of most common passwords");
        }
Exemplo n.º 2
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.º 3
0
 public SimulatedAccounts(IpPool ipPool, SimulatedPasswords simPasswords, DebugLogger logger)
 {
     _ipPool       = ipPool;
     _logger       = logger;
     _simPasswords = simPasswords;
 }
Exemplo n.º 4
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.º 5
0
 public SimulatedAccounts(IpPool ipPool, SimulatedPasswords simPasswords, DebugLogger logger)
 {
     _ipPool = ipPool;
     _logger = logger;
     _simPasswords = simPasswords;
 }
Exemplo n.º 6
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();
                }
            }
        }