
Introduction:
Threat actors and malware authors use various anti-analysis techniques to keep initial access, execution, persistence, privilege escalation, credential access, lateral movement, command and control, and exfiltration of data hidden from the reverse engineers that try to peer inside their code. Usually this makes post-detection analysis more difficult. The malicious binaries below exhibit evasive behaviors which aim to detect or disrupt the analysis in a virtual machine or in your favorite debugger.
SonicWall Capture Labs Threat Research Team will present anti-debugging techniques and main concepts that cover a variety of top malware categories in today's malware. In anti-debugging, malware detects debuggers by searching for known indicators or artifacts used to implement core debugger functionalities, such as tracing, breakpoints, and hooking.
In this lower section, we cover only anti-debugging techniques used in the top malware families we have categorized below enabling us to present an analysis on the real state of evasion techniques in use by malware today. This is by no means a comprehensive catalog of known anti-debugging techniques used by the Windows API:
NtQuerySystemInformation:
NtQuerySystemInformation() function call of the ntdll.dll can be used with the undocumented SystemKernelDebuggerInformation as a SystemInformationClass parameter to detect the presence of a debugger. The result is stored in the buffer pointed by the SystemInformation parameter that has 2 bytes representing two flags. Each one with 8 bits (LSB KdDebuggerEnabled and MSB KdDebuggerNotPresent). KdDebuggerNotPresent is FALSE if a debugger is present.
NtQueryInformationProcess:
NtQueryInformationProcess() used with ProcessDebugPort as a ProcessInformationClass parameter will set (-1)0xffffffff in the ProcessInformation parameter if a process is being debugged.
NtQueryInformationProcess() used with ProcessDebugObjectHandle as a ProcessInformationClass parameter to query for the debug object handle.
NtQueryInformationProcess() used with ProcessDebugFlags as a ProcessInformationClass parameter to set the inverse of EPROCESS->NoDebugInherit bit in the ProcessInformation parameter.
Windows Debugging Services:
asm { int 2dh }, is the interface for the Win32 kernel and provides kernel debugging services to user level debuggers and remote debuggers such as IMM, Kd and WinDbg.
Hardware Breakpoints:
When an exception occurs, windows creates a context structure to pass to the exception handler. This structure will contain the values of the debug registers. The debug registers will contain values that will reveal the presence of a debugger. Another way includes using GetCurrentThread() and GetThreadContext() then testing the debug registers for values.
CheckRemoteDebuggerPresent:
CheckRemoteDebuggerPresent() is a kernel32.dll function that sets (-1)0xffffffff in the DebuggerPresent parameter if a debugger is present. Internally, it also uses NtQueryInformationProcess() with ProcessDebugPort as a ProcessInformationClass parameter.
Instruction Counting:
An exception handler is registered to deal with the EXCEPTION_SINGLE_STEP(0x80000004) exception. This will include the use of other Win32 APIs such as GetThreadContext(). The handler will simply count how many times it was reached and then change EIP to point to a new instruction and resume execution.
Find Window:
FindWindow() function can be used to find opened debuggers using both parameters, lpClassName and lpWindowName. Example: lpClassName: "OLLYDBG" or lpWindowName: "IDA".
Execution Timing:
When a debugger is present, the time elapsed between instructions are measured. RDTSC assembly instruction is a very popular anti-debugging technique. However, others are also used such as RDPMC, RDMSR, GetTickCount(), GetLocalTime(), GetSystemTime(), and QueryPerformanceCounter().

Malware Family Coverage:
Botnet - (Pushdo):
Fileless - (Kovter):
Cryptojack - (Coinminer):
Ransomware - (Cerber):
RAT - (Ghost):
Spyware - (Lokibot):
Trojan - (agentTesla):
Virus - (Ramnit):
SonicWall, GAV Cloud, provides protection as follows:
Share This Article

An Article By
An Article By
Security News
Security News