T1622 - Debugger Evasion
Description from ATT&CK (opens in a new tab)
Adversaries may employ various means to detect and avoid debuggers. Debuggers are typically used by defenders to trace and/or analyze the execution of potential malware payloads.(Citation: ProcessHacker Github)Debugger evasion may include changing behaviors based on the results of the checks for the presence of artifacts indicative of a debugged environment. Similar to Virtualization/Sandbox Evasion (opens in a new tab), if the adversary detects a debugger, they may alter their malware to disengage from the victim or conceal the core functions of the implant. They may also search for debugger artifacts before dropping secondary or additional payloads.
Specific checks will vary based on the target and/or adversary, but may involve Native API (opens in a new tab) function calls such as
IsDebuggerPresent()
andNtQueryInformationProcess()
, or manually checking theBeingDebugged
flag of the Process Environment Block (PEB). Other checks for debugging artifacts may also seek to enumerate hardware breakpoints, interrupt assembly opcodes, time checks, or measurements if exceptions are raised in the current process (assuming a present debugger would “swallow” or handle the potential error).(Citation: hasherezade debug)(Citation: AlKhaser Debug)(Citation: vxunderground debug)Adversaries may use the information learned from these debugger checks during automated discovery to shape follow-on behaviors. Debuggers can also be evaded by detaching the process or flooding debug logs with meaningless data via messages produced by looping Native API (opens in a new tab) function calls such as
OutputDebugStringW()
.(Citation: wardle evilquest partii)(Citation: Checkpoint Dridex Jan 2021)
Atomic Tests
Atomic Test #1 - Detect a Debugger Presence in the Machine
Detecting a running debugger process or if the debugger is attached to a process via PowerShell
Supported Platforms: Windows
auto_generated_guid: 58bd8c8d-3a1a-4467-a69c-439c75469b07
Attack Commands: Run with powershell
! Elevation Required (e.g. root or admin)
# Check for common debugger processes
$debuggerProcesses = Get-Process | Where-Object { $_.ProcessName -match "dbg" -or $_.ProcessName -match "debug" }
# Check for debugging flags
$debuggingFlags = [System.Diagnostics.Debugger]::IsAttached