Exemple #1
0
        public void TestToString4()
        {
            var culture = CultureInfo.InvariantCulture;

            ElapsedTimeFormatter.ToString(TimeSpan.FromDays(1), culture)
            .Should().Be("1d 00:00:00.000");
        }
Exemple #2
0
        public void TestToString2()
        {
            var culture = CultureInfo.InvariantCulture;

            ElapsedTimeFormatter.ToString(TimeSpan.FromSeconds(1), culture)
            .Should().Be("00:00:01.000");
        }
Exemple #3
0
        public static void FindPassword(string hash, string salt, string input, string crackingMethod)
        {
            var    stopwatch     = new Stopwatch();
            string foundPassword = null;
            string algorithm     = "";

            switch (input)
            {
            case "1":
                algorithm = "SHA256";
                break;

            case "2":
                algorithm = "SHA512";
                break;

            case "3":
                algorithm = "PBKDF2-SHA256";
                break;

            case "4":
                algorithm = "Argon2";
                break;

            case "5":
                algorithm = "SHA1";
                break;

            default:
                Console.WriteLine("Neispravan unos.");
                return;
            }

            if (crackingMethod == "1")
            {
                WordlistUtility.CreateWordlist();

                stopwatch.Start();
                foundPassword = WordlistUtility.FindPasswordWithWordlist(hash, salt, algorithm);
            }
            else if (crackingMethod == "2")
            {
                Console.Write("\nMolimo da unesete karaktere za brute force metodu (ostavite prazno za defaultn-e vrijednosti): ");
                var    selectedChars = Console.ReadLine();
                char[] charArray     = null;

                if (!string.IsNullOrWhiteSpace(selectedChars))
                {
                    charArray = selectedChars.Distinct().ToArray();
                }

                int  estimatedLength = 0;
                bool parsed          = false;

                do
                {
                    Console.Write("\nMolimo da unesete dužinu lozinke (ostavite prazno ukoliko ne znate): ");
                    var estimatedSelectedLength = Console.ReadLine();

                    if (estimatedSelectedLength == "")
                    {
                        break;
                    }

                    parsed = int.TryParse(estimatedSelectedLength, out estimatedLength);
                } while (!parsed);

                stopwatch.Start();
                Console.WriteLine("U toku...");

                foundPassword = BruteForceUtility.FindPasswordWithBruteForce(hash, salt, algorithm, charArray, estimatedLength);
            }
            else
            {
                stopwatch.Stop();
                return;
            }

            stopwatch.Stop();

            var elapsedTimeFormatted = ElapsedTimeFormatter.FormatElapsedTime(stopwatch.Elapsed, "Završeno za");

            if (!string.IsNullOrEmpty(foundPassword))
            {
                Console.WriteLine($"\nPronađena lozinka je: {foundPassword}");
            }
            else
            {
                Console.WriteLine("\nŽao nam je, lozinka nije pronađena.");
            }

            Console.WriteLine($"Korišteni algoritam: {algorithm}");
            Console.WriteLine(elapsedTimeFormatted);
        }