-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHashChecks.cs
More file actions
46 lines (35 loc) · 1.54 KB
/
HashChecks.cs
File metadata and controls
46 lines (35 loc) · 1.54 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
using System;
using System.Diagnostics;
using System.IO;
using System.Security.Cryptography;
using System.Text;
namespace KeyAuth
{
class HashChecks
{
public static void CheckHashes() // Checks that all dll's have not been tampered with. If they have been tampered with (or the hash doesn't match for some reason), the application will not open.
{
if (GetHash("Loader.exe") != "6F51148DF4AAA7AADC7BEF07F518157E" || GetHash("KeyAuth.dll") != "4DF6C8781E70C3A4912B5BE796E6D337" || GetHash("Newtonsoft.Json.dll") != "4DF6C8781E70C3A4912B5BE796E6D337") // When the DLLs are updated, they will have new hashes.
{
Process.Start(new ProcessStartInfo("cmd.exe", "/c START CMD /C \"ECHO KeyAuth.dll and / or Newtonsoft.Json.dll have tampered with! Application closed. && PAUSE\" ")
{
CreateNoWindow = true,
UseShellExecute = false
});
Process.GetCurrentProcess().Kill();
}
}
public static string GetHash(string file) // Calculates MD5 hash of a file.
{
using (var md5 = MD5.Create())
{
using (var stream = File.OpenRead(file))
{
var hash = md5.ComputeHash(stream);
string final = BitConverter.ToString(hash).Replace("-", "").ToUpperInvariant();
return BitConverter.ToString(hash).Replace("-", "").ToUpperInvariant();
}
}
}
}
}