-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
52 lines (44 loc) · 1.81 KB
/
Program.cs
File metadata and controls
52 lines (44 loc) · 1.81 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
using System;
using System.CommandLine;
using System.Diagnostics;
using System.IO;
namespace Celones.MicrosoftKeyTool
{
public static class Cruncher
{
public static int Main(string[] args)
{
var patternArgument = new Argument<string>(
name: "pattern",
description: "Microsoft product key pattern");
var configOption = new Option<FileInfo>(
name: "--config",
description: "XrML key configuration file",
getDefaultValue: () => new FileInfo("pkeyconfig.xrm-ms"));
var cmd = new RootCommand("Microsoft product key cruncher");
cmd.Add(patternArgument);
cmd.Add(configOption);
cmd.SetHandler((config, key) => Crunch(config, key), configOption, patternArgument);
return cmd.Invoke(args);
}
internal static int Crunch(FileInfo config, string pattern)
{
var generator = new KeyGenerator(pattern);
var checker = new KeyChecker(config.FullName);
var stopwatch = Stopwatch.StartNew();
for (int i = 1; i <= generator.PossibilitiesCount; i++)
{
var key = generator.GetNext();
Console.Write(key);
var valid = checker.IsValid(key, out var description);
Console.WriteLine(" - {0} [{1}]", valid ? "VALID" : "INVALID", description);
var elapsed = stopwatch.Elapsed;
var pace = elapsed / i;
var left = (generator.PossibilitiesCount - i) * pace;
Console.WriteLine("{0:dd\\.hh\\:mm\\:ss}, {1}/{2}, ETA: {3:dd\\.hh\\:mm\\:ss}", elapsed, i, generator.PossibilitiesCount, left);
Console.WriteLine();
}
return 0;
}
}
}