-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path14.linq
72 lines (65 loc) · 2.14 KB
/
14.linq
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
<Query Kind="Program">
<Namespace>System.Security.Cryptography</Namespace>
</Query>
static int _hashCount = 2017;
string _salt = "zpqevtbw";
int _targetCounter = 64;
void Main()
{
Dictionary<int, Tuple<char, bool>> triplets = new Dictionary<int, Tuple<char, bool>>();
int counter = 0;
for (int i = 0; i < int.MaxValue; i++)
{
int check = i-1001;
if (triplets.ContainsKey(check))
{
if (triplets[check].Item2)
{
counter++;
}
if (counter == _targetCounter)
{
check.Dump();
return;
}
triplets.Remove(check);
}
string key = _salt + i.ToString();
string hash = MD5Hash(key);
for (int j = 0; j < hash.Length - 4; j++)
{
if (triplets.Any(t => t.Value.Item1 == hash[j]) && hash[j] == hash[j + 1] && hash[j] == hash[j + 2] && hash[j] == hash[j + 3] && hash[j] == hash[j + 4])
{
int[] indecies = triplets.Where(kvp => kvp.Value.Item1 == hash[j]).Select(kvp => kvp.Key).ToArray();
foreach (int idx in indecies)
{
triplets[idx] = new Tuple<char, bool>(hash[j], true);
}
}
}
for (int j = 0; j < hash.Length - 2; j++)
{
if (hash[j] == hash[j+1] && hash[j] == hash[j+2])
{
triplets.Add(i, new Tuple<char, bool>(hash[j], false));
break;
}
}
}
}
public static string MD5Hash(string inputString)
{
string current = inputString;
using (var md5 = MD5.Create())
{
for (int j = 1; j <= _hashCount; j++)
{
var inputBytes = Encoding.UTF8.GetBytes(current.Trim().ToLower());
var hashBytes = md5.ComputeHash(inputBytes);
var sb = new StringBuilder();
for (var i = 0; i < hashBytes.Length; i++) sb.Append(hashBytes[i].ToString("x2"));
current = sb.ToString().ToLower();
}
}
return current;
}