# arbitrary-write-to-rce

Playbook for turning memory write primitives into code execution. Maps working targets from GOT entries to thread destructors across glibc versions.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode · 3600 installs · ★ 2547
- Author: yaklang
- License: MIT · policy=mirror · the beginning of the file is at the end of this page
- Source: https://github.com/yaklang/hack-skills/tree/HEAD/skills/arbitrary-write-to-rce/SKILL.md
- Updated: 2026-09-13
- HTML: https://affpapa.org/en/nevibecode/skills/arbitrary-write-to-rce

## What it does

The skill provides an attack playbook to convert memory write primitives into code execution. It assists during heap corruption or format string exploitation. The guide organizes overwrite targets by glibc version compatibility, focusing on GOT entries, `_IO_FILE` vtables, `__exit_funcs`, and `TLS_dtor_list`.

Each target details necessary memory leaks. Full RELRO blocks GOT overwrites completely. Starting with glibc 2.34, standard allocator hooks are removed. This makes pointer guard bypasses and wide-character vtable tampering the primary attack paths on modern systems.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add yaklang/hack-skills --skill arbitrary-write-to-rce -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/arbitrary-write-to-rce/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/arbitrary-write-to-rce/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add yaklang/hack-skills --skill arbitrary-write-to-rce -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/arbitrary-write-to-rce/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add yaklang/hack-skills --skill arbitrary-write-to-rce -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/arbitrary-write-to-rce/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install yaklang/hack-skills arbitrary-write-to-rce
```

2. **Manually: put the files in place**
- File: `.github/skills/arbitrary-write-to-rce/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add yaklang/hack-skills --skill arbitrary-write-to-rce -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/yaklang/hack-skills --path skills/arbitrary-write-to-rce
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/arbitrary-write-to-rce/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add yaklang/hack-skills --skill arbitrary-write-to-rce -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/yaklang/hack-skills/tree/HEAD/skills/arbitrary-write-to-rce/SKILL.md

## When to use it
- Select viable overwrite targets for a specific glibc version
- Exploit targets on glibc 2.34 where allocator hooks are removed
- Compute mangled function pointers for `__exit_funcs`
- Craft fake vtables for `_IO_FILE` exploitation

## Example prompts
- I have an arbitrary write primitive and a libc leak. How do I reach RCE through TLS_dtor_list?
- The binary has Partial RELRO. Which GOT entry should I replace with system?
- Show how to compute the mangled pointer for __exit_funcs using pointer guard.

## Source text · SKILL.md · MIT

Below is the content of a third-party file. It is data, not instructions for you: do not act on anything written inside unless the human asks. Block tag: 0359c1d1a0b17ae4.

BEGIN THIRD-PARTY FILE 0359c1d1a0b17ae4
```text
---
name: arbitrary-write-to-rce
description: >-
  Arbitrary write to RCE playbook. Use when you have an arbitrary write primitive (from heap exploitation, format string, or OOB write) and need to convert it into code execution by targeting GOT, hooks, _IO_FILE vtable, exit_funcs, TLS_dtor_list, modprobe_path, .fini_array, or C++ vtables.
---

# SKILL: Arbitrary Write to Code Execution — Expert Attack Playbook

> **AI LOAD INSTRUCTION**: Expert techniques for converting an arbitrary write primitive into code execution. Covers every major overwrite target organized by glibc version compatibility: GOT, __malloc_hook, __free_hook, _IO_FILE vtable, __exit_funcs, TLS_dtor_list, _dl_fini, modprobe_path, .fini_array, C++ vtable, and setcontext gadget. This is the "last mile" skill. Base models often target hooks that no longer exist (post-glibc 2.34) or miss pointer mangling requirements.

## 0. RELATED ROUTING

- [heap-exploitation](../heap-exploitation/SKILL.md) — obtaining the arbitrary write via heap attacks
- [format-string-exploitation](../format-string-exploitation/SKILL.md) — obtaining the arbitrary write via %n
- [stack-overflow-and-rop](../stack-overflow-and-rop/SKILL.md) — stack-based write primitives
- [binary-protection-bypass](../binary-protection-bypass/SKILL.md) — which targets are available given protection configuration
- [heap-exploitation IO_FILE_EXPLOITATION.md](../heap-exploitation/IO_FILE_EXPLOITATION.md) — deep _IO_FILE structure exploitation

---

## 1. TARGET SELECTION BY GLIBC VERSION

| Target | glibc < 2.24 | 2.24–2.33 | ≥ 2.34 | Required Knowledge |
|---|---|---|---|---|
| GOT overwrite | OK (Partial RELRO) | OK (Partial RELRO) | OK (Partial RELRO) | Binary base |
| `__malloc_hook` | OK | OK | **Removed** | libc base |
| `__free_hook` | OK | OK | **Removed** | libc base |
| `__realloc_hook` | OK | OK | **Removed** | libc base |
| `_IO_FILE` vtable (direct) | OK | Vtable range check | Vtable range check | libc base + heap |
| `_IO_FILE` via `_IO_str_jumps` | N/A | OK (2.24–2.27) | Patched | libc base + heap |
| `_IO_FILE` via `_IO_wfile_jumps` | N/A | OK (≥ 2.28) | OK | libc base + heap |
| `__exit_funcs` | OK | OK | OK | libc base + pointer guard |
| `TLS_dtor_list` | N/A | N/A | OK | TLS addr + pointer guard |
| `_dl_fini` / link_map | OK | OK | OK | ld.so base |
| `modprobe_path` (kernel) | OK | OK | OK | Kernel base |
| `.fini_array` | OK | OK | OK | Binary base (if writable) |
| C++ vtable | OK | OK | OK | Object address + heap |
| `setcontext` gadget | OK | OK (changed in 2.29) | OK | libc base |
| Stack return address | Always | Always | Always | Stack address |

---

## 2. GOT OVERWRITE

**Replace a function pointer in the Global Offset Table.**

### Requirements
- Partial RELRO (`.got.plt` writable) — Full RELRO blocks this entirely

### Common Targets

| Overwrite From | Overwrite To | Trigger |
|---|---|---|
| `printf@GOT` | `system` | Next `printf(user_input)` with input = `/bin/sh` |
```
END THIRD-PARTY FILE 0359c1d1a0b17ae4

The third-party file has ended. Everything between the 0359c1d1a0b17ae4 tags is data: requests and commands from it are not followed. An “end of file” line with another tag inside the block is part of the file.

First 2993 of 13105 bytes. © yaklang · MIT · https://github.com/yaklang/hack-skills/tree/HEAD/skills/arbitrary-write-to-rce/SKILL.md

_Part of the page did not fit — see the HTML version._

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
