Handling the evasion of debugger breakpoints
Another way to detect debuggers or evade them is to detect their breakpoints. Whether they are software breakpoints (such as INT3
), hardware breakpoints, single-step breakpoints (trap flag), or memory breakpoints, malware can detect them and possibly remove them to escape reverse engineer control.
Detecting software breakpoints (INT3)
This type of breakpoint is the easiest to use and the easiest to detect. As we stated in Chapter 2, A Crash Course in Assembly and Programming Basics, this breakpoint modifies the instruction bytes by replacing the first byte with 0xCC (the INT3
instruction), which creates an exception (an error) that gets delivered to the debugger to handle.
Since it modifies the code in memory, it’s easy to scan the code section in memory for the INT3
byte. A simple scan will look like this:
Figure 6.3 – A simple INT3 scan
The only drawback of this approach is that some C++...