Spotting breakpoints
The procedure of examining memory page permissions can aid in identifying program breakpoints set by a debugger. Initially, it is necessary to ascertain the total count of pages within the process working set and allocate a sufficiently large buffer to store all relevant information. Subsequently, the task involves iterating through memory pages and inspecting the permissions associated with each, with a specific focus on executable pages. We analyze each executable page to determine whether its IF
statement is utilized by processes other than the current one. By default, memory pages are shared among all concurrently running programs. However, when a write operation occurs (e.g., inserting an INT 3
instruction into the code), a copy of the page is mapped to the process’s virtual memory. This copy-on-write mechanism results in the page no longer being shared after a write operation.
Practical example
The following is a simple PoC code in C that demonstrates...