Example #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");
        }
Example #2
0
        public LoginAttemptController(
            IUserAccountControllerFactory <TUserAccount> userAccountControllerFactory,
            IUserAccountRepositoryFactory <TUserAccount> userAccountRepositoryFactory,
            IBinomialLadderFilter binomialLadderFilter,
            MemoryUsageLimiter memoryUsageLimiter,
            BlockingAlgorithmOptions blockingOptions
            )
        {
            _options = blockingOptions;
            _binomialLadderFilter         = binomialLadderFilter;
            _userAccountRepositoryFactory = userAccountRepositoryFactory;
            _userAccountControllerFactory = userAccountControllerFactory;


            _recentIncorrectPasswords = new AgingMembershipSketch(blockingOptions.AgingMembershipSketchTables, blockingOptions.AgingMembershipSketchTableSize);

            _ipHistoryCache = new SelfLoadingCache <IPAddress, IpHistory>(address => new IpHistory(address, _options));

            memoryUsageLimiter.OnReduceMemoryUsageEventHandler += ReduceMemoryUsage;
        }
        /// <summary>
        /// Construct the controller.
        /// </summary>
        /// <param name="userAccountControllerFactory">A factory for creating IUserAccountController interfaces for managing user account records.</param>
        /// <param name="userAccountRepositoryFactory">A factory for creating IAccountRepository interfaces for obtaining user account records.</param>
        /// <param name="binomialLadderFilter">A binomial ladder frequency that the controller should use to track frequently-guessed passwords.</param>
        /// <param name="memoryUsageLimiter">A memory usage limiter that the controller should register into so that when memory is tight,
        /// the controller can do its part to free up cached items it may not need anymore.</param>
        /// <param name="blockingOptions">Configuration options.</param>
        public LoginAttemptController(
            IUserAccountControllerFactory <TUserAccount> userAccountControllerFactory,
            IUserAccountRepositoryFactory <TUserAccount> userAccountRepositoryFactory,
            IBinomialLadderFilter binomialLadderFilter,
            MemoryUsageLimiter memoryUsageLimiter,
            BlockingAlgorithmOptions blockingOptions
            )
        {
            // Copy parameters into the controller.
            _options = blockingOptions;
            _binomialLadderFilter         = binomialLadderFilter;
            _userAccountRepositoryFactory = userAccountRepositoryFactory;
            _userAccountControllerFactory = userAccountControllerFactory;

            // Create a membership sketch to track username/password pairs that have failed.
            _recentIncorrectPasswords = new AgingMembershipSketch(blockingOptions.AgingMembershipSketchTables, blockingOptions.AgingMembershipSketchTableSize);

            // Create a cache of records storing information about the behavior of IPs that have issued login attempts.
            _ipHistoryCache = new SelfLoadingCache <IPAddress, IpHistory>(address => new IpHistory(address, _options));

            // When memory is low, the memeory usage limiter should call the ReduceMemoryUsage method of this controller.
            memoryUsageLimiter.OnReduceMemoryUsageEventHandler += ReduceMemoryUsage;
        }
Example #4
0
        public Simulator(DebugLogger logger, string path, ExperimentalConfiguration myExperimentalConfiguration, SimulatedPasswords simPasswords)
        {
            _simPasswords = simPasswords;
            _logger       = logger;
            if (_Attempts == null)
            {
                _Attempts = new ConcurrentStreamWriter(path + "Attempts.txt");
            }

            _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>();
            _userAccountController = new SimulatedUserAccountController();

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

            //_logger.WriteStatus("Exiting Simulator constructor");
        }