# binary-protection-bypass

A skill that walks through ELF binary protections and the bypass for each one. Useful for CTF work and exploit analysis.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode · 3700 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/binary-protection-bypass/SKILL.md
- Updated: 2026-09-13
- HTML: https://affpapa.org/en/nevibecode/skills/binary-protection-bypass

## What it does

The skill covers how to identify which protections a binary has and what to do about each. It goes through ASLR, PIE, NX/DEP, stack canary, RELRO, FORTIFY_SOURCE, stack clash, CET shadow stack and ARM MTE. Every protection comes paired with a bypass method and the primitive that method needs: an info leak, a partial overwrite, a ROP chain, ret2dlresolve.

Identification relies on `checksec`, `readelf -h`, `readelf -l` and reading `/proc/sys/kernel/randomize_va_space`. From there the skill maps the finding to a technique. With Full RELRO the GOT is read-only, so the targets shift to `__malloc_hook`, `__free_hook`, `_IO_FILE vtable`, `__exit_funcs`, `TLS_dtor_list` or `.fini_array`. For NX it lays out an mprotect chain that marks a page executable and jumps to shellcode.

Cross-references point to `stack-overflow-and-rop`, `format-string-exploitation`, `heap-exploitation` and `arbitrary-write-to-rce`. A separate `PROTECTION_BYPASS_MATRIX.md` file holds the protection × bypass × primitive matrix. If you are working a specific binary rather than reading theory, start with `checksec` — without the list of active protections the rest of the sections are guesswork.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add yaklang/hack-skills --skill binary-protection-bypass -a claude-code
```

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

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add yaklang/hack-skills --skill binary-protection-bypass -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/binary-protection-bypass/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add yaklang/hack-skills --skill binary-protection-bypass -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/binary-protection-bypass/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install yaklang/hack-skills binary-protection-bypass
```

2. **Manually: put the files in place**
- File: `.github/skills/binary-protection-bypass/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add yaklang/hack-skills --skill binary-protection-bypass -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/yaklang/hack-skills --path skills/binary-protection-bypass
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/binary-protection-bypass/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add yaklang/hack-skills --skill binary-protection-bypass -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/binary-protection-bypass/SKILL.md

## When to use it
- identify which protections are enabled in an ELF binary
- pick a bypass for NX using ROP or an mprotect chain
- work around Full RELRO when the GOT is read-only
- leak a libc or PIE address through a format string
- choose an overwrite target when a canary is present

## Example prompts
- run checksec on ./binary and break down which protections are on
- Full RELRO and NX are enabled — what overwrite targets are left
- I need to leak a libc address with a format string, walk me through it

## 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: 5ffb994a4349608b.

BEGIN THIRD-PARTY FILE 5ffb994a4349608b
````text
---
name: binary-protection-bypass
description: >-
  Binary protection bypass playbook. Use when identifying and bypassing ASLR, PIE, NX/DEP, stack canary, RELRO, FORTIFY_SOURCE, CET, and MTE protections in ELF binaries to enable exploitation.
---

# SKILL: Binary Protection Bypass — Expert Attack Playbook

> **AI LOAD INSTRUCTION**: Expert binary protection identification and bypass techniques. Covers ASLR, PIE, NX, RELRO, canary, FORTIFY_SOURCE, stack clash, CET shadow stack, and ARM MTE. Each protection is paired with its bypass methods and required primitives. Distilled from ctf-wiki mitigation sections and real-world exploitation. Base models often confuse which protections block which attacks and miss the combinatorial effect of multiple protections.

## 0. RELATED ROUTING

- [stack-overflow-and-rop](../stack-overflow-and-rop/SKILL.md) — ROP chains to bypass NX, ret2libc for ASLR bypass
- [format-string-exploitation](../format-string-exploitation/SKILL.md) — primary method for leaking canary, PIE, libc addresses
- [heap-exploitation](../heap-exploitation/SKILL.md) — heap attacks for RELRO bypass (when GOT is read-only)
- [arbitrary-write-to-rce](../arbitrary-write-to-rce/SKILL.md) — what to overwrite when GOT is protected by RELRO

### Advanced Reference

Load [PROTECTION_BYPASS_MATRIX.md](./PROTECTION_BYPASS_MATRIX.md) for comprehensive protection × bypass × primitive matrix.

---

## 1. PROTECTION IDENTIFICATION

```bash
$ checksec ./binary
[*] '/path/to/binary'
    Arch:     amd64-64-little
    RELRO:    Full RELRO          ← GOT read-only
    Stack:    Canary found        ← stack canary enabled
    NX:       NX enabled          ← stack not executable
    PIE:      PIE enabled         ← position-independent code
    FORTIFY:  Enabled             ← fortified libc functions
```

### Quick Identification Table

| Protection | Check Command | Binary Indicator |
|---|---|---|
| ASLR | `cat /proc/sys/kernel/randomize_va_space` | OS-level (0=off, 1=partial, 2=full) |
| PIE | `checksec` or `readelf -h` (Type: DYN) | Binary compiled with `-pie` |
| NX | `checksec` or `readelf -l` (no RWE segment) | `gcc -z noexecstack` (default on) |
| Canary | `checksec` or look for `__stack_chk_fail@plt` | `gcc -fstack-protector-all` |
| Partial RELRO | `readelf -l` (GNU_RELRO segment, `.got.plt` writable) | `gcc -Wl,-z,relro` |
````
END THIRD-PARTY FILE 5ffb994a4349608b

The third-party file has ended. Everything between the 5ffb994a4349608b 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 2377 of 12037 bytes. © yaklang · MIT · https://github.com/yaklang/hack-skills/tree/HEAD/skills/binary-protection-bypass/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
