Files
  • main.cs
  • main.exe
main.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
using System;
using System.Diagnostics;
using System.IO;

namespace Brute_Force_Attacker {
    class Program {
        public char firstchar = 'a';
        public char lasrchar = 'z';
        public int passwordLength = 6;
        public long tries = 0;
        public bool done = false;
        public string password = "hey";
        public void CreatePasswords(string keys) {
            if (keys == password) {
                done = true;
            }
            if (keys.Length == passwordLength || done == true) {
                return;
            }
            for (char c = firstchar; c <= lasrchar; c++) {
                tries++;
                CreatePasswords(keys + c);
            }
        }
        static void Main(string[] args) {
            Program program = new Program();
            Console.ForegroundColor = ConsoleColor.DarkRed;
            Console.WriteLine("Welcome to the C# Brute Force Password Cracker!");
            System.Threading.Thread.Sleep(3000);
            Console.Write("This program was created by ");
            Console.ForegroundColor = ConsoleColor.Cyan;
            Console.Write("CyanCoding");
            Console.ForegroundColor = ConsoleColor.DarkRed;
            Console.WriteLine(".");
            System.Threading.Thread.Sleep(2800);
            Console.WriteLine("Note that passwords found in under a second won't tell you how many passwords per second they got.");
            System.Threading.Thread.Sleep(5000);
            Console.WriteLine("Also, for those of you who aren't patient, I made it so that it only guesses at lowercase letters.");
            System.Threading.Thread.Sleep(5000);
            Console.ForegroundColor = ConsoleColor.DarkYellow;
            Console.Write("\nPlease enter your password > ");
            program.password = Convert.ToString(Console.ReadLine());
            program.password = program.password.ToLower();
            Console.ForegroundColor = ConsoleColor.DarkRed;
            Console.WriteLine("\nCracking your password...");
            Stopwatch timer = Stopwatch.StartNew();
            program.passwordLength = program.password.Length;
            program.CreatePasswords(string.Empty);
            timer.Stop();
            long elapsedMs = timer.ElapsedMilliseconds;
            double elapsedTime = elapsedMs / 1000;
            if (elapsedTime > 0) {
                Console.WriteLine("\n\nYour password has been found! Here are the statistics:");
                Console.WriteLine("----------------------------------");
                Console.WriteLine("Password: {0}", program.password);
                Console.WriteLine("Password length: {0}", program.passwordLength);
                Console.WriteLine("Tries: {0}", program.tries);
                string plural = "seconds";
                if (elapsedTime == 1) {
                    plural = "second";
                }
                Console.WriteLine("Time to crack: {0} {1}", elapsedTime, plural);
                Console.WriteLine("Passwords per second: {0}", (long)(program.tries / elapsedTime));
            }
            else {
                Console.WriteLine("\n\nYour password has been found! Here are the statistics:");
                Console.WriteLine("----------------------------------");
                Console.WriteLine("Password: {0}", program.password);
                Console.WriteLine("Password length: {0}", program.passwordLength);
                Console.WriteLine("Tries: {0}", program.tries);
                Console.WriteLine("Time to crack: {0} seconds", elapsedTime);
            }
            System.Threading.Thread.Sleep(5000);
            Console.ForegroundColor = ConsoleColor.DarkYellow;
            Console.Write("\n\nPress any key to close");
            Console.ReadKey();
        }
    }
}