コード例 #1
0
ファイル: Program.cs プロジェクト: ThisTrick/PDF_Force
        private static List <string> GenerateBirthdayDictionary(StopwatchController stopwatch, DitionaryCreator ditionaryCreator)
        {
            List <string> dictionary;
            DateTime      startDate  = new DateTime(1960, 1, 1);
            DateTime      finishDate = DateTime.Now.AddYears(-10);

            Console.WriteLine($"Generate dictionary between {startDate.ToString("dd/MM/yyyy")} and {finishDate.ToString("dd/MM/yyyy")}");
            stopwatch.Start();
            dictionary = ditionaryCreator.GenerateForBirthday(startDate, finishDate);
            stopwatch.Stop();
            Console.WriteLine($"Working time: {stopwatch.Time}\tDictionary length: {dictionary.Count}");
            return(dictionary);
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: ThisTrick/PDF_Force
        private static void FindPassword(string[] args, List <string> dictionary, StopwatchController stopwatch)
        {
            if (dictionary is null || dictionary.Count < 1)
            {
                return;
            }
            Console.WriteLine("Write path of PDF File:");
            string pdfPath = Console.ReadLine();

            if (!File.Exists(pdfPath))
            {
                Console.WriteLine("404! 404! abort!");
                return;
            }
            if (!IsPasswordProtected(pdfPath))
            {
                Console.WriteLine("Doesn't appear to be password protected...");
                return;
            }
            stopwatch.Start();
            if (args.Any(a => a == "-p"))
            {
                Parallel.ForEach(dictionary, (str, pls) =>
                {
                    if (IsPasswordValid(pdfPath, GetBytes(str)))
                    {
                        Console.WriteLine("Correct password is: {0}", str);
                        stopwatch.Stop();
                        Console.WriteLine($"Working time: {stopwatch.Time}");
                        pls.Break();
                    }
                });
                return;
            }
            else
            {
                foreach (var password in dictionary)
                {
                    if (IsPasswordValid(pdfPath, GetBytes(password)))
                    {
                        Console.WriteLine("Correct password is: {0}", password);
                        stopwatch.Stop();
                        Console.WriteLine($"Working time: {stopwatch.Time}");
                        return;
                    }
                }
            }
            stopwatch.Stop();
            Console.WriteLine($"Password not find. Working time: {stopwatch.Time}");
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: ThisTrick/PDF_Force
        private static List <string> GenerateKeywordsDictionary(StopwatchController stopwatch, DitionaryCreator ditionaryCreator)
        {
            List <string> dictionary = new List <string>();
            string        str        = "";
            List <string> keywords   = new List <string>();

            while (true)
            {
                Console.WriteLine("Write keyword or stop for exit:");
                str = Console.ReadLine();
                if (str == "stop")
                {
                    break;
                }
                if (!string.IsNullOrEmpty(str))
                {
                    keywords.Add(str);
                }
            }
            stopwatch.Start();
            try
            {
                keywords   = ditionaryCreator.FirstCharUp(keywords);
                dictionary = ditionaryCreator.GenerateForKeywords(keywords, 2);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                stopwatch.Stop();
                Console.WriteLine($"Working time: {stopwatch.Time}\tKeywords: {keywords?.Count}\tDictionary length: {dictionary?.Count}");
            }
            return(dictionary);
        }