hardMultiple ChoiceObjective-mapped
PT0-002 Practice Question: During an internal penetration test, a tester…
During an internal penetration test, a tester discovers a Windows server running a custom service that is vulnerable to a stack-based buffer overflow. The binary has Data Execution Prevention (DEP) enabled but Address Space Layout Randomization (ASLR) is disabled. Which exploitation technique would be MOST effective to achieve code execution?
⚠ Common exam trap
It's easy for candidates to assume DEP can be bypassed simply by enabling execution on the stack (option D) without realizing that doing so requires a ROP chain or similar technique to call VirtualProtect, making option C the more direct and effective approach.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
Constructing a ROP chain using gadgets from loaded DLLs to simulate shellcode execution
With DEP enabled, the stack is marked non-executable, so injecting shellcode directly (option A) would fail. ASLR being disabled means the addresses of loaded DLLs are predictable, making it feasible to construct a ROP chain using gadgets from those DLLs to simulate shellcode execution. Option C is correct because ROP chains bypass DEP by reusing existing executable code (gadgets) without needing to execute code on the stack.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Injecting shellcode directly onto the stack and overwriting the return address to jump to it
Why it's wrong here
Directly injecting shellcode onto the stack and redirecting execution to it fails because DEP marks the stack as non-executable. With the NX bit set, the CPU refuses to fetch instructions from stack pages, and any attempt to jump to the injected shellcode triggers an access violation (0xC0000005). Even with a precise overwrite of the saved return address, the exploit cannot gain code execution without first disabling DEP or using an indirect technique.
- ✗
Using a return-to-libc attack to call system() with a command string
Why it's wrong here
A return-to-libc attack is ineffective here because Windows servers do not utilise the `libc` library or its `system()` function in the same manner as Unix-like systems. Windows relies on its native API, such as `kernel32.dll`, for system calls. This technique is tempting as it is a classic method for bypassing Data Execution Prevention by executing existing code. It would be highly effective on a Linux system with DEP enabled and Address Space Layout Randomisation disabled, where `system()` is predictably located.
- ✓
Constructing a ROP chain using gadgets from loaded DLLs to simulate shellcode execution
Why this is correct
A ROP chain reuses sequences of existing instructions (gadgets) terminated by a ret, all located in executable modules such as loaded DLLs or system libraries. Because these gadgets reside in executable memory, DEP does not block them; chaining them lets the attacker simulate arbitrary logic or call functions like VirtualProtect to change memory permissions and then execute shellcode. With ASLR disabled, gadget addresses are fixed and predictable, making this a reliable bypass of DEP on Windows.
- ✗
Enabling the execute bit on the stack via a memory corruption primitive
Why it's wrong here
Altering the execute permission of the stack typically requires modifying page-table entries or invoking a privileged API like VirtualProtect, which itself demands code execution. A memory corruption primitive alone only gives the attacker read/write access to process memory, not the ability to change hardware-enforced memory protection; doing so would require an additional vulnerability, such as an arbitrary write to kernel structures. This approach is neither standard nor practical, as it introduces extra attack surface and is far more complex than a straightforward ROP chain.
Go deeper
Related to this question
Learn chapter
Penetration Testing Methodology
Key term
Shellcode
Shellcode is a small piece of code used as a payload in the exploitation of a software vulnerability, typically giving an attacker a command shell on the target machine.
Key term
Buffer overflow
A buffer overflow is a type of software vulnerability where a program writes more data to a memory buffer than it was designed to hold, causing adjacent memory to be overwritten.
About these practice questions
One of 185 original PT0-003 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This PT0-003 practice question is part of Courseiva's free CompTIA certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the PT0-003 exam.