-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
34 lines (30 loc) · 1.32 KB
/
Program.cs
File metadata and controls
34 lines (30 loc) · 1.32 KB
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
namespace Bizness;
using System.IO;
using System.Text;
using System.Security.Cryptography;
class Program
{
static void Main(string[] args)
{
// Set properties, based on findings from the targetmachine:
string salt = "d";
string hashToCompare = "uP0_QaVBpDWFeo8-dRzDqRwXQ2I";
// Since SHA is based on a non-linear function, there is no decryption.
// For this reason we need to "HashAndCompare" the entries from our wordlist...
List<string> wordlist = new List<string>(File.ReadAllLines($"{System.Environment.CurrentDirectory}/rockyou.txt"));
foreach (string passwordToCompare in wordlist)
{
string saltAndPassword = string.Concat(salt, passwordToCompare);
byte[] hashFromSaltAndPassword = SHA1.HashData(Encoding.UTF8.GetBytes(saltAndPassword));
string hashAsBase64 = Convert.ToBase64String(hashFromSaltAndPassword);
// ... and bring it into the expected, comparable format :
string result = hashAsBase64.Replace("/", "_").Replace("+", "-").Replace("=", "");
if (result == hashToCompare)
{
Console.WriteLine($"Password found: {passwordToCompare}");
break;
}
}
Console.WriteLine("Done.");
}
}