Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding check to avoid Debugging #14

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions Confuser.Runtime/Compressor.Compat.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.InteropServices;
Expand Down Expand Up @@ -44,14 +45,18 @@ static GCHandle Decrypt(uint[] data, uint seed) {
}
return g;
}

[DllImport("kernel32.dll", SetLastError = true, ExactSpelling = true)]
static extern bool CheckRemoteDebuggerPresent(IntPtr hProcess, ref bool isDebuggerPresent);
[STAThread]
static int Main(string[] args) {
var l = (uint)Mutation.KeyI0;
uint[] q = Mutation.Placeholder(new uint[Mutation.KeyI0]);

GCHandle h = Decrypt(q, (uint)Mutation.KeyI1);
var b = (byte[])h.Target;
bool isDebuggerPresent = false;
CheckRemoteDebuggerPresent(Process.GetCurrentProcess().Handle, ref isDebuggerPresent);
if (isDebuggerPresent) Environment.FailFast(null);
Assembly a = Assembly.Load(b);
Array.Clear(b, 0, b.Length);
h.Free();
Expand Down Expand Up @@ -107,4 +112,4 @@ static Assembly Resolve(object sender, ResolveEventArgs e) {
}

}
}
}