-
Notifications
You must be signed in to change notification settings - Fork 0
/
AntiDebugging.cs
41 lines (37 loc) · 1.07 KB
/
AntiDebugging.cs
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
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
namespace ArtemisSecurity
{
public static class AntiDebugging
{
[DllImport("kernel32.dll")]
private static extern bool IsDebuggerPresent();
public static void PreventDebugging()
{
if (IsDebuggerPresent() || Debugger.IsAttached)
{
Console.WriteLine("Debugger detected! Terminating...");
Environment.Exit(-1);
}
}
}
public static class AntiTampering
{
public static void ValidateIntegrity()
{
var currentHash = GetApplicationHash();
// Compare with a known good hash
if (currentHash != "KnownGoodHash")
{
Console.WriteLine("Application tampered with! Terminating...");
Environment.Exit(-1);
}
}
private static string GetApplicationHash()
{
// Implement your hashing logic to check integrity
return "ApplicationHash";
}
}
}