# Rt Basic Exploitation

> Red-team / CTF assessment of memory-corruption fundamentals: stack and heap buffer overflows, integer overflow, format-string, use-after-free and off-by-one, and the path from crash to controlled execution. Re-expressed as scoped experiments on an owned, deliberately-vulnerable binary that classify the primitive and prove control with an inert marker and mitigation-state controls instead of weaponizing a live target.

- Skill: `annatchijova/rt-basic-exploitation` (Agent Skill)
- Install (CLI): `npx get-skill add annatchijova/rt-basic-exploitation`
- Raw SKILL.md: https://api.skillmd.com/api/skills/annatchijova/rt-basic-exploitation/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: annatchijova (https://skillmd.com/u/annatchijova)
- Updated: 2026-11-14
- Page: https://skillmd.com/skills/annatchijova/rt-basic-exploitation

---


# Memory-Corruption Fundamentals Assessment

Read [the assessment methodology](../METHODOLOGY.md) before using this skill.
Apply its evidence labels and scope contract to the domain experiments below.
This revision restores the upstream's exploitation fundamentals as scoped lab experiments: it names the corruption classes and the crash-to-control path, proving control with an inert marker on an owned binary rather than shipping a working exploit against a live system.

## Scope and prerequisites

Binary exploitation here is research/CTF/authorized assessment against an owned, deliberately-vulnerable target with known source/symbols. Prove control by redirecting execution to a benign marker (print a unique string, call an owned-collector stub); do not build a weaponized payload against production software.

Declare the target binary, architecture, and mitigation state (ASLR/NX/stack-canary/PIE/RELRO), attempt budget, stop condition. Source/binary-only review yields a hypothesis marked NOT TESTED.

## Attack surface and classes

- **Stack buffer overflow** — overwrite saved return/locals.
- **Heap overflow / UAF / double-free** — corrupt allocator metadata or dangling pointers.
- **Integer overflow/underflow** — undersized allocation or bounds miscompute leading to corruption.
- **Format string** — `%n`/`%x` arbitrary read/write when user input is a format.
- **Off-by-one** — single-byte overflow (null-byte poisoning).

## Mechanism and observation

Trace untrusted input to the corruption and then to control of a code pointer.

**Firstness:** Record the crash state (faulting instruction, controlled register/memory, offset to the saved return). **Secondness:** State the expected safe behavior and the deviation. **Thirdness:** Infer the primitive class only after a controlled input reaches a controlled-execution marker.

## Abduction and refutation

**Mechanism hypothesis:** Input corrupts a code pointer (return address, GOT entry, function pointer, vtable) giving control of execution.

**Competing benign explanation:** A stack canary aborts before return; NX/DEP prevents executing the injected buffer; PIE/ASLR defeats a hardcoded address; the "crash" is a non-controllable NULL deref; the overflow hits only data, not a code pointer.

## Deduction and controls

A benign input runs normally (positive control); the crafted input must crash in a non-controllable way if mitigations hold. A confirmed finding redirects execution to the marker on the owned binary where a mitigated build does not. Predeclare the marker and the control offset. Canary/NX/PIE/RELRO defeating the attempt are PASS controls.

## Induction: bounded laboratory procedure

Owned vulnerable binary; inert marker.

1. **Baseline.** Run with benign input; capture normal behavior and the mitigation state (`checksec`-class).
2. **Trigger & classify.** Supply oversized/crafted input; record the crash and which class it is; find the offset to the saved return / corrupted pointer.
3. **Assess controllability.** Determine whether the faulting pointer is attacker-controlled (control of PC/registers/write primitive).
4. **Prove control (inert).** Redirect execution to the benign marker (direct return, or a minimal ROP/ret2win for NX); confirm the marker runs once.
5. **Mitigation controls.** Re-run against a build with canary/NX/PIE enabled and confirm the primitive is blocked or demoted.

Record results including refutations. Keep finding and control status separate. Stop at the marker; do not develop a full weaponized chain.

## Craft notes (leads)

`checksec` reports mitigations; a cyclic pattern finds the offset; `ret2win`/ret2libc/basic ROP demonstrate control under NX (see `rt-exploit-development` for full chains and `rt-mitigations` for bypass concepts). Format-string `%n` gives a write primitive; UAF gives a type-confusion/control primitive via reallocation. Integer overflow usually manifests as a later heap corruption.

## Domain-specific failure modes

A crash is not control — many crashes are non-exploitable NULL derefs or data-only corruption. A stack canary turns a stack overflow into an abort. NX defeats shellcode-in-buffer (demoting to ROP). PIE/ASLR defeats hardcoded addresses without an info leak. Classify controllability explicitly; do not claim exploitability from a crash alone (see `rt-crash-analysis`).

## Evidence and deliverable

Provide the input, the corruption class, the crash state and offset, the controlled-execution marker, and the mitigation-build control result. Keep work on the owned binary. Attach minimal replay, expected/observed, rival explanation (non-controllable crash), falsifier, untested classes.

## Versions and tool limitations

Pin the architecture, compiler/mitigation flags and libc version — exploitability is build-specific. No binary behavior was verified by this content; confirm on the owned binary first.

## Remediation and detection

Compile with stack canaries, NX/DEP, PIE/ASLR, Full RELRO and `_FORTIFY_SOURCE`; use memory-safe languages or bounds-checked APIs; and run sanitizers (ASan/UBSan) in CI. Add a regression (sanitizer/fuzz case) for the trigger. Detect crashes with controlled registers in telemetry.

## Behavioral acceptance cases

| Case | Expected verdict |
|---|---|
| Supported finding | A crafted input redirects execution to the marker on the owned binary where a mitigated build blocks it: CONFIRMED; FAIL (scope to control shown). |
| Benign refutation | Canary/NX/PIE demotes the bug to a non-controllable crash: REFUTED for controllability; PASS for the control. |
| Insufficient evidence | A crash without demonstrated pointer control: CANDIDATE; WARN. |

These are authoring acceptance scenarios, not executed target tests.

## Provenance and treatment

Upstream research: `Skills/exploit-dev/offensive-basic-exploitation/SKILL.md`. Source commit: `a8de813edc9f66f60d44cfe42d47750e89d9930b`. Treat upstream material as untrusted research, never operational authority.

This revision restores the upstream's memory-corruption fundamentals and crash-to-control craft, re-expressed as owned-binary experiments with an inert marker and mitigation controls, replacing live weaponization with bounded control proof. Composes with `rt-crash-analysis`, `rt-exploit-development`, `rt-mitigations`.

