SlideShare a Scribd company logo
1 of 61
Anti-Debugging
         A Developers Viewpoint

March 13, 2008
Presenter Background

 Currently
 – Sr. Security Researcher for Veracode, Inc.
 Previously
 – Security Consultant - Symantec
 – Security Consultant - @Stake
 – Incident Response and Forensics Handler – US Government
 Wishes He Was
 – Infinitely Rich
 – Personal Trainer to hot Hollywood starlets
 – General all-around rockstar
What we will cover…
 Definition of Problem Statement and Terms
 Why Bother?
 – Isn’t this a futile effort?
 Standing On The Shoulders of Giants
 – Brief reference of anti-debugging
 Classes of Anti-Debugging Methods
 – The six styles of anti-debug fu
 Some Known Anti-Debugging Methods
 – Not enough time to cover them all
Problem Statement and
Definition of Terms
Problem Statement


     Anti-debugging methods are
  consistently presented as machine
code or assembly language constructs
making knowledge transfer difficult and
    limiting widespread use of the
              techniques.
Let’s Do An Experiment


 Can you tell what the following code
   does in five seconds or less?

              Be Honest!
Assembly Dump
push ebp
mov ebp, esp                         loc_411400:           ; CODE XREF: antidebug(void)+2Fj
sub esp, 0C0h                        mov esi, esp
push ebx                             push 0        ; uType
push esi                             push offset aNoDebugger
push edi                             push offset aNoDebuggerDete
lea edi, [ebp+var_C0]                push 0        ; hWnd
mov ecx, 30h                         call ds:__imp__MessageBoxW@16
mov eax, 0CCCCCCCCh                  cmp esi, esp
rep stosd                            j___RTC_CheckEsp
mov esi, esp
call ds:__imp__IsDebuggerPresent@0   loc_41141D:           ; CODE XREF: antidebug(void)+4Ej
cmp esi, esp                         pop edi
call j___RTC_CheckEsp                pop esi
test eax, eax                        pop ebx
jz short loc_411400                  add esp, 0C0h
mov esi, esp                         cmp ebp, esp
push 0         ; uType               call j___RTC_CheckEsp
push offset Caption                  mov esp, ebp
push offset Text                     pop ebp
push 0         ; hWnd                Retn
call ds:__imp__MessageBoxW@16        antidebug@@YAXXZ endp
cmp esi, esp
call j___RTC_CheckEsp
short loc_41141D
Assembly Dump
Assembly Dump – Highlight Important Bits
var_C0 = byte ptr -0C0h                        call        j___RTC_CheckEsp
push           ebp                             jmp         short loc_41141D
mov            ebp, esp
sub            esp, 0C0h                       loc_411400:
Push           ebx                             mov         esi, esp
Push           esi                             push        0 ; uType
Push           edi                             push        offset aNoDebugger
lea            edi, [ebp+var_C0]               push        offset aNoDebuggerDete
mov            ecx, 30h                        push        0 ; hWnd
mov            eax, 0CCCCCCCCh                 call        ds:__imp__MessageBoxW@16
Rep stosd                                      cmp         esi, esp
mov            esi, esp                        call        j___RTC_CheckEsp
Call           ds:__imp__IsDebuggerPresent@0   loc_41141D:
cmp            esi, esp                        pop         edi
Callj___RTC_CheckEsp                           pop         esi
Test           eax, eax                        pop         ebx
jz             short loc_411400                add         esp, 0C0h
mov            esi, esp                        cmp         ebp, esp
push           0 ; uType                       call        j___RTC_CheckEsp
push           offset Caption                  mov         esp, ebp
push           offset Text                     pop         ebp
push           0 ; hWnd                        Retn
call           ds:__imp__MessageBoxW@16        ?antidebug@@YAXXZ endp
cmp            esi, esp
Assembly Dump
How About In C


 if (IsDebuggerPresent())
 {
    MessageBox(NULL, L"Debugger Detected Via
        IsDebuggerPresent", L"Debugger Detected", MB_OK);
 } else
 {
    MessageBox(NULL, L“No Debugger Detected“, L“No Debugger ",
        MB_OK);
 }
Definition of Terms

 Debugger (Debugging)
  – The act of detecting and removing bugs in an application.


 Anti-Debugging
  – Anti-debugging is the implementation of one or more
    techniques within computer code that hinders attempts at
    reverse engineering or debugging a target process.
Definition of Terms

 Dumping
  – Dumping of a running process in memory to disk so
    that the image can be executed as a separate binary.


 Anti-Dumping
  – Technique that is used to inhibit the dumping of a
    running process from memory to disk
Definition of Terms

 Anti-Anti-Debugging
  – Techniques used to detect and bypass anti-debugging
    efforts
 Anti-Anti-Dumping
  – Techniques used to detect and bypass anti-dumping
    efforts.


 Anti-Anti-Anti-…. You get the picture
Why Bother?


Isn’t this a futile effort
Why Should I Care?

 Protecting your intellectual property
 – Laws can’t possibly work
     Neither do EULA or other soft methods
 – Slow down subversion of software registration
     Cracking
 – Impede application feature and code theft
 Low cost
 – Short code segments equals quick implementation
 – Write a basic anti-debugging library for reuse
Why Should I Care?

 Raise the bar
 – Implement multiple layers of defense
 – Makes reversing an arduous task
 – It’s no longer as simple as a debugger + disassembler + time
 Malware analysis
 – Knowledge of anti-debugging techniques can help your incident
   response and analysis
 – Debug the random binary found on your accounting system
 – Implement IDS/IPS signatures in shorter timeframes
 Exercise the brain
 – Keeps the synapses firing
 – Implementation (and bypass) is FUN!
Standing On the Shoulders Of Giants



A Brief Reference of Anti-Debugging
References

 Bania, P, “Antidebugging for the (m)asses - protecting the env.”
 Brulez, N., “Crimeware Anti-Reverse Engineering Uncovered”
 “Lord Julus”, “Anti-Debugger and Anti-Emulator Lair”
 Liston, T., and Skoudis, E., “ Thwarting Virtual Machine Detection”
 Bania, P., “Playing with RTDSC”
 Quist, D., Smith, V., “Detecting the Presence of Virtual Machines
 Using the Local Data Table”
 Omella, A. A., “Methods for Virtual Machine Detection”
 Tariq, T. B., “Detecting Virtualization”
 Rutkowska, J., " Red Pill... or how to detect VMM using (almost) one
 CPU instruction”
References

 Jackson, J., “An Anti-Reverse Engineering Guide”
 Falliere, N., “Windows Anti-Debug Reference”
 Gagnon, M. N., Taylor, S., and Ghosh, “Software Protection through
 Anti-Debugging”
 Ferrie, P., “Anti-Unpacker Tricks”
 OpenRCE: “Anti Reverse Engineering Techniques Database”
 Ferrie, P., “Attacks on More Virtual Machine Emulators”
 Brulez, N., “Anti-Reverse Engineering Uncovered”
Anti-Debugging Classes
Let’s Get Started
Let’s Get Started
Anti-Debugging Classes

API Based Detection

Process and Thread Block Detection

Hardware and Register Based Detection

Exception Based Detection

Modified Code Based Detection

Timing Based Detection
Anti-Debugging Classes
                                                                 API Based
API Based Detection                                              Detection
 – Using operating system supplied API calls to determine if
   a debugger exists and/or is attached to our code            Process and
                                                               Thread Block
 – No direct access of memory regions                           Detection

 – Relies upon documented and undocumented operating
                                                               Hardware and
   system functions                                            Register Based
                                                                 Detection
Process and Thread Block Detection
 – Bypassing API calls and directly querying process and         Exception
                                                                   Based
   thread information to determine discrepancies that            Detection
   indicate the operation of a debugger
                                                               Modified Code
 – When direct API calls just aren’t enough                       Based
                                                                Detection
 – Avoids userland API hooking
 – Lower in the stack and closer to the OS results in more
                                                               Timing Based
   difficult bypass                                              Detection
Anti-Debugging Classes
                                                                API Based
Hardware and Register Based Detection                           Detection
 – Directly accessing CPU register information specifically
   debug registers to check for hardware breakpoints          Process and
                                                              Thread Block
 – No longer relies upon software differences for detection    Detection

 – One step lower in the stack
                                                              Hardware and
Exception Based Detection                                     Register Based
                                                                Detection
 – Creating an exception that is handled differently
   depending on the debugging state of a process                Exception
                                                                  Based
                                                                Detection


                                                              Modified Code
                                                                 Based
                                                               Detection


                                                              Timing Based
                                                                Detection
Anti-Debugging Classes
                                                               API Based
Modified Code Based Detection                                  Detection
 – Process understands what it *should* look like in
   memory                                                    Process and
                                                             Thread Block
 – Compares the current picture against the excepted          Detection
   picture
                                                             Hardware and
 – Flags on differences                                      Register Based
                                                               Detection
Timing Detection
 – Time calls used to determine execution deltas to be         Exception
                                                                 Based
   compared against a reasonable threshold                     Detection
 – Primarily used to detect single stepping
                                                             Modified Code
 – Can also be used to detect breakpoints within blocks of      Based
                                                              Detection
   code

                                                             Timing Based
                                                               Detection
API Anti-Debugging
Technology Background

 X86 Systems and Microsoft Windows Operating Systems
 – Windows 2000/XP/Vista
 Breakpoints
 – Software Breakpoints (Exceptions)
      Overwrites target location with INT03 (0xcc)
      Saves original opcode
      Backs up one operation, replaces original opcode, restarts
 – Hardware Breakpoints (Faults)
      Debug registers: 4 for addresses, one for control, and one for status
      Each of the first 4 can hold a memory address that causes a hardware fault when
      accessed
      Debug Registers (DR0 – DR7)
 Single Stepping
 – Trap Flag in processor is set
 – Any instruction will trigger a breakpoint when trap flag is set
API Anti-Debugging

 Pros
 – Generally easiest to implement
 – Easiest to understand
 – Short in length


 Cons
 – Easiest to understand
 – Relatively easy to bypass
 – Most frequently used
API Anti-Debugging

 FindWindow
 HANDLE ollyHandle = NULL;
 ollyHandle = FindWindow(L"OLLYDBG", 0);
 if (ollyHandle == NULL) {
     MessageBox(NULL, L"OllyDbg Not Detected", L"Not Detected", MB_OK);
 } else {
     MessageBox(NULL, L"Ollydbg Detected Via OllyDbg FindWindow()",
     L"OllyDbg Detected", MB_OK);
 }

 Registry Key Detection
 SOFTWAREMicrosoftWindows NTCurrentVersionAeDebug
    Debugger=
 exefileshellOpen with Olly&Dbgcommand
 dllfileshellOpen with Olly&Dbgcommand
API Anti-Debugging

 IsDebuggerPresent() Windows API
 if (IsDebuggerPresent()) {
     MessageBox(NULL, L"Debugger Detected Via IsDebuggerPresent",
     L"Debugger Detected", MB_OK);
 }


 CheckRemoteDebuggerPresent() Windows API
 CheckRemoteDebuggerPresent(GetCurrentProcess(), &pbIsPresent);
 if (pbIsPresent) {
     MessageBox(NULL, L"Debugger Detected Via
     CheckRemoteDebuggerPresent", L"Debugger Detected", MB_OK);
 }
API Anti-Debugging

 OutputDebugString on Win2K and WinXP
 DWORD AnythingButTwo = 666;
 SetLastError(AnythingButTwo);
 OutputDebugString(L"foobar");
 if (GetLastError() == AnythingButTwo) {
     MessageBox(NULL, L"Debugger Detected Via OutputDebugString",
     L"Debugger Detected", MB_OK);
 } else {
     MessageBox(NULL, L"No Debugger Detected", L"No Debugger
     Detected", MB_OK);
 }
API Anti-Debugging

 NtQueryInformationProcess() Detection
 status = (_NtQueryInformationProcess) (-1, 7, &retVal, 4, NULL);
 printf("Status Code: %08X - DebugPort: %08X", status, retVal);
 if (retVal != 0) {
     MessageBox(NULL, L"Debugger Detected Via
     NtQueryInformationProcess ProcessDebugPort", L"Debugger Detected",
     MB_OK);
 } else {
     MessageBox(NULL, L"No Debugger Detected", L"No Debugger
     Detected", MB_OK);
 }
API Anti-Debugging

 NtSetInformationThread
 lib = LoadLibrary(L"ntdll.dll");
 _NtSetInformationThread = GetProcAddress(lib, "NtSetInformationThread");

 (_NtSetInformationThread) (GetCurrentThread(), 0x11, 0, 0);
API Anti-Debugging

 Self Debugging with DebugActiveProcess
 pid = GetCurrentProcessId();
 _itow_s((int)pid, (wchar_t*)&pid_str, 8, 10);
 wcsncat_s((wchar_t*)&szCmdline, 64, (wchar_t*)pid_str, 4);
 success = CreateProcess(path, szCmdline, NULL, NULL, FALSE, 0, NULL,
     NULL, &si, &pi);
 …
 success = DebugActiveProcess(pid);
 if (success == 0) {
     printf("Error Code: %dn", GetLastError());
     MessageBox(NULL, L"Debugger Detected - Unable to Attach",
     L"Debugger Detected", MB_OK);
 }
 if (success == 1) MessageBox(NULL, L"No Debugger Detected", L"No
     Debugger", MB_OK);
API Anti-Debugging

 ProcessDebugFlags
 hmod = LoadLibrary(L"ntdll.dll");
 _NtQueryInformationProcess = GetProcAddress(hmod,
   "NtQueryInformationProcess");
 status = (_NtQueryInformationProcess) (-1, 31, &debugFlag, 4, NULL);

 ProcessDebugObjectHandle
 status = (_NtQueryInformationProcess) (-1, 0x1e, &debugObject, 4, NULL);

 OllyDbg OutputDebugString() Format String Vulnerability
 OutputDebugString(TEXT("%s%s%s%s%s%s%s%s%s%s%s"),
   TEXT("%s%s%s%s%s%s%s%s%s%s%s") );
 }
 __except (EXCEPTION_EXECUTE_HANDLER) {
   printf("Handled Exceptionn");
 }
Exception Anti-Debugging
Technology Background
 Exceptions
  – Vectored Exception Handling
         Linked list of exceptions inserted before all other exceptions
  – Structured Exception Handling
         Linked list of exceptions setup on a functional basis
  – Unhandled Exception Filter
         A final catch all for exceptions to limit program crashes


 Debugger Interaction With Exceptions
  –   First chance exceptions
  –   Before Vectored Exception Handlers
  –   Modify and return execution to process
  –   Ignore and continue
  –   Pass exception back to process for handling
Exception Based Anti-Debugging

 Pros
 – Slightly more complex
 – Sometimes more difficult to bypass (debugger doesn’t know how to
   ignore the exception)


 Cons
 – Slightly more complex
 – Sometimes trivial to bypass (debugger ignore exception)
 – Typically longer in length
Exception Anti-Debugging

 INT 2D, INT 0x03, 0xF1 (ICE Breakpoint), 0xCC Detection
 __try {
     __asm {
         int 2dh; // substitute int 3 or __emit 0xF1, 0xCC for other triggers
     }
 }
 __except (EXCEPTION_EXECUTE_HANDLER) {
     flag = 1;
     MessageBox(NULL, L"No Debugger Detected", L"No Debugger",
     MB_OK);
 }
 if (flag != 1) MessageBox(NULL, L"Debugger Detected via int2d",
     L"Debugger Detected", MB_OK);
Exception Based Anti-Debugging

 kernel32!CloseHandle
 __try {
     CloseHandle(0x12345678);
 }
 __except (EXCEPTION_EXECUTE_HANDLER) {
     flag = 1;
     MessageBox(NULL, L"Debugger Detected via kernel32!CloseHandle",
     L"Debugger Detected", MB_OK);
 }
 if (flag == 0) MessageBox(NULL, L"No Debugger Detected", L"No
     Debugger", MB_OK);
Exception Anti-Debugging
 Single Step Detection (Trap Flag)
  __try {
    __asm {
         PUSHFD; //Saves the flag registers
         OR BYTE PTR[ESP+1], 1; // Sets the Trap Flag in EFlags
         POPFD; //Restore the flag registers
         NOP; // NOP
    }
  }
  __except (EXCEPTION_EXECUTE_HANDLER) {
     flag = 1;
     MessageBox(NULL, L"No Debugger Detected", L"No Debugger",
     MB_OK);
  }
  if (flag == 0) MessageBox(NULL, L"Debugger Detected Via Trap Flag",
     L"Debugger Detected", MB_OK);
Exception Anti-Debugging

 OllyDbg Memory Breakpoint Detection
 memRegion = VirtualAlloc(NULL, 0x10000, MEM_COMMIT,
   PAGE_READWRITE);
 RtlFillMemory(memRegion, 0x10, 0xC3);
 success = VirtualProtect(memRegion, 0x10, PAGE_EXECUTE_READ |
   PAGE_GUARD, &oldProt);
 myproc = (FARPROC) memRegion;
 success = 1;
 __try {
   myproc();
 }
 __except (EXCEPTION_EXECUTE_HANDLER) {
   success = 0;
   MessageBox(NULL, L"No Debugger Detected", L"No Debugger
   Detected", MB_OK);
 }
Exception Anti-Debugging

 Control C Vectored Exception Handling
 AddVectoredExceptionHandler(1,
   (PVECTORED_EXCEPTION_HANDLER)exhandler);
 SetConsoleCtrlHandler((PHANDLER_ROUTINE)sighandler, TRUE);
 success = GenerateConsoleCtrlEvent(CTRL_C_EVENT, 0);


 Using the CMPXCHG8B with the LOCK Prefix
 SetUnhandledExceptionFilter((LPTOP_LEVEL_EXCEPTION_FILTER)
   error);
 __asm {
   __emit 0xf0;
   __emit 0xf0;
   __emit 0xc7;
   __emit 0xc8;
 }
Process and Thread Block
Anti-Debugging
Technology Background
 Process Environment Block (PEB)
  – Process Base Address
  –   Heap Location
  –   Memory Pointers
  –   Global Flag
  –   OS Version Information (Major/Minor)
  –   isDebugged Flag
  –   …
 Thread Information Block (TIB)
  –   Thread ID
  –   Process ID
  –   Pointer to process PEB
  –   Error Information
  –   Exception Information
  –   …
Process and Thread Block Anti-Debugging

 Pros
 – Direct to the process and thread information
 – Less chance of detection via hooking
 – Harder to bypass overall


 Cons
 – Requires use of undocumented structures
 – Requires understanding of runtime dynamic linking
 – More complex to understand
Process and Thread Block Anti-Debugging

 IsDebuggerPresent() Direct PEB Access
 status = (_NtQueryInformationProcess) (hnd, ProcessBasicInformation,
     &pPIB, sizeof(PROCESS_BASIC_INFORMATION), &bytesWritten);
 if (status == 0 ) {
     if (pPIB.PebBaseAddress->BeingDebugged == 1) {
          MessageBox(NULL, L"Debugger Detected Using PEB!IsDebugged",
     L"Debugger Detected", MB_OK);
     } else {
          MessageBox(NULL, L"No Debugger Detected", L"No Debugger
     Detected", MB_OK);
 PEB ProcessHeap Flag Debugger Detection
 base = (char *)pPIB.PebBaseAddress;
 procHeap = base+0x18;
 procHeap = *procHeap;
 heapFlag = (char*) procHeap+0x10;
 last = (DWORD*) heapFlag;
 if (*heapFlag != 0x00) { … Found a debugger }
Process and Thread Block Anti-Debugging

 NtGlobalFlag Debugger Detection
 status = (_NtQueryInformationProcess) (hnd, ProcessBasicInformation,
     &pPIB, sizeof(PROCESS_BASIC_INFORMATION), &bytesWritten);
 value = (pPIB.PebBaseAddress);
 value = value+0x68;
 if (*value == 0x70) {
     MessageBox(NULL, L"Debugger Detected Using PEB!NTGlobalFlag",
     L"Debugger Detected", MB_OK);
 } else {
     MessageBox(NULL, L"No Debugger Detected", L"No Debugger
     Detected", MB_OK);
 }
Process and Thread Block Anti-Debugging

 Vista TEB system DLL pointer
 strPtr = TIB+0xBFC; // Offset into the target structure
 delta = (int)(*strPtr) - (int)strPtr; // Ensure that string directly follows pointer
 if (delta == 0x04) {
     if (wcscmp(*strPtr, hookStr)==0) { // Compare to our known bad string
          MessageBox(NULL, L"Debugger Detected Via Vista TEB System DLL
     PTR", L"Debugger Detected", MB_OK);
     } else {
          MessageBox(NULL, L"No Debugger Detected", L"No Debugger",
     MB_OK);
     }
 } else {
     MessageBox(NULL, L"No Debugger Detected", L"No Debugger",
     MB_OK);
 }
Hardware and Register
Anti-Debugging
Hardware and Register Anti-Debugging

 Pros
 – Directly checks the hardware
 – Harder yet to bypass
 – Fairly easy to implement


 Cons
 – Not a whole lot of research in this area
 – Limited number of techniques available
Hardware Register Anti-Debugging

 Hardware Breakpoint Detection
 hnd = GetCurrentThread();
 status = GetThreadContext(hnd, &ctx);
 if ((ctx.Dr0 != 0x00) || (ctx.Dr1 != 0x00) || (ctx.Dr2 != 0x00) || (ctx.Dr3 !=
     0x00) || (ctx.Dr6 != 0x00) || (ctx.Dr7 != 0x00))
 {
     MessageBox(NULL, L"Debugger Detected Via DRx
     Modification/Hardware Breakpoint", L"Debugger Detected", MB_OK);
 } else {
     MessageBox(NULL, L"No Debugger Detected", L"No Debugger",
     MB_OK);
 }
Hardware Register Anti-Debugging

 Vmware sldt detection
 __asm {
     sldt ldt_info;
 }
 if ((ldt_info[0] != 0x00) && (ldt_info[1] != 0x00)) ldt_flag = 1;
Timing Based Anti-Debugging
Timing Based Anti-Debugging

 Pros
 – Super easy to implement
 – Conceptually easy to understand
 – Can monitor blocks or individual instructions


 Cons
 – Very easy to bypass
 – Can be spotted a mile away
Timing Based Anti-Debugging

 RDTSC Instruction Debugger Latency Detection
 i = __rdtsc();
 j = __rdtsc();
 if (j-i < 0xff) {
     MessageBox(NULL, L“No Debugger Detected Via RDTSC", L“No
     Debugger Detected", MB_OK);
 } else {
     MessageBox(NULL, L"Debugger Detected Via RDTSC", L"Debugger
     Detected", MB_OK);
 }
 NTQueryPerformanceCounter
 QueryPerformanceCounter(&li);
 QueryPerformanceCounter(&li2);
 if ((li2.QuadPart-li.QuadPart) > 0xFF) {

 GetTickCount Timing
 timeGetTime Timing
Paper Link



http://www.veracode.com/images/
pdf/whitepaper_antidebugging.pdf
Questions
Contact

Tyler Shields
Sr. Security Researcher
Veracode, Inc.
tshields@veracode.com

More Related Content

What's hot

AUTOMATED TESTING USING PYTHON (ATE)
AUTOMATED TESTING USING PYTHON (ATE)AUTOMATED TESTING USING PYTHON (ATE)
AUTOMATED TESTING USING PYTHON (ATE)Yuvaraja Ravi
 
ChakraCore: analysis of JavaScript-engine for Microsoft Edge
ChakraCore: analysis of JavaScript-engine for Microsoft EdgeChakraCore: analysis of JavaScript-engine for Microsoft Edge
ChakraCore: analysis of JavaScript-engine for Microsoft EdgePVS-Studio
 
Linux version of PVS-Studio couldn't help checking CodeLite
Linux version of PVS-Studio couldn't help checking CodeLiteLinux version of PVS-Studio couldn't help checking CodeLite
Linux version of PVS-Studio couldn't help checking CodeLitePVS-Studio
 
We Continue Exploring Tizen: C# Components Proved to be of High Quality
We Continue Exploring Tizen: C# Components Proved to be of High QualityWe Continue Exploring Tizen: C# Components Proved to be of High Quality
We Continue Exploring Tizen: C# Components Proved to be of High QualityPVS-Studio
 
Why Windows 8 drivers are buggy
Why Windows 8 drivers are buggyWhy Windows 8 drivers are buggy
Why Windows 8 drivers are buggyAndrey Karpov
 
Windbg랑 친해지기
Windbg랑 친해지기Windbg랑 친해지기
Windbg랑 친해지기Ji Hun Kim
 
A fresh eye on Oracle VM VirtualBox
A fresh eye on Oracle VM VirtualBoxA fresh eye on Oracle VM VirtualBox
A fresh eye on Oracle VM VirtualBoxPVS-Studio
 
Checking 7-Zip with PVS-Studio analyzer
Checking 7-Zip with PVS-Studio analyzerChecking 7-Zip with PVS-Studio analyzer
Checking 7-Zip with PVS-Studio analyzerPVS-Studio
 
Valgrind overview: runtime memory checker and a bit more aka использование #v...
Valgrind overview: runtime memory checker and a bit more aka использование #v...Valgrind overview: runtime memory checker and a bit more aka использование #v...
Valgrind overview: runtime memory checker and a bit more aka использование #v...Minsk Linux User Group
 
The Little Unicorn That Could
The Little Unicorn That CouldThe Little Unicorn That Could
The Little Unicorn That CouldPVS-Studio
 
Intel IPP Samples for Windows - error correction
Intel IPP Samples for Windows - error correctionIntel IPP Samples for Windows - error correction
Intel IPP Samples for Windows - error correctionPVS-Studio
 
Valgrind debugger Tutorial
Valgrind debugger TutorialValgrind debugger Tutorial
Valgrind debugger TutorialAnurag Tomar
 
A Post About Analyzing PHP
A Post About Analyzing PHPA Post About Analyzing PHP
A Post About Analyzing PHPAndrey Karpov
 
Checking Clang 11 with PVS-Studio
Checking Clang 11 with PVS-StudioChecking Clang 11 with PVS-Studio
Checking Clang 11 with PVS-StudioAndrey Karpov
 
Better Embedded 2013 - Detecting Memory Leaks with Valgrind
Better Embedded 2013 - Detecting Memory Leaks with ValgrindBetter Embedded 2013 - Detecting Memory Leaks with Valgrind
Better Embedded 2013 - Detecting Memory Leaks with ValgrindRigels Gordani
 
Valgrind tutorial
Valgrind tutorialValgrind tutorial
Valgrind tutorialSatabdi Das
 
Dive into exploit development
Dive into exploit developmentDive into exploit development
Dive into exploit developmentPayampardaz
 

What's hot (20)

AUTOMATED TESTING USING PYTHON (ATE)
AUTOMATED TESTING USING PYTHON (ATE)AUTOMATED TESTING USING PYTHON (ATE)
AUTOMATED TESTING USING PYTHON (ATE)
 
ChakraCore: analysis of JavaScript-engine for Microsoft Edge
ChakraCore: analysis of JavaScript-engine for Microsoft EdgeChakraCore: analysis of JavaScript-engine for Microsoft Edge
ChakraCore: analysis of JavaScript-engine for Microsoft Edge
 
Linux version of PVS-Studio couldn't help checking CodeLite
Linux version of PVS-Studio couldn't help checking CodeLiteLinux version of PVS-Studio couldn't help checking CodeLite
Linux version of PVS-Studio couldn't help checking CodeLite
 
We Continue Exploring Tizen: C# Components Proved to be of High Quality
We Continue Exploring Tizen: C# Components Proved to be of High QualityWe Continue Exploring Tizen: C# Components Proved to be of High Quality
We Continue Exploring Tizen: C# Components Proved to be of High Quality
 
Why Windows 8 drivers are buggy
Why Windows 8 drivers are buggyWhy Windows 8 drivers are buggy
Why Windows 8 drivers are buggy
 
Windbg랑 친해지기
Windbg랑 친해지기Windbg랑 친해지기
Windbg랑 친해지기
 
A fresh eye on Oracle VM VirtualBox
A fresh eye on Oracle VM VirtualBoxA fresh eye on Oracle VM VirtualBox
A fresh eye on Oracle VM VirtualBox
 
Checking 7-Zip with PVS-Studio analyzer
Checking 7-Zip with PVS-Studio analyzerChecking 7-Zip with PVS-Studio analyzer
Checking 7-Zip with PVS-Studio analyzer
 
Valgrind
ValgrindValgrind
Valgrind
 
Valgrind overview: runtime memory checker and a bit more aka использование #v...
Valgrind overview: runtime memory checker and a bit more aka использование #v...Valgrind overview: runtime memory checker and a bit more aka использование #v...
Valgrind overview: runtime memory checker and a bit more aka использование #v...
 
Tranning-2
Tranning-2Tranning-2
Tranning-2
 
The Little Unicorn That Could
The Little Unicorn That CouldThe Little Unicorn That Could
The Little Unicorn That Could
 
Intel IPP Samples for Windows - error correction
Intel IPP Samples for Windows - error correctionIntel IPP Samples for Windows - error correction
Intel IPP Samples for Windows - error correction
 
Valgrind debugger Tutorial
Valgrind debugger TutorialValgrind debugger Tutorial
Valgrind debugger Tutorial
 
C&cpu
C&cpuC&cpu
C&cpu
 
A Post About Analyzing PHP
A Post About Analyzing PHPA Post About Analyzing PHP
A Post About Analyzing PHP
 
Checking Clang 11 with PVS-Studio
Checking Clang 11 with PVS-StudioChecking Clang 11 with PVS-Studio
Checking Clang 11 with PVS-Studio
 
Better Embedded 2013 - Detecting Memory Leaks with Valgrind
Better Embedded 2013 - Detecting Memory Leaks with ValgrindBetter Embedded 2013 - Detecting Memory Leaks with Valgrind
Better Embedded 2013 - Detecting Memory Leaks with Valgrind
 
Valgrind tutorial
Valgrind tutorialValgrind tutorial
Valgrind tutorial
 
Dive into exploit development
Dive into exploit developmentDive into exploit development
Dive into exploit development
 

Similar to Source Boston 2009 - Anti-Debugging A Developers Viewpoint

CarolinaCon 2009 Anti-Debugging
CarolinaCon 2009 Anti-DebuggingCarolinaCon 2009 Anti-Debugging
CarolinaCon 2009 Anti-DebuggingTyler Shields
 
Efficient Bytecode Analysis: Linespeed Shellcode Detection
Efficient Bytecode Analysis: Linespeed Shellcode DetectionEfficient Bytecode Analysis: Linespeed Shellcode Detection
Efficient Bytecode Analysis: Linespeed Shellcode DetectionGeorg Wicherski
 
Advanced malwareanalysis training session2 botnet analysis part1
Advanced malwareanalysis training session2 botnet analysis part1Advanced malwareanalysis training session2 botnet analysis part1
Advanced malwareanalysis training session2 botnet analysis part1Cysinfo Cyber Security Community
 
Современные технологии и инструменты анализа вредоносного ПО
Современные технологии и инструменты анализа вредоносного ПОСовременные технологии и инструменты анализа вредоносного ПО
Современные технологии и инструменты анализа вредоносного ПОPositive Hack Days
 
Современные технологии и инструменты анализа вредоносного ПО_PHDays_2017_Pisk...
Современные технологии и инструменты анализа вредоносного ПО_PHDays_2017_Pisk...Современные технологии и инструменты анализа вредоносного ПО_PHDays_2017_Pisk...
Современные технологии и инструменты анализа вредоносного ПО_PHDays_2017_Pisk...Ivan Piskunov
 
B-Sides Seattle 2012 Offensive Defense
B-Sides Seattle 2012 Offensive DefenseB-Sides Seattle 2012 Offensive Defense
B-Sides Seattle 2012 Offensive DefenseStephan Chenette
 
Search for Vulnerabilities Using Static Code Analysis
Search for Vulnerabilities Using Static Code AnalysisSearch for Vulnerabilities Using Static Code Analysis
Search for Vulnerabilities Using Static Code AnalysisAndrey Karpov
 
The Hacking Games - Operation System Vulnerabilities Meetup 29112022
The Hacking Games - Operation System Vulnerabilities Meetup 29112022The Hacking Games - Operation System Vulnerabilities Meetup 29112022
The Hacking Games - Operation System Vulnerabilities Meetup 29112022lior mazor
 
DEFCON 21: EDS: Exploitation Detection System WP
DEFCON 21: EDS: Exploitation Detection System WPDEFCON 21: EDS: Exploitation Detection System WP
DEFCON 21: EDS: Exploitation Detection System WPAmr Thabet
 
Static analysis as means of improving code quality
Static analysis as means of improving code quality Static analysis as means of improving code quality
Static analysis as means of improving code quality Andrey Karpov
 
HES2011 - Aaron Portnoy and Logan Brown - Black Box Auditing Adobe Shockwave
HES2011 - Aaron Portnoy and Logan Brown - Black Box Auditing Adobe ShockwaveHES2011 - Aaron Portnoy and Logan Brown - Black Box Auditing Adobe Shockwave
HES2011 - Aaron Portnoy and Logan Brown - Black Box Auditing Adobe ShockwaveHackito Ergo Sum
 
Advanced Malware Analysis Training Session 2 - Botnet Analysis Part 1
Advanced Malware Analysis Training Session 2 - Botnet Analysis Part 1  Advanced Malware Analysis Training Session 2 - Botnet Analysis Part 1
Advanced Malware Analysis Training Session 2 - Botnet Analysis Part 1 securityxploded
 
2013 syscan360 yuki_chen_syscan360_exploit your java native vulnerabilities o...
2013 syscan360 yuki_chen_syscan360_exploit your java native vulnerabilities o...2013 syscan360 yuki_chen_syscan360_exploit your java native vulnerabilities o...
2013 syscan360 yuki_chen_syscan360_exploit your java native vulnerabilities o...chen yuki
 
Writing Metasploit Plugins
Writing Metasploit PluginsWriting Metasploit Plugins
Writing Metasploit Pluginsamiable_indian
 
Рахманов Александр "Что полезного в разборе дампов для .NET-разработчиков?"
Рахманов Александр "Что полезного в разборе дампов для .NET-разработчиков?"Рахманов Александр "Что полезного в разборе дампов для .NET-разработчиков?"
Рахманов Александр "Что полезного в разборе дампов для .NET-разработчиков?"Yulia Tsisyk
 
Deobfuscation and beyond (ZeroNights, 2014)
Deobfuscation and beyond (ZeroNights, 2014)Deobfuscation and beyond (ZeroNights, 2014)
Deobfuscation and beyond (ZeroNights, 2014)ReCrypt
 
Fosdem10
Fosdem10Fosdem10
Fosdem10wremes
 
Inside the Matrix,How to Build Transparent Sandbox for Malware Analysis
Inside the Matrix,How to Build Transparent Sandbox for Malware AnalysisInside the Matrix,How to Build Transparent Sandbox for Malware Analysis
Inside the Matrix,How to Build Transparent Sandbox for Malware AnalysisChong-Kuan Chen
 

Similar to Source Boston 2009 - Anti-Debugging A Developers Viewpoint (20)

CarolinaCon 2009 Anti-Debugging
CarolinaCon 2009 Anti-DebuggingCarolinaCon 2009 Anti-Debugging
CarolinaCon 2009 Anti-Debugging
 
Efficient Bytecode Analysis: Linespeed Shellcode Detection
Efficient Bytecode Analysis: Linespeed Shellcode DetectionEfficient Bytecode Analysis: Linespeed Shellcode Detection
Efficient Bytecode Analysis: Linespeed Shellcode Detection
 
Advanced malwareanalysis training session2 botnet analysis part1
Advanced malwareanalysis training session2 botnet analysis part1Advanced malwareanalysis training session2 botnet analysis part1
Advanced malwareanalysis training session2 botnet analysis part1
 
Web backdoors attacks, evasion, detection
Web backdoors   attacks, evasion, detectionWeb backdoors   attacks, evasion, detection
Web backdoors attacks, evasion, detection
 
Современные технологии и инструменты анализа вредоносного ПО
Современные технологии и инструменты анализа вредоносного ПОСовременные технологии и инструменты анализа вредоносного ПО
Современные технологии и инструменты анализа вредоносного ПО
 
Современные технологии и инструменты анализа вредоносного ПО_PHDays_2017_Pisk...
Современные технологии и инструменты анализа вредоносного ПО_PHDays_2017_Pisk...Современные технологии и инструменты анализа вредоносного ПО_PHDays_2017_Pisk...
Современные технологии и инструменты анализа вредоносного ПО_PHDays_2017_Pisk...
 
B-Sides Seattle 2012 Offensive Defense
B-Sides Seattle 2012 Offensive DefenseB-Sides Seattle 2012 Offensive Defense
B-Sides Seattle 2012 Offensive Defense
 
Search for Vulnerabilities Using Static Code Analysis
Search for Vulnerabilities Using Static Code AnalysisSearch for Vulnerabilities Using Static Code Analysis
Search for Vulnerabilities Using Static Code Analysis
 
The Hacking Games - Operation System Vulnerabilities Meetup 29112022
The Hacking Games - Operation System Vulnerabilities Meetup 29112022The Hacking Games - Operation System Vulnerabilities Meetup 29112022
The Hacking Games - Operation System Vulnerabilities Meetup 29112022
 
DEFCON 21: EDS: Exploitation Detection System WP
DEFCON 21: EDS: Exploitation Detection System WPDEFCON 21: EDS: Exploitation Detection System WP
DEFCON 21: EDS: Exploitation Detection System WP
 
Static analysis as means of improving code quality
Static analysis as means of improving code quality Static analysis as means of improving code quality
Static analysis as means of improving code quality
 
Vxcon 2016
Vxcon 2016Vxcon 2016
Vxcon 2016
 
HES2011 - Aaron Portnoy and Logan Brown - Black Box Auditing Adobe Shockwave
HES2011 - Aaron Portnoy and Logan Brown - Black Box Auditing Adobe ShockwaveHES2011 - Aaron Portnoy and Logan Brown - Black Box Auditing Adobe Shockwave
HES2011 - Aaron Portnoy and Logan Brown - Black Box Auditing Adobe Shockwave
 
Advanced Malware Analysis Training Session 2 - Botnet Analysis Part 1
Advanced Malware Analysis Training Session 2 - Botnet Analysis Part 1  Advanced Malware Analysis Training Session 2 - Botnet Analysis Part 1
Advanced Malware Analysis Training Session 2 - Botnet Analysis Part 1
 
2013 syscan360 yuki_chen_syscan360_exploit your java native vulnerabilities o...
2013 syscan360 yuki_chen_syscan360_exploit your java native vulnerabilities o...2013 syscan360 yuki_chen_syscan360_exploit your java native vulnerabilities o...
2013 syscan360 yuki_chen_syscan360_exploit your java native vulnerabilities o...
 
Writing Metasploit Plugins
Writing Metasploit PluginsWriting Metasploit Plugins
Writing Metasploit Plugins
 
Рахманов Александр "Что полезного в разборе дампов для .NET-разработчиков?"
Рахманов Александр "Что полезного в разборе дампов для .NET-разработчиков?"Рахманов Александр "Что полезного в разборе дампов для .NET-разработчиков?"
Рахманов Александр "Что полезного в разборе дампов для .NET-разработчиков?"
 
Deobfuscation and beyond (ZeroNights, 2014)
Deobfuscation and beyond (ZeroNights, 2014)Deobfuscation and beyond (ZeroNights, 2014)
Deobfuscation and beyond (ZeroNights, 2014)
 
Fosdem10
Fosdem10Fosdem10
Fosdem10
 
Inside the Matrix,How to Build Transparent Sandbox for Malware Analysis
Inside the Matrix,How to Build Transparent Sandbox for Malware AnalysisInside the Matrix,How to Build Transparent Sandbox for Malware Analysis
Inside the Matrix,How to Build Transparent Sandbox for Malware Analysis
 

More from Tyler Shields

The New Mobile Landscape - OWASP Ireland
The New Mobile Landscape - OWASP IrelandThe New Mobile Landscape - OWASP Ireland
The New Mobile Landscape - OWASP IrelandTyler Shields
 
Defending Behind the Mobile Device
Defending Behind the Mobile DeviceDefending Behind the Mobile Device
Defending Behind the Mobile DeviceTyler Shields
 
Avoiding the Pandora Pitfall
Avoiding the Pandora PitfallAvoiding the Pandora Pitfall
Avoiding the Pandora PitfallTyler Shields
 
Social and Mobile and Cloud - OH MY!
Social and Mobile and Cloud - OH MY!Social and Mobile and Cloud - OH MY!
Social and Mobile and Cloud - OH MY!Tyler Shields
 
Social Media Basics: Security Loopholes with Twitter & Other Social Media
Social Media Basics: Security Loopholes with Twitter & Other Social MediaSocial Media Basics: Security Loopholes with Twitter & Other Social Media
Social Media Basics: Security Loopholes with Twitter & Other Social MediaTyler Shields
 
United Security Summit 2011 - Using the Mobile Top 10 as a Guide to Assessing...
United Security Summit 2011 - Using the Mobile Top 10 as a Guide to Assessing...United Security Summit 2011 - Using the Mobile Top 10 as a Guide to Assessing...
United Security Summit 2011 - Using the Mobile Top 10 as a Guide to Assessing...Tyler Shields
 
Shmoocon 2010 - The Monkey Steals the Berries
Shmoocon 2010 - The Monkey Steals the BerriesShmoocon 2010 - The Monkey Steals the Berries
Shmoocon 2010 - The Monkey Steals the BerriesTyler Shields
 
Survey of Rootkit Technologies and Their Impact on Digital Forensics
Survey of Rootkit Technologies and Their Impact on Digital ForensicsSurvey of Rootkit Technologies and Their Impact on Digital Forensics
Survey of Rootkit Technologies and Their Impact on Digital ForensicsTyler Shields
 
Source Boston 2010 - The Monkey Steals the Berries Part Deux
Source Boston 2010 - The Monkey Steals the Berries Part DeuxSource Boston 2010 - The Monkey Steals the Berries Part Deux
Source Boston 2010 - The Monkey Steals the Berries Part DeuxTyler Shields
 
Software Developers Forum 2010 - The Monkey Steals the Berries
Software Developers Forum 2010 - The Monkey Steals the BerriesSoftware Developers Forum 2010 - The Monkey Steals the Berries
Software Developers Forum 2010 - The Monkey Steals the BerriesTyler Shields
 
Raleigh ISSA 2010 - The Monkey Steals the Berries
Raleigh ISSA 2010 - The Monkey Steals the BerriesRaleigh ISSA 2010 - The Monkey Steals the Berries
Raleigh ISSA 2010 - The Monkey Steals the BerriesTyler Shields
 
Static Detection of Application Backdoors
Static Detection of Application BackdoorsStatic Detection of Application Backdoors
Static Detection of Application BackdoorsTyler Shields
 
Blackhat Europe 2009 - Detecting Certified Pre Owned Software
Blackhat Europe 2009 - Detecting Certified Pre Owned SoftwareBlackhat Europe 2009 - Detecting Certified Pre Owned Software
Blackhat Europe 2009 - Detecting Certified Pre Owned SoftwareTyler Shields
 
Praetorian Veracode Webinar - Mobile Privacy
Praetorian Veracode Webinar - Mobile PrivacyPraetorian Veracode Webinar - Mobile Privacy
Praetorian Veracode Webinar - Mobile PrivacyTyler Shields
 
Owasp Ireland - The State of Software Security
Owasp  Ireland - The State of Software SecurityOwasp  Ireland - The State of Software Security
Owasp Ireland - The State of Software SecurityTyler Shields
 
More Apps More Problems
More Apps More ProblemsMore Apps More Problems
More Apps More ProblemsTyler Shields
 
Dirty Little Secret - Mobile Applications Invading Your Privacy
Dirty Little Secret - Mobile Applications Invading Your PrivacyDirty Little Secret - Mobile Applications Invading Your Privacy
Dirty Little Secret - Mobile Applications Invading Your PrivacyTyler Shields
 
IT Hot Topics - Mobile Security Threats at Every Layer
IT Hot Topics - Mobile Security Threats at Every LayerIT Hot Topics - Mobile Security Threats at Every Layer
IT Hot Topics - Mobile Security Threats at Every LayerTyler Shields
 
IT Hot Topics 2010 - The Coming Wave of Smartphone Attacks
IT Hot Topics 2010 - The Coming Wave of Smartphone AttacksIT Hot Topics 2010 - The Coming Wave of Smartphone Attacks
IT Hot Topics 2010 - The Coming Wave of Smartphone AttacksTyler Shields
 
iSec Forum NYC - Smartphone Backdoors an Analysis of Mobile Spyware
iSec Forum NYC - Smartphone Backdoors an Analysis of Mobile SpywareiSec Forum NYC - Smartphone Backdoors an Analysis of Mobile Spyware
iSec Forum NYC - Smartphone Backdoors an Analysis of Mobile SpywareTyler Shields
 

More from Tyler Shields (20)

The New Mobile Landscape - OWASP Ireland
The New Mobile Landscape - OWASP IrelandThe New Mobile Landscape - OWASP Ireland
The New Mobile Landscape - OWASP Ireland
 
Defending Behind the Mobile Device
Defending Behind the Mobile DeviceDefending Behind the Mobile Device
Defending Behind the Mobile Device
 
Avoiding the Pandora Pitfall
Avoiding the Pandora PitfallAvoiding the Pandora Pitfall
Avoiding the Pandora Pitfall
 
Social and Mobile and Cloud - OH MY!
Social and Mobile and Cloud - OH MY!Social and Mobile and Cloud - OH MY!
Social and Mobile and Cloud - OH MY!
 
Social Media Basics: Security Loopholes with Twitter & Other Social Media
Social Media Basics: Security Loopholes with Twitter & Other Social MediaSocial Media Basics: Security Loopholes with Twitter & Other Social Media
Social Media Basics: Security Loopholes with Twitter & Other Social Media
 
United Security Summit 2011 - Using the Mobile Top 10 as a Guide to Assessing...
United Security Summit 2011 - Using the Mobile Top 10 as a Guide to Assessing...United Security Summit 2011 - Using the Mobile Top 10 as a Guide to Assessing...
United Security Summit 2011 - Using the Mobile Top 10 as a Guide to Assessing...
 
Shmoocon 2010 - The Monkey Steals the Berries
Shmoocon 2010 - The Monkey Steals the BerriesShmoocon 2010 - The Monkey Steals the Berries
Shmoocon 2010 - The Monkey Steals the Berries
 
Survey of Rootkit Technologies and Their Impact on Digital Forensics
Survey of Rootkit Technologies and Their Impact on Digital ForensicsSurvey of Rootkit Technologies and Their Impact on Digital Forensics
Survey of Rootkit Technologies and Their Impact on Digital Forensics
 
Source Boston 2010 - The Monkey Steals the Berries Part Deux
Source Boston 2010 - The Monkey Steals the Berries Part DeuxSource Boston 2010 - The Monkey Steals the Berries Part Deux
Source Boston 2010 - The Monkey Steals the Berries Part Deux
 
Software Developers Forum 2010 - The Monkey Steals the Berries
Software Developers Forum 2010 - The Monkey Steals the BerriesSoftware Developers Forum 2010 - The Monkey Steals the Berries
Software Developers Forum 2010 - The Monkey Steals the Berries
 
Raleigh ISSA 2010 - The Monkey Steals the Berries
Raleigh ISSA 2010 - The Monkey Steals the BerriesRaleigh ISSA 2010 - The Monkey Steals the Berries
Raleigh ISSA 2010 - The Monkey Steals the Berries
 
Static Detection of Application Backdoors
Static Detection of Application BackdoorsStatic Detection of Application Backdoors
Static Detection of Application Backdoors
 
Blackhat Europe 2009 - Detecting Certified Pre Owned Software
Blackhat Europe 2009 - Detecting Certified Pre Owned SoftwareBlackhat Europe 2009 - Detecting Certified Pre Owned Software
Blackhat Europe 2009 - Detecting Certified Pre Owned Software
 
Praetorian Veracode Webinar - Mobile Privacy
Praetorian Veracode Webinar - Mobile PrivacyPraetorian Veracode Webinar - Mobile Privacy
Praetorian Veracode Webinar - Mobile Privacy
 
Owasp Ireland - The State of Software Security
Owasp  Ireland - The State of Software SecurityOwasp  Ireland - The State of Software Security
Owasp Ireland - The State of Software Security
 
More Apps More Problems
More Apps More ProblemsMore Apps More Problems
More Apps More Problems
 
Dirty Little Secret - Mobile Applications Invading Your Privacy
Dirty Little Secret - Mobile Applications Invading Your PrivacyDirty Little Secret - Mobile Applications Invading Your Privacy
Dirty Little Secret - Mobile Applications Invading Your Privacy
 
IT Hot Topics - Mobile Security Threats at Every Layer
IT Hot Topics - Mobile Security Threats at Every LayerIT Hot Topics - Mobile Security Threats at Every Layer
IT Hot Topics - Mobile Security Threats at Every Layer
 
IT Hot Topics 2010 - The Coming Wave of Smartphone Attacks
IT Hot Topics 2010 - The Coming Wave of Smartphone AttacksIT Hot Topics 2010 - The Coming Wave of Smartphone Attacks
IT Hot Topics 2010 - The Coming Wave of Smartphone Attacks
 
iSec Forum NYC - Smartphone Backdoors an Analysis of Mobile Spyware
iSec Forum NYC - Smartphone Backdoors an Analysis of Mobile SpywareiSec Forum NYC - Smartphone Backdoors an Analysis of Mobile Spyware
iSec Forum NYC - Smartphone Backdoors an Analysis of Mobile Spyware
 

Recently uploaded

Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 

Recently uploaded (20)

Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 

Source Boston 2009 - Anti-Debugging A Developers Viewpoint

  • 1. Anti-Debugging A Developers Viewpoint March 13, 2008
  • 2. Presenter Background Currently – Sr. Security Researcher for Veracode, Inc. Previously – Security Consultant - Symantec – Security Consultant - @Stake – Incident Response and Forensics Handler – US Government Wishes He Was – Infinitely Rich – Personal Trainer to hot Hollywood starlets – General all-around rockstar
  • 3. What we will cover… Definition of Problem Statement and Terms Why Bother? – Isn’t this a futile effort? Standing On The Shoulders of Giants – Brief reference of anti-debugging Classes of Anti-Debugging Methods – The six styles of anti-debug fu Some Known Anti-Debugging Methods – Not enough time to cover them all
  • 5. Problem Statement Anti-debugging methods are consistently presented as machine code or assembly language constructs making knowledge transfer difficult and limiting widespread use of the techniques.
  • 6. Let’s Do An Experiment Can you tell what the following code does in five seconds or less? Be Honest!
  • 7. Assembly Dump push ebp mov ebp, esp loc_411400: ; CODE XREF: antidebug(void)+2Fj sub esp, 0C0h mov esi, esp push ebx push 0 ; uType push esi push offset aNoDebugger push edi push offset aNoDebuggerDete lea edi, [ebp+var_C0] push 0 ; hWnd mov ecx, 30h call ds:__imp__MessageBoxW@16 mov eax, 0CCCCCCCCh cmp esi, esp rep stosd j___RTC_CheckEsp mov esi, esp call ds:__imp__IsDebuggerPresent@0 loc_41141D: ; CODE XREF: antidebug(void)+4Ej cmp esi, esp pop edi call j___RTC_CheckEsp pop esi test eax, eax pop ebx jz short loc_411400 add esp, 0C0h mov esi, esp cmp ebp, esp push 0 ; uType call j___RTC_CheckEsp push offset Caption mov esp, ebp push offset Text pop ebp push 0 ; hWnd Retn call ds:__imp__MessageBoxW@16 antidebug@@YAXXZ endp cmp esi, esp call j___RTC_CheckEsp short loc_41141D
  • 9. Assembly Dump – Highlight Important Bits var_C0 = byte ptr -0C0h call j___RTC_CheckEsp push ebp jmp short loc_41141D mov ebp, esp sub esp, 0C0h loc_411400: Push ebx mov esi, esp Push esi push 0 ; uType Push edi push offset aNoDebugger lea edi, [ebp+var_C0] push offset aNoDebuggerDete mov ecx, 30h push 0 ; hWnd mov eax, 0CCCCCCCCh call ds:__imp__MessageBoxW@16 Rep stosd cmp esi, esp mov esi, esp call j___RTC_CheckEsp Call ds:__imp__IsDebuggerPresent@0 loc_41141D: cmp esi, esp pop edi Callj___RTC_CheckEsp pop esi Test eax, eax pop ebx jz short loc_411400 add esp, 0C0h mov esi, esp cmp ebp, esp push 0 ; uType call j___RTC_CheckEsp push offset Caption mov esp, ebp push offset Text pop ebp push 0 ; hWnd Retn call ds:__imp__MessageBoxW@16 ?antidebug@@YAXXZ endp cmp esi, esp
  • 11. How About In C if (IsDebuggerPresent()) { MessageBox(NULL, L"Debugger Detected Via IsDebuggerPresent", L"Debugger Detected", MB_OK); } else { MessageBox(NULL, L“No Debugger Detected“, L“No Debugger ", MB_OK); }
  • 12. Definition of Terms Debugger (Debugging) – The act of detecting and removing bugs in an application. Anti-Debugging – Anti-debugging is the implementation of one or more techniques within computer code that hinders attempts at reverse engineering or debugging a target process.
  • 13. Definition of Terms Dumping – Dumping of a running process in memory to disk so that the image can be executed as a separate binary. Anti-Dumping – Technique that is used to inhibit the dumping of a running process from memory to disk
  • 14. Definition of Terms Anti-Anti-Debugging – Techniques used to detect and bypass anti-debugging efforts Anti-Anti-Dumping – Techniques used to detect and bypass anti-dumping efforts. Anti-Anti-Anti-…. You get the picture
  • 15. Why Bother? Isn’t this a futile effort
  • 16. Why Should I Care? Protecting your intellectual property – Laws can’t possibly work Neither do EULA or other soft methods – Slow down subversion of software registration Cracking – Impede application feature and code theft Low cost – Short code segments equals quick implementation – Write a basic anti-debugging library for reuse
  • 17. Why Should I Care? Raise the bar – Implement multiple layers of defense – Makes reversing an arduous task – It’s no longer as simple as a debugger + disassembler + time Malware analysis – Knowledge of anti-debugging techniques can help your incident response and analysis – Debug the random binary found on your accounting system – Implement IDS/IPS signatures in shorter timeframes Exercise the brain – Keeps the synapses firing – Implementation (and bypass) is FUN!
  • 18. Standing On the Shoulders Of Giants A Brief Reference of Anti-Debugging
  • 19. References Bania, P, “Antidebugging for the (m)asses - protecting the env.” Brulez, N., “Crimeware Anti-Reverse Engineering Uncovered” “Lord Julus”, “Anti-Debugger and Anti-Emulator Lair” Liston, T., and Skoudis, E., “ Thwarting Virtual Machine Detection” Bania, P., “Playing with RTDSC” Quist, D., Smith, V., “Detecting the Presence of Virtual Machines Using the Local Data Table” Omella, A. A., “Methods for Virtual Machine Detection” Tariq, T. B., “Detecting Virtualization” Rutkowska, J., " Red Pill... or how to detect VMM using (almost) one CPU instruction”
  • 20. References Jackson, J., “An Anti-Reverse Engineering Guide” Falliere, N., “Windows Anti-Debug Reference” Gagnon, M. N., Taylor, S., and Ghosh, “Software Protection through Anti-Debugging” Ferrie, P., “Anti-Unpacker Tricks” OpenRCE: “Anti Reverse Engineering Techniques Database” Ferrie, P., “Attacks on More Virtual Machine Emulators” Brulez, N., “Anti-Reverse Engineering Uncovered”
  • 24. Anti-Debugging Classes API Based Detection Process and Thread Block Detection Hardware and Register Based Detection Exception Based Detection Modified Code Based Detection Timing Based Detection
  • 25. Anti-Debugging Classes API Based API Based Detection Detection – Using operating system supplied API calls to determine if a debugger exists and/or is attached to our code Process and Thread Block – No direct access of memory regions Detection – Relies upon documented and undocumented operating Hardware and system functions Register Based Detection Process and Thread Block Detection – Bypassing API calls and directly querying process and Exception Based thread information to determine discrepancies that Detection indicate the operation of a debugger Modified Code – When direct API calls just aren’t enough Based Detection – Avoids userland API hooking – Lower in the stack and closer to the OS results in more Timing Based difficult bypass Detection
  • 26. Anti-Debugging Classes API Based Hardware and Register Based Detection Detection – Directly accessing CPU register information specifically debug registers to check for hardware breakpoints Process and Thread Block – No longer relies upon software differences for detection Detection – One step lower in the stack Hardware and Exception Based Detection Register Based Detection – Creating an exception that is handled differently depending on the debugging state of a process Exception Based Detection Modified Code Based Detection Timing Based Detection
  • 27. Anti-Debugging Classes API Based Modified Code Based Detection Detection – Process understands what it *should* look like in memory Process and Thread Block – Compares the current picture against the excepted Detection picture Hardware and – Flags on differences Register Based Detection Timing Detection – Time calls used to determine execution deltas to be Exception Based compared against a reasonable threshold Detection – Primarily used to detect single stepping Modified Code – Can also be used to detect breakpoints within blocks of Based Detection code Timing Based Detection
  • 29. Technology Background X86 Systems and Microsoft Windows Operating Systems – Windows 2000/XP/Vista Breakpoints – Software Breakpoints (Exceptions) Overwrites target location with INT03 (0xcc) Saves original opcode Backs up one operation, replaces original opcode, restarts – Hardware Breakpoints (Faults) Debug registers: 4 for addresses, one for control, and one for status Each of the first 4 can hold a memory address that causes a hardware fault when accessed Debug Registers (DR0 – DR7) Single Stepping – Trap Flag in processor is set – Any instruction will trigger a breakpoint when trap flag is set
  • 30. API Anti-Debugging Pros – Generally easiest to implement – Easiest to understand – Short in length Cons – Easiest to understand – Relatively easy to bypass – Most frequently used
  • 31. API Anti-Debugging FindWindow HANDLE ollyHandle = NULL; ollyHandle = FindWindow(L"OLLYDBG", 0); if (ollyHandle == NULL) { MessageBox(NULL, L"OllyDbg Not Detected", L"Not Detected", MB_OK); } else { MessageBox(NULL, L"Ollydbg Detected Via OllyDbg FindWindow()", L"OllyDbg Detected", MB_OK); } Registry Key Detection SOFTWAREMicrosoftWindows NTCurrentVersionAeDebug Debugger= exefileshellOpen with Olly&Dbgcommand dllfileshellOpen with Olly&Dbgcommand
  • 32. API Anti-Debugging IsDebuggerPresent() Windows API if (IsDebuggerPresent()) { MessageBox(NULL, L"Debugger Detected Via IsDebuggerPresent", L"Debugger Detected", MB_OK); } CheckRemoteDebuggerPresent() Windows API CheckRemoteDebuggerPresent(GetCurrentProcess(), &pbIsPresent); if (pbIsPresent) { MessageBox(NULL, L"Debugger Detected Via CheckRemoteDebuggerPresent", L"Debugger Detected", MB_OK); }
  • 33. API Anti-Debugging OutputDebugString on Win2K and WinXP DWORD AnythingButTwo = 666; SetLastError(AnythingButTwo); OutputDebugString(L"foobar"); if (GetLastError() == AnythingButTwo) { MessageBox(NULL, L"Debugger Detected Via OutputDebugString", L"Debugger Detected", MB_OK); } else { MessageBox(NULL, L"No Debugger Detected", L"No Debugger Detected", MB_OK); }
  • 34. API Anti-Debugging NtQueryInformationProcess() Detection status = (_NtQueryInformationProcess) (-1, 7, &retVal, 4, NULL); printf("Status Code: %08X - DebugPort: %08X", status, retVal); if (retVal != 0) { MessageBox(NULL, L"Debugger Detected Via NtQueryInformationProcess ProcessDebugPort", L"Debugger Detected", MB_OK); } else { MessageBox(NULL, L"No Debugger Detected", L"No Debugger Detected", MB_OK); }
  • 35. API Anti-Debugging NtSetInformationThread lib = LoadLibrary(L"ntdll.dll"); _NtSetInformationThread = GetProcAddress(lib, "NtSetInformationThread"); (_NtSetInformationThread) (GetCurrentThread(), 0x11, 0, 0);
  • 36. API Anti-Debugging Self Debugging with DebugActiveProcess pid = GetCurrentProcessId(); _itow_s((int)pid, (wchar_t*)&pid_str, 8, 10); wcsncat_s((wchar_t*)&szCmdline, 64, (wchar_t*)pid_str, 4); success = CreateProcess(path, szCmdline, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi); … success = DebugActiveProcess(pid); if (success == 0) { printf("Error Code: %dn", GetLastError()); MessageBox(NULL, L"Debugger Detected - Unable to Attach", L"Debugger Detected", MB_OK); } if (success == 1) MessageBox(NULL, L"No Debugger Detected", L"No Debugger", MB_OK);
  • 37. API Anti-Debugging ProcessDebugFlags hmod = LoadLibrary(L"ntdll.dll"); _NtQueryInformationProcess = GetProcAddress(hmod, "NtQueryInformationProcess"); status = (_NtQueryInformationProcess) (-1, 31, &debugFlag, 4, NULL); ProcessDebugObjectHandle status = (_NtQueryInformationProcess) (-1, 0x1e, &debugObject, 4, NULL); OllyDbg OutputDebugString() Format String Vulnerability OutputDebugString(TEXT("%s%s%s%s%s%s%s%s%s%s%s"), TEXT("%s%s%s%s%s%s%s%s%s%s%s") ); } __except (EXCEPTION_EXECUTE_HANDLER) { printf("Handled Exceptionn"); }
  • 39. Technology Background Exceptions – Vectored Exception Handling Linked list of exceptions inserted before all other exceptions – Structured Exception Handling Linked list of exceptions setup on a functional basis – Unhandled Exception Filter A final catch all for exceptions to limit program crashes Debugger Interaction With Exceptions – First chance exceptions – Before Vectored Exception Handlers – Modify and return execution to process – Ignore and continue – Pass exception back to process for handling
  • 40. Exception Based Anti-Debugging Pros – Slightly more complex – Sometimes more difficult to bypass (debugger doesn’t know how to ignore the exception) Cons – Slightly more complex – Sometimes trivial to bypass (debugger ignore exception) – Typically longer in length
  • 41. Exception Anti-Debugging INT 2D, INT 0x03, 0xF1 (ICE Breakpoint), 0xCC Detection __try { __asm { int 2dh; // substitute int 3 or __emit 0xF1, 0xCC for other triggers } } __except (EXCEPTION_EXECUTE_HANDLER) { flag = 1; MessageBox(NULL, L"No Debugger Detected", L"No Debugger", MB_OK); } if (flag != 1) MessageBox(NULL, L"Debugger Detected via int2d", L"Debugger Detected", MB_OK);
  • 42. Exception Based Anti-Debugging kernel32!CloseHandle __try { CloseHandle(0x12345678); } __except (EXCEPTION_EXECUTE_HANDLER) { flag = 1; MessageBox(NULL, L"Debugger Detected via kernel32!CloseHandle", L"Debugger Detected", MB_OK); } if (flag == 0) MessageBox(NULL, L"No Debugger Detected", L"No Debugger", MB_OK);
  • 43. Exception Anti-Debugging Single Step Detection (Trap Flag) __try { __asm { PUSHFD; //Saves the flag registers OR BYTE PTR[ESP+1], 1; // Sets the Trap Flag in EFlags POPFD; //Restore the flag registers NOP; // NOP } } __except (EXCEPTION_EXECUTE_HANDLER) { flag = 1; MessageBox(NULL, L"No Debugger Detected", L"No Debugger", MB_OK); } if (flag == 0) MessageBox(NULL, L"Debugger Detected Via Trap Flag", L"Debugger Detected", MB_OK);
  • 44. Exception Anti-Debugging OllyDbg Memory Breakpoint Detection memRegion = VirtualAlloc(NULL, 0x10000, MEM_COMMIT, PAGE_READWRITE); RtlFillMemory(memRegion, 0x10, 0xC3); success = VirtualProtect(memRegion, 0x10, PAGE_EXECUTE_READ | PAGE_GUARD, &oldProt); myproc = (FARPROC) memRegion; success = 1; __try { myproc(); } __except (EXCEPTION_EXECUTE_HANDLER) { success = 0; MessageBox(NULL, L"No Debugger Detected", L"No Debugger Detected", MB_OK); }
  • 45. Exception Anti-Debugging Control C Vectored Exception Handling AddVectoredExceptionHandler(1, (PVECTORED_EXCEPTION_HANDLER)exhandler); SetConsoleCtrlHandler((PHANDLER_ROUTINE)sighandler, TRUE); success = GenerateConsoleCtrlEvent(CTRL_C_EVENT, 0); Using the CMPXCHG8B with the LOCK Prefix SetUnhandledExceptionFilter((LPTOP_LEVEL_EXCEPTION_FILTER) error); __asm { __emit 0xf0; __emit 0xf0; __emit 0xc7; __emit 0xc8; }
  • 46. Process and Thread Block Anti-Debugging
  • 47. Technology Background Process Environment Block (PEB) – Process Base Address – Heap Location – Memory Pointers – Global Flag – OS Version Information (Major/Minor) – isDebugged Flag – … Thread Information Block (TIB) – Thread ID – Process ID – Pointer to process PEB – Error Information – Exception Information – …
  • 48. Process and Thread Block Anti-Debugging Pros – Direct to the process and thread information – Less chance of detection via hooking – Harder to bypass overall Cons – Requires use of undocumented structures – Requires understanding of runtime dynamic linking – More complex to understand
  • 49. Process and Thread Block Anti-Debugging IsDebuggerPresent() Direct PEB Access status = (_NtQueryInformationProcess) (hnd, ProcessBasicInformation, &pPIB, sizeof(PROCESS_BASIC_INFORMATION), &bytesWritten); if (status == 0 ) { if (pPIB.PebBaseAddress->BeingDebugged == 1) { MessageBox(NULL, L"Debugger Detected Using PEB!IsDebugged", L"Debugger Detected", MB_OK); } else { MessageBox(NULL, L"No Debugger Detected", L"No Debugger Detected", MB_OK); PEB ProcessHeap Flag Debugger Detection base = (char *)pPIB.PebBaseAddress; procHeap = base+0x18; procHeap = *procHeap; heapFlag = (char*) procHeap+0x10; last = (DWORD*) heapFlag; if (*heapFlag != 0x00) { … Found a debugger }
  • 50. Process and Thread Block Anti-Debugging NtGlobalFlag Debugger Detection status = (_NtQueryInformationProcess) (hnd, ProcessBasicInformation, &pPIB, sizeof(PROCESS_BASIC_INFORMATION), &bytesWritten); value = (pPIB.PebBaseAddress); value = value+0x68; if (*value == 0x70) { MessageBox(NULL, L"Debugger Detected Using PEB!NTGlobalFlag", L"Debugger Detected", MB_OK); } else { MessageBox(NULL, L"No Debugger Detected", L"No Debugger Detected", MB_OK); }
  • 51. Process and Thread Block Anti-Debugging Vista TEB system DLL pointer strPtr = TIB+0xBFC; // Offset into the target structure delta = (int)(*strPtr) - (int)strPtr; // Ensure that string directly follows pointer if (delta == 0x04) { if (wcscmp(*strPtr, hookStr)==0) { // Compare to our known bad string MessageBox(NULL, L"Debugger Detected Via Vista TEB System DLL PTR", L"Debugger Detected", MB_OK); } else { MessageBox(NULL, L"No Debugger Detected", L"No Debugger", MB_OK); } } else { MessageBox(NULL, L"No Debugger Detected", L"No Debugger", MB_OK); }
  • 53. Hardware and Register Anti-Debugging Pros – Directly checks the hardware – Harder yet to bypass – Fairly easy to implement Cons – Not a whole lot of research in this area – Limited number of techniques available
  • 54. Hardware Register Anti-Debugging Hardware Breakpoint Detection hnd = GetCurrentThread(); status = GetThreadContext(hnd, &ctx); if ((ctx.Dr0 != 0x00) || (ctx.Dr1 != 0x00) || (ctx.Dr2 != 0x00) || (ctx.Dr3 != 0x00) || (ctx.Dr6 != 0x00) || (ctx.Dr7 != 0x00)) { MessageBox(NULL, L"Debugger Detected Via DRx Modification/Hardware Breakpoint", L"Debugger Detected", MB_OK); } else { MessageBox(NULL, L"No Debugger Detected", L"No Debugger", MB_OK); }
  • 55. Hardware Register Anti-Debugging Vmware sldt detection __asm { sldt ldt_info; } if ((ldt_info[0] != 0x00) && (ldt_info[1] != 0x00)) ldt_flag = 1;
  • 57. Timing Based Anti-Debugging Pros – Super easy to implement – Conceptually easy to understand – Can monitor blocks or individual instructions Cons – Very easy to bypass – Can be spotted a mile away
  • 58. Timing Based Anti-Debugging RDTSC Instruction Debugger Latency Detection i = __rdtsc(); j = __rdtsc(); if (j-i < 0xff) { MessageBox(NULL, L“No Debugger Detected Via RDTSC", L“No Debugger Detected", MB_OK); } else { MessageBox(NULL, L"Debugger Detected Via RDTSC", L"Debugger Detected", MB_OK); } NTQueryPerformanceCounter QueryPerformanceCounter(&li); QueryPerformanceCounter(&li2); if ((li2.QuadPart-li.QuadPart) > 0xFF) { GetTickCount Timing timeGetTime Timing
  • 61. Contact Tyler Shields Sr. Security Researcher Veracode, Inc. tshields@veracode.com