C# Advanced Anti Debugger

fr3dofficial

TG: fr3dofficial
Gold Üye
Katılım
16 May 2022
Mesajlar
182
Beğeniler
100
Uyarı: Kesin çözüm olmasada 5 farklı method ile programınız debug edilmesini engeller.

Özellikler
Windows API check
Debug Port check
.net framework Debugger check
Remote Debugger check
Ve son olarak Debugger DLL kontrolü yapmaktadır.
C#:
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;

namespace AntiDebugAdvanced
{
    class Program
    {
        [DllImport("kernel32.dll")]
        private static extern bool IsDebuggerPresent();

        [DllImport("ntdll.dll", SetLastError = true)]
        private static extern int NtQueryInformationProcess(IntPtr processHandle, int processInformationClass, ref int processInformation, int processInformationLength, ref int returnLength);

        [DllImport("kernel32.dll", SetLastError = true)]
        private static extern IntPtr LoadLibrary(string lpFileName);

        [DllImport("kernel32.dll", SetLastError = true)]
        private static extern IntPtr GetProcAddress(IntPtr hModule, string procName);

        [DllImport("kernel32.dll")]
        private static extern bool CheckRemoteDebuggerPresent(IntPtr hProcess, ref bool isDebuggerPresent);

        static void Main()
        {
            if (IsDebuggerPresent() || Debugger.IsAttached || CheckDebugger() || HasDebugDllsLoaded() || CheckRemoteDebugger())
            {
                Environment.Exit(1);
            }
        }

        private static bool CheckDebugger()
        {
            int isDebugged = 0, returnLength = 0;
            int status = NtQueryInformationProcess(Process.GetCurrentProcess().Handle, 7, ref isDebugged, Marshal.SizeOf(isDebugged), ref returnLength);
            return status == 0 && isDebugged != 0;
        }

        private static bool HasDebugDllsLoaded()
        {
            string[] debugDlls = { "SbieDll.dll", "dbghelp.dll", "ntdll.dll" };
            foreach (string dll in debugDlls)
            {
                if (LoadLibrary(dll) != IntPtr.Zero) return true;
            }
            return false;
        }

        private static bool CheckRemoteDebugger()
        {
            bool isDebuggerPresent = false;
            CheckRemoteDebuggerPresent(Process.GetCurrentProcess().Handle, ref isDebuggerPresent);
            return isDebuggerPresent;
        }
    }
}
 
Helal olsun! Mükemmel ingilizce mükemmel kodlama, başarılar!
 

  Şuanda konuyu görüntüleyen kullanıcılar


Üst Alt