Anti Debugger source small help >.<

Joined
Apr 13, 2012
Messages
535
Reaction score
32
Hello ,
I tried to add anti debugger and here is the code
Code:
unsigned long Ret, IsRemotePresent = 0, NtGlobalFlags = 0;
			const int ProcessDbgPort = 7;
			char IsDbgPresent1 = 0;
			BOOL IsDbgPresent = FALSE;

			if(IsDebuggerPresent())
			{
				ExitProcess(0);
			}
			__asm {
				 mov eax, fs:[30h]
				 mov al, [eax + 2h]
				 mov IsDbgPresent1, al
			}
			if(IsDbgPresent1)
			{
				ExitProcess(0);
			}
			CheckRemoteDebuggerPresent(GetCurrentProcess(), &IsDbgPresent);
			if(IsDbgPresent)
			{
				ExitProcess(0);
			}
			pfnNtQueryInformationProcess NtQueryInfoProcess = NULL;
			HMODULE hNtDll = LoadLibrary(TEXT("ntdll.dll"));
			if(hNtDll == NULL)
			{
			}
			NtQueryInfoProcess = (pfnNtQueryInformationProcess)GetProcAddress(hNtDll, "NtQueryInformationProcess");
			if(NtQueryInfoProcess == NULL)
			{
			}
			Ret = NtQueryInfoProcess(GetCurrentProcess(), ProcessDbgPort, &IsRemotePresent, sizeof(unsigned long), NULL);
			if(Ret == 0x00000000 && IsRemotePresent != 0)ExitProcess(0);
			__asm {
				mov eax, fs:[30h]
				mov eax, [eax + 68h]
				mov NtGlobalFlags, eax
			}
			if(NtGlobalFlags & 0x70)
			{
				ExitProcess(0);
			}
got it from here :
and its not working iam putting it in WinMain
please anyone help.
 
try this
Code:
void antidebug()
{
while(true)
{
unsigned long Ret, IsRemotePresent = 0, NtGlobalFlags = 0;
			const int ProcessDbgPort = 7;
			char IsDbgPresent1 = 0;
			BOOL IsDbgPresent = FALSE;


			if(IsDebuggerPresent())
			{
				ExitProcess(0);
			}
			__asm {
				 mov eax, fs:[30h]
				 mov al, [eax + 2h]
				 mov IsDbgPresent1, al
			}
			if(IsDbgPresent1)
			{
				ExitProcess(0);
			}
			CheckRemoteDebuggerPresent(GetCurrentProcess(), &IsDbgPresent);
			if(IsDbgPresent)
			{
				ExitProcess(0);
			}
			pfnNtQueryInformationProcess NtQueryInfoProcess = NULL;
			HMODULE hNtDll = LoadLibrary(TEXT("ntdll.dll"));
			if(hNtDll == NULL)
			{
			}
			NtQueryInfoProcess = (pfnNtQueryInformationProcess)GetProcAddress(hNtDll, "NtQueryInformationProcess");
			if(NtQueryInfoProcess == NULL)
			{
			}
			Ret = NtQueryInfoProcess(GetCurrentProcess(), ProcessDbgPort, &IsRemotePresent, sizeof(unsigned long), NULL);
			if(Ret == 0x00000000 && IsRemotePresent != 0)ExitProcess(0);
			__asm {
				mov eax, fs:[30h]
				mov eax, [eax + 68h]
				mov NtGlobalFlags, eax
			}
			if(NtGlobalFlags & 0x70)
			{
				ExitProcess(0);
			}
}


}


CreateThread(0, 0, (LPTHREAD_START_ROUTINE)antidebug, 0, 0, 0);
 
Upvote 0
Back