summaryrefslogtreecommitdiff
path: root/WinKeyRecover/Program.cs
blob: ddf3d27c5cebf862f38787bdd2c5de33e0980ee5 (plain)
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
using System;
using System.IO;
using System.Xml;
using System.Text;
using System.Linq;
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Runtime.InteropServices;


namespace WinKeyRecover
{
	class Program
	{
		public static void Main()
		{
            // Pour 4 manquants liste a 390625 posssibilités pour 19 819 368 octets (20Mo)
            // Pour 5 manquants liste a 9765625  posssibilités pour 356 225 912 octets (357Mo) !!!
            //11F "TDC2B-NG8YF-JH2BQ-46JJW-J8F7G"

            IntPtr hModule = NativeMethods.LoadLibrary(".\\pidgenx2.dll");
			string fileXml = ".\\Win10pkeyconfig.xrm-ms";
            string keyTest = "TDC2B-NG2YF-****Q-46JJW-J8F7G";
			char[] patternChars = new char[]
			{
				'B', 'C', 'D', 'F', 'G',
				'H', 'J', 'K', 'M', 'N',
				'P', 'Q', 'R', 'T', 'V',
				'W', 'X', 'Y', '2', '3',
				'4', '6', '7', '8', '9'
			};

			CheckIsValid checkIsValid = new CheckIsValid();
			bool isValidKey = checkIsValid.CheckKey(patternChars, keyTest);

			if (isValidKey)
			{
				CountMissingChars countMissingChars = new CountMissingChars();
				int numberOfMissings = countMissingChars.Count(keyTest);

				GetMissingPositions getMissingPositions = new GetMissingPositions();
				List<int> positions = getMissingPositions.GetPositions(keyTest);

				GeneratePattern patternGenerator = new GeneratePattern();
				List<string> pattern = patternGenerator.Generate(patternChars, numberOfMissings);

				ReplaceMissings replaceMissings = new ReplaceMissings(keyTest, positions);
				CheckKey checkKey = new CheckKey(hModule, fileXml);
				SaveAsJson saveToJson = new SaveAsJson();

				List<List<string>> resultats = new List<List<string>>();
				for (int i = 0; i < pattern.Count; i++)
				{
					string key = replaceMissings.Replace(pattern[i]);

                    string result = checkKey.Check(key);
					if (result != "Invalid")
					{
						resultats.Add(new List<string>() { key, result });
                        saveToJson.Save(resultats);
                    }
					Console.WriteLine("Clés numéro: {0}/{1} Trouvés:{3}", i, pattern.Count(), resultats.Count());
                    Console.CursorTop -= 1;
                    Console.CursorLeft = 0;
                }

				checkKey.FreeMemory();
            }

            NativeMethods.FreeLibrary(hModule);

            Console.WriteLine("Fin.");
			Console.ReadLine();
		}
	}
}