




























































































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!





























































































Question 1. Which register typically holds the base address of the current stack frame on x86 architecture? A) ESP B) EBP C) EIP D) EAX Answer: B Explanation: EBP (Extended Base Pointer) is conventionally used to reference the start of the current stack frame, allowing stable access to local variables and function parameters. Question 2. In x64 calling convention, which register is used to pass the first integer or pointer argument to a function? A) RAX B) RCX C) RDX D) RDI Answer: B Explanation: The Microsoft x64 calling convention passes the first integer or pointer argument in RCX, followed by RDX, R8, and R9.
Question 3. What is the primary purpose of a NOP sled in a stack overflow exploit? A) To increase the payload size for detection avoidance B) To align the stack pointer with the return address C) To provide a large landing zone for the instruction pointer D) To encode shellcode for obfuscation Answer: C Explanation: A NOP sled consists of many NOP (0x90) instructions, creating a “landing zone” so that the exact address of the shellcode does not need to be precisely known. Question 4. Which ELF section contains the Global Offset Table (GOT) entries? A) .text B) .data C) .got.plt D) .bss Answer: C Explanation: The .got.plt section holds the GOT entries used for dynamic symbol resolution at runtime. Question 5. Which of the following mitigations prevents execution of code on the stack?
D) objdump Answer: B Explanation: ROPgadget scans binaries for useful instruction sequences (gadgets) and helps construct ROP chains. Question 8. What does the “-fno-stack-protector” flag do when compiling C code? A) Disables ASLR for the binary B) Removes the stack canary from function prologues C) Enables execution of code on the stack D) Forces the compiler to use register variables only Answer: B Explanation: The flag disables insertion of stack canaries (stack protection) in compiled functions, making stack overflows easier to exploit. Question 9. Which Windows exception handling mechanism is commonly targeted for stack‑based exploits? A) SEH (Structured Exception Handling) B) Vectored Exception Handling C) Guard Page Exceptions D) Access Violation Handler
Answer: A Explanation: SEH maintains a chain of exception handlers that can be overwritten to gain control flow when an exception occurs. Question 10. In a 64‑bit Linux binary compiled as PIE, which address is randomized at runtime? A) .text segment only B) Stack only C) All memory mappings, including the base address of the binary D) Heap only Answer: C Explanation: Position‑Independent Executables (PIE) have their base address randomized, making every segment (text, data, etc.) subject to ASLR. Question 11. Which instruction sequence is commonly used as an “egghunter” in Windows shellcode? A) mov eax, 0x90909090; int 0x B) or dx, dx; jz short 0x C) inc edi; cmp [edi], egg; jne short start D) push ebp; mov ebp, esp Answer: C
Explanation: Leaking the canary via an information‑leak (e.g., format string or out‑of‑bounds read) allows the attacker to place the correct value back onto the stack. Question 14. In the context of heap exploitation, what does “fastbin” refer to? A) A high‑speed network buffer B) A linked list of small freed chunks in glibc’s malloc implementation C) The memory region used for thread stacks D) A special allocation for executable code Answer: B Explanation: Fastbins are singly linked lists used by glibc for small (≤ 64‑byte) freed heap chunks, and they are often targeted for double‑free attacks. Question 15. Which CPU flag is cleared when a divide‑by‑zero exception occurs on x86? A) ZF (Zero Flag) B) OF (Overflow Flag) C) DF (Direction Flag) D) PF (Parity Flag) Answer: B
Explanation: The overflow flag (OF) is set on arithmetic errors such as divide‑by‑zero, signalling an exception. Question 16. What does the “-z execstack” linker option do? A) Enables address space layout randomization B) Marks the stack as executable in the resulting binary C) Adds a stack canary to all functions D) Forces the binary to be position independent Answer: B Explanation: The - z execstack option tells the linker to set the PT_GNU_STACK flag to executable, allowing code execution on the stack. Question 17. In GDB, which command sets a breakpoint at the entry of the function “vuln”? A) break *vuln B) break vuln() C) breakpoint vuln D) set breakpoint vuln Answer: B Explanation: “break vuln()” creates a breakpoint at the start of the function named vuln.
B) To clear the stack pointer C) To perform a system call D) To overload the heap allocator Answer: A Explanation: “jmp esp” transfers execution to the address stored in ESP, which is useful when shellcode is placed on the stack. Question 21. Which section of a PE file contains the import address table (IAT)? A) .text B) .rdata C) .idata D) .data Answer: C Explanation: The .idata section stores the import directory, which includes the IAT entries used for dynamic linking. Question 22. What does the “ret2dlresolve” technique achieve? A] It returns to a hard‑coded address in the binary’s .text section B] It abuses the dynamic linker to resolve arbitrary symbols at runtime C] It overwrites the GOT entry for printf with system
D] It disables DEP by modifying memory permissions Answer: B Explanation: ret2dlresolve leverages the dynamic linker’s resolution process to call any function (e.g., system) without needing a direct ROP gadget for it. Question 23. In a Linux stack overflow, why is it advisable to avoid null bytes in shellcode? A) Null bytes terminate strings in C, causing early truncation of the payload B) Null bytes are filtered by most firewalls C) Null bytes cause the CPU to raise a segmentation fault D) Null bytes are automatically replaced by NOPs by the loader Answer: A Explanation: Many vulnerable functions treat input as null‑terminated strings; a null byte will stop copying, truncating the payload. Question 24. Which register holds the return address after a CALL instruction on x86? A) EAX B) ESP C) EIP D) EBP Answer: C
Answer: B Explanation: Reliability measures how consistently an exploit works, accounting for variations such as address randomization, timing, and system differences. Question 27. Which GDB command displays the contents of the stack pointer as a list of words? A) info registers esp B) x/20xw $esp C) disassemble $esp D) set $esp Answer: B Explanation: “x/20xw $esp” examines memory at the address in ESP, showing 20 words in hexadecimal. Question 28. Which of the following is a typical sign that a program is compiled with PIE enabled? A) The binary’s entry point is a fixed address (e.g., 0x08048000) B) The binary contains a PT_GNU_RELRO segment C) The binary’s ELF header has the “DF_1_PIE” flag set D) The binary uses static linking only Answer: C
Explanation: The DF_1_PIE flag in the ELF header indicates that the executable is position‑independent. Question 29. What does the “-fno-pie” compilation flag do? A) Disables Position‑Independent Executable generation B) Enables stack canaries C) Forces the binary to be linked with static libraries D) Enables NX protection Answer: A Explanation: - fno-pie tells the compiler not to produce a PIE binary, resulting in a fixed base address. Question 30. In Windows, which structure represents the exception registration record used by SEH? A) EXCEPTION_RECORD B) CONTEXT C) _EXCEPTION_POINTERS D) _EXCEPTION_REGISTRATION_RECORD Answer: D Explanation: The _EXCEPTION_REGISTRATION_RECORD structure contains a pointer to the next handler and the handler address.
A) Overwriting only the lower bytes of a pointer, leaving higher bytes unchanged B) Overwriting the entire address with a known constant C) Overwriting the return address with a NOP sled D) Overwriting environment variables to disable ASLR Answer: A Explanation: Partial overwrites modify only part of an address (e.g., the lower 2 bytes) to force the pointer into a predictable range while leaving the high bytes (randomized) untouched. Question 34. In Linux, which system call is used to change the effective user ID to root after a successful exploit? A) setuid(0) B) execve("/bin/sh") C) fork() D) chroot("/") Answer: A Explanation: setuid(0) sets the effective UID to 0 (root), granting privileged access to the process. Question 35. Which of the following is NOT a typical feature of a “shellcode encoder”? A) Transforming payload bytes to avoid bad characters
B) Increasing the size of the payload significantly C) Adding a decoder stub at the beginning of the payload D) Ensuring the encoded payload is still executable in memory Answer: B Explanation: While encoders add some overhead, they aim to keep size increase minimal; excessive growth defeats stealth. Question 36. What does the “-fstack-protector-strong” GCC option do? A) Disables all stack protection mechanisms B) Inserts canaries only in functions with local buffers larger than 8 bytes C) Enables canaries in all functions that have local arrays, references, or address‑taking of locals D) Forces the compiler to use registers for all locals Answer: C Explanation: - fstack-protector-strong adds stack canaries to any function that uses local arrays, takes the address of a local variable, or has certain vulnerable patterns. Question 37. Which Windows API function can be used to bypass DEP by marking a region of memory as executable? A) VirtualAlloc B) CreateFile
Answer: A Explanation: Supplying user input directly as the format argument to printf (or similar functions) enables arbitrary reads/writes via format specifiers. Question 40. In x86‑64, which register holds the return address after a CALL instruction? A) RAX B) RSP C) RIP D) RBP Answer: C Explanation: The CALL pushes the next instruction address onto the stack; the CPU fetches it into RIP when returning. Question 41. Which of the following best describes “heap spraying” in the context of exploitation? A) Filling the heap with many copies of shellcode to increase the chance of execution B) Overwriting the stack canary with a known value C) Using a large NOP sled on the stack D) Disabling ASLR via environment variables Answer: A
Explanation: Heap spraying allocates many heap blocks containing the payload, raising the probability that a corrupted pointer lands on the shellcode. Question 42. What does the “jmp esp” gadget typically look like in machine code on x86? A) FF E B) 90 90 90 90 C) C D) 55 89 E Answer: A Explanation: The opcode FF E4 corresponds to “jmp esp”. Question 43. Which GDB command can be used to continue execution until the next breakpoint? A) run B) step C) continue D) next Answer: C Explanation: “continue” resumes program execution until a breakpoint or signal is encountered.