Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Otros entornos y lenguajes > C++ Builder
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 01-06-2020
Avatar de aguml
aguml aguml is offline
Miembro
 
Registrado: may 2013
Posts: 885
Poder: 11
aguml Va por buen camino
Truco Antidebug con NtSetInformationThread no funciona

Hola amigos, estoy intentando añadir ese truco a un proyecto mio pero no detecta el debugger nunca. Estoy en Windows 10 x64 y lo tengo así:
Código PHP:
bool __fastcall TMyThread2::QueryNtSetInformationThread(void)
{
    
HMODULE NtDll;
    
NTSTATUS ntStat;
    
bool check false;
    
bool retval=false;
    
int ThreadHideFromDebugger 0x11;

    
NtDll LoadLibrary(L"ntdll.dll");
    
LONG (WINAPI *NtSetInformationThread)(HANDLE ThreadHandleULONG ThreadInformationClassPVOID ThreadInformationULONG ThreadInformationLength);
    
LONG (WINAPI *NtQueryInformationThread)(HANDLE ThreadHandleULONG ThreadInformationClassPVOID ThreadInformationULONG ThreadInformationLengthPULONG ReturnLength);
    *(
FARPROC *)&NtSetInformationThread GetProcAddress(NtDll"NtSetInformationThread");
    *(
FARPROC *)&NtQueryInformationThread GetProcAddress(NtDll"NtQueryInformationThread");

    
//invalid parameter
    
ntStat NtSetInformationThread(NULLThreadHideFromDebugger, &checksizeof(ULONG));
    if (
ntStat >= 0//it must fail
    
{
        
//Detectado con metodo 1
        
return true;
    }

    
//invalid handle
    
ntStat NtSetInformationThread((HANDLE)0xFFFFFThreadHideFromDebugger00);
    if (
ntStat >= 0//it must fail
    
{
        
//Detectado con metodo 2
        
return true;
    }

    
//En x32 si estamos depurandolo se cerrará directamente el proceso
    
ntStat NtSetInformationThread(NULLThreadHideFromDebugger00);

    
//only available >= VISTA
    
ntStat NtQueryInformationThread(NULLThreadHideFromDebugger, &checksizeof(bool), 0);
    if (
ntStat >= 0)
    {
        if (!
check)
        {
            
//Detectado con metodo 4
            
return true;
        }
        else
        {
            return 
false;
        }
    }
    return 
retval;

¿Que hago mal?
Responder Con Cita
  #2  
Antiguo 01-06-2020
Avatar de aguml
aguml aguml is offline
Miembro
 
Registrado: may 2013
Posts: 885
Poder: 11
aguml Va por buen camino
El original era así:
Código PHP:
bool __fastcall TMyThread2::QueryNtSetInformationThread(void)
{
    
HMODULE NtDll;
    
NTSTATUS ntStat;
    
bool check false;
    
bool retval=false;
    
int ThreadHideFromDebugger 0x11;

    
NtDll LoadLibrary(L"ntdll.dll");
    
LONG (WINAPI *NtSetInformationThread)(HANDLE ThreadHandleULONG ThreadInformationClassPVOID ThreadInformationULONG ThreadInformationLength);
    
LONG (WINAPI *NtQueryInformationThread)(HANDLE ThreadHandleULONG ThreadInformationClassPVOID ThreadInformationULONG ThreadInformationLengthPULONG ReturnLength);
    *(
FARPROC *)&NtSetInformationThread GetProcAddress(NtDll"NtSetInformationThread");
    *(
FARPROC *)&NtQueryInformationThread GetProcAddress(NtDll"NtQueryInformationThread");

    
//invalid parameter
    
ntStat NtSetInformationThread(NULLThreadHideFromDebugger, &checksizeof(ULONG));
    if (
ntStat >= 0//it must fail
    
{
        
//Detectado con metodo 1
        
return true;
    }

    
//invalid handle
    
ntStat NtSetInformationThread((HANDLE)0xFFFFFThreadHideFromDebugger00);
    if (
ntStat >= 0//it must fail
    
{
        
//Detectado con metodo 2
        
return true;
    }

    
//En x32 si estamos depurandolo se cerrará directamente el proceso
    
ntStat NtSetInformationThread(NULLThreadHideFromDebugger00);

    if (
ntStat >= 0)
    {
        
//only available >= VISTA
        
ntStat NtQueryInformationThread(NULLThreadHideFromDebugger, &checksizeof(bool), 0);
        if (
ntStat >= 0)
        {
            if (!
check)
            {
                
//Detectado con metodo 4
                
return true;
            }
            else
            {
                return 
false;
            }
        }
    }else{
        
//Detectado por metodo 3
        
return true;
    }

    return 
retval;

Pero siempre me decía que me había detectado con el método 3 aunque no hubiese depurador
Responder Con Cita
Respuesta



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
Implementar truco para antidebug en mi clase debugger aguml C++ Builder 2 01-06-2020 21:32:56
El truco "Enumerar recursos de red" no funciona en Delphi XE7 JoAnCa Varios 4 13-02-2017 22:15:06
funciona bien en windows 7 64b pero en XP no funciona ASAPLTDA Varios 5 06-05-2011 16:24:50


La franja horaria es GMT +2. Ahora son las 09:51:47.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi