Example #1
0
        public static void Main(string[] args)
        {
            var predictor = new SubGenPredictor();
            int passwordLength = 0;

            Console.WriteLine("Enter in 6 passwords:");

            for (var i = 0; i < 6; i++)
            {
                var password = Console.ReadLine();
                passwordLength = password.Length;
                
                RecordPassword(predictor, password);
            }


            var possibleOutputs = new List<WeightedValue>[passwordLength];

            for (var i = 0; i < passwordLength; i++)
                possibleOutputs[i] = predictor.PredictWeightedNext(Password.AllChars.Length).ToList();

            List<string> possiblePasswords = GetPossiblePasswords(possibleOutputs, new int[passwordLength], 0);
            File.WriteAllLines("passwords.txt", possiblePasswords);

            Console.WriteLine($"{possiblePasswords.Count} possible next passwords written to passwords.txt");
            Console.ReadLine();
        }
Example #2
0
 private static void RecordPassword(SubGenPredictor predictor, string password)
 {
     foreach (char ch in password)
     {
         var index = Password.AllChars.IndexOf(ch);
         predictor.CollectNext(index, Password.AllChars.Length);
     }
 }
Example #3
0
 public RandomAuditor(Random random, SubGenPredictor predictor)
 {
     Random = random;
     Predictor = predictor;
     DebugOutput = false;
 }
Example #4
0
        public static void Test5()
        {
            var generator = new SimplePasswordGenerator(new SystemRandom(new Random()));
            var predictor = new SubGenPredictor();
            int passwordLength = 0;

            Console.WriteLine("Generating passwords...");

            for (var i = 0; i < 6; i++)
            {
                var password = generator.GeneratePassword();
                passwordLength = password.Length;
                Console.WriteLine(password);

                RecordPassword(predictor, password);
            }


            var possibleOutputs = new List<WeightedValue>[passwordLength];

            for (var i = 0; i < passwordLength; i++)
                possibleOutputs[i] = predictor.PredictWeightedNext(Password.AllChars.Length).ToList();

            List<string> possiblePasswords = GetPossiblePasswords(possibleOutputs, new int[passwordLength], 0);
            File.WriteAllLines("passwords.txt", possiblePasswords);

            Console.WriteLine($"{possiblePasswords.Count} possible next passwords written to passwords.txt");
            Console.WriteLine("Next password:"******"This password was not found in the list.");
            else
                Console.WriteLine($"Password was found at index {index} in the list.");

            Console.ReadLine();
        }
Example #5
0
        private static void Test()
        { 
            var random = new Random(42);
            var random2 = new Random(43);
            var predictor = new SubGenPredictor();


            for (var i = 0; i < 54; ++i)
            {
                var value = random.Next();
                var value2 = random2.Next();

                predictor.CollectNext(new[]
                {
                    new PossibleValue ( .5M, value ),
                    new PossibleValue ( .5M, value2 )
                });
                Console.WriteLine(string.Format("{0}\t{1}", value, value2));
            }

            Console.WriteLine(random.Next());
            predictor.Skip();

            for (var i = 0; i < 115; ++i)
            {
                var value = random.Next();
                var predicted = predictor.PredictNext(increment: false).ToList();
                var predictedStr = string.Join(", ", predicted);
                Console.WriteLine(string.Format("{0}\t{1}\t{2}", value == predicted.First().LowerBound, value, predictedStr));

                predictor.CollectNext(value);
            }

            Console.ReadLine();
        }
Example #6
0
        private static void Test2()
        { 
            var random = new Random(42);
            var predictor = new SubGenPredictor();
            var max = 10;
            var step = (double)max / Int32.MaxValue;

            for (var i = 0; i < 55; ++i)
            {
                var value = random.Next(max);
                predictor.CollectNext(value, max);
                var lastLaggers = string.Join(", ", predictor.LastLaggers);
                var lastLeaders = string.Join(", ", predictor.LastLeaders);
                Console.WriteLine(string.Format("{0}:{1}\t{2}\t{3}", i, value, lastLaggers, lastLeaders));
            }

            for (var i = 0; i < 110; ++i)
            {
                var value = random.Next(max);
                var rawPredicted = string.Join(", ", predictor.PredictNext(increment: false));
                    //.Select(p => $"[{p.LowerBound * step:F2}, {p.UpperBound * step:F2}]"));
                var predicted = predictor.PredictNext(max, increment: false).ToList();
                var predictedStr = string.Join(", ", predicted);
                Console.WriteLine(string.Format("{0}:{1}\t{2}\t{3}", i, value == predicted.First().LowerBound, value, predictedStr)); //\t{rawPredicted}");
                //Console.WriteLine($"{i}\t{value}\t{rawPredicted}");
                predictor.CollectNext(value, max);
            }

            Console.ReadLine();
        }