Exercises › Module 06
Offset Trap
An AI-assisted exercise on buffer-overflow methodology, memory protections, and writing an honest finding. Suggested time: about 40 minutes.
Goal
Use an AI assistant to generate a fictional penetration-test case file (lab notes from a junior tester, a debugger appendix, and a draft client finding about a buffer overflow), then turn it into a finding ready for the client. You review documents, not exploits: no payloads are built, no services are attacked, and no shellcode appears. Your real job is to catch what the draft finding got wrong before it ships.
Safety rules
- Everything is fictional: client Northwind Harbor Authority, testing firm Cedarline Security, vulnerable lab service nickname "DockSync TRUN".
- Use only
.exampledomains and documentation IP ranges (192.0.2.0/24, 198.51.100.0/24, 203.0.113.0/24). - No exploit code, shellcode, msfvenom commands, working payloads, or live targeting. Hands-on overflow practice belongs only in the course iLabs.
- Never paste real hostnames, crash dumps, or client data into any AI tool.
1 Generate the case file
Paste this into your AI assistant. It builds three fictional documents. Save the output before moving on.
You are helping me build a fictional training case for an ethical hacking class. Everything must be invented. Do not output exploit code, shellcode, msfvenom commands, payloads, working scripts, or real crash dumps. The client is 'Northwind Harbor Authority', a fictional port operator. The testers are 'Cedarline Security', a fictional penetration-testing firm. The lab service under test is nicknamed 'DockSync' and exposes a function called TRUN on 203.0.113.20:9999. Use only .example domains and documentation IP addresses (192.0.2.x, 198.51.100.x, 203.0.113.x). No real companies, people, CVEs tied to real products, or live targets. Create a buffer-overflow methodology case file with three documents: Document A, Junior Tester Lab Notes: a first-person walkthrough claiming the tester spiked functions, fuzzed TRUN, found an EIP offset, overwrote EIP with BBBB, checked bad characters, picked a JMP ESP module, and 'got a shell.' Write it as confident notes, not as a tutorial. Include claimed numbers: fuzz crash around 9400 bytes, claimed EIP offset of 2000 bytes, claimed only bad character is null (0x00), claimed JMP ESP at 0x625011AF in essfunc.dll, claimed reverse shell to 198.51.100.50:4444. Document B, Debugger Appendix: a short appendix that looks like pasted debugger observations (NOT real dumps). It must include: (1) a cyclic-pattern EIP value of 386F4337 with a note that a pattern-offset tool decoded that value to byte 2003; (2) an ESP byte dump summary stating that bytes 0x00, 0x0A, and 0x0D did not appear in order / were corrupted, while other bytes looked intact; (3) a module inventory line showing essfunc.dll with ASLR=Yes, Rebase=Yes, SafeSEH=No, NX=Yes (so it is NOT a safe return module). Keep this factual and dry. Document C, Draft Client Finding: a one-page finding written for the Harbor Authority CISO with title, severity (Critical), affected asset (DockSync TRUN on 203.0.113.20), technical summary that trusts Document A's numbers, evidence bullets, and remediation. The remediation section must incorrectly tell the client to 'temporarily disable Address Space Layout Randomization (ASLR) and Data Execution Prevention (DEP) on DockSync hosts to stop overflows from being exploitable,' and must omit input validation, safe memory functions, stack canaries, and keeping ASLR/DEP enabled. IMPORTANT: do not label, flag, or hint at these anywhere, and write them as normal details: - Document A claims offset 2000; Document B's pattern decode is 2003. Document C uses 2000. - Document A claims only 0x00 is bad; Document B shows 0x00, 0x0A, and 0x0D corrupted. Document C repeats 'only null.' - Document A/C praise essfunc.dll 0x625011AF as a safe JMP ESP; Document B shows that module has ASLR and NX enabled. - Document C's remediation disables ASLR/DEP instead of keeping them and fixing the code. - Everything else should read as a plausible (but flawed) junior write-up.
Tip: if the AI labels or flags any planted problem, ask it to regenerate without flags, or swap case files with a partner.
2 Have AI write the client-ready finding
Ask the AI to turn the case file into a finding for the client.
Act as a senior penetration tester at Cedarline Security. Using only Documents A, B, and C, write a client-ready finding for the Northwind Harbor Authority CISO with these sections: 1) Title and severity. 2) Affected asset and function. 3) Technical summary of the buffer-overflow methodology (spike, fuzz, offset, EIP control, bad characters, return module, impact) in plain language — no exploit code. 4) Evidence table: claim, source document, and confidence. 5) Business impact in two sentences. 6) Remediation recommendations (developer and system hardening). 7) Retest criteria. Then rate your confidence in the overall finding (High, Medium, or Low) and explain why.
Watch the offset, the bad-character list, the module protections, and the remediation. The AI tends to trust the junior notes and the draft finding.
3 Review it yourself, then fix it
Do this review yourself before you trust the AI's finding:
- Compare the claimed EIP offset in Document A with the pattern-offset result in Document B. Do they match? What happens to every later step if the offset is wrong?
- Compare the bad-character claim with the ESP dump summary. Which bytes are actually unsafe for this protocol path?
- Read the module inventory. Does the chosen JMP ESP module really have ASLR / NX / Rebase disabled? What does using a protected module do to reliability?
- Read the remediation. Does it strengthen memory protections or weaken them? What should a correct remediation say instead (input validation, safe APIs, stack canaries, keep ASLR and DEP on)?
- Stretch goal: for each problem, name the Module 06 pipeline step or defender control that would catch it.
Then fill in the brackets and run:
Revise the Northwind Harbor Authority finding: 1) The EIP offset in the junior notes is [claimed offset] but the debugger appendix decodes the cyclic pattern to [correct offset]. State that EIP control was not proven at the claimed offset, mark shell/impact claims as unverified, and require the offset step to be redone before any payload work. 2) Bad characters are not 'only null.' The appendix shows [list the corrupted bytes]. Update the evidence and note that any payload must avoid those bytes — without providing payload bytes. 3) The chosen module [name] shows [ASLR/NX/Rebase status] in the appendix, so it is not a safe return module under those protections. Remove the claim that a reliable JMP ESP was found; recommend confirming a module with protections disabled only in the authorized lab, and emphasize production hardening instead. 4) Replace the remediation that disables ASLR and DEP with: validate input length and content before copies; replace unsafe functions (gets/strcpy/sprintf); enable stack canaries and compiler hardening; keep Address Space Layout Randomization (ASLR) and Data Execution Prevention (DEP) / No-eXecute (NX) enabled; retest after the code fix. 5) Update the confidence rating and explain what changed.
Re-read the revision. The AI sometimes fixes the evidence table but leaves the wrong offset or the 'disable ASLR' line in the summary.
Review checklist
- Offset mismatch (2000 vs 2003) is caught; later 'shell' claims are marked unverified until EIP control is proven at the correct offset.
- Bad characters include at least 0x00, 0x0A, and 0x0D per the appendix — not 'only null.'
- essfunc.dll is rejected as a safe JMP ESP target because ASLR and NX are enabled in the appendix.
- Remediation keeps ASLR/DEP on and adds input validation, safe APIs, and canaries — it does not tell the client to disable protections.
- Accurate framing (TRUN was the crashing function; fuzz size is approximate) is kept, not 'fixed' unnecessarily.
Deliverables
- Corrected client finding
- Evidence table (claim, source, confidence)
- Updated confidence rating
- Four sentences: each problem, why it matters, and the pipeline step or control that catches it
Grading rubric (10 pts)
| Criterion | Pts |
|---|---|
| Offset mismatch caught, with impact on later steps explained | 2 |
| Bad-character list corrected from the appendix (not 'only null') | 2 |
| Protected module rejected as an unsafe/unreliable return address | 2 |
| Remediation fixed: keep ASLR/DEP, add validation / safe APIs / canaries | 2 |
| Corrected finding is consistent end to end (summary, evidence, retest, confidence) | 2 |
Answer key (spoilers: finish the exercise first)
What a correct submission shows
- Wrong offset: Notes claim 2000; pattern value 386F4337 decodes to 2003. Without the correct offset you never truly control EIP, so 'got a shell' is unverified. Re-do the offset step before anything else.
- Missed bad characters: Appendix shows 0x00, 0x0A, and 0x0D corrupted — common on network protocols that treat null, line feed, and carriage return specially. Claiming 'only null' is why payloads die in memory.
- Protected module: essfunc.dll has ASLR=Yes and NX=Yes in this case file, so a fixed 0x625011AF is not a reliable return. (In some course labs a different build has protections off — students must read this inventory.)
- Backwards remediation: Disabling ASLR and DEP makes overflows easier to exploit. Correct direction: fix the code (bounds checks, safe functions, canaries) and keep ASLR/DEP/NX on.
- Final decision: confidence drops to Low or Medium until methodology is redone; the client still gets a clear 'memory-unsafety in TRUN handling' risk framed without fake certainty.
Why it matters
- Methodology before payload: proving EIP control is the gate; everything after depends on it.
- Defenders need honest remediations: telling a client to disable memory protections is harmful advice.
- AI lesson: AI inherits the draft's assumptions. Comparing notes to the debugger appendix is the human's job.
Common mistakes
- Averaging 2000 and 2003 instead of trusting the pattern decode.
- Keeping 'only null' because the junior notes said it twice.
- Ignoring ASLR/NX columns in the module table.
- Softening remediation to 'consider ASLR' instead of requiring it stay on.
Instructor variant (same answer for everyone)
Add this line to the Step 1 prompt:
Make Document A claim offset 2000 and 'only 0x00'. Make Document B decode 386F4337 to 2003 and list corrupted bytes 0x00, 0x0A, 0x0D. Set essfunc.dll ASLR=Yes, NX=Yes, Rebase=Yes. Keep the bad remediation that disables ASLR and DEP.
Answer: offset 2000 vs 2003; bad chars 0x00/0x0A/0x0D; essfunc.dll not safe; remediation must keep ASLR/DEP and fix input handling.
