
Ctf Reverse
Study CTF reverse-engineering writeups—signal handlers, trace inversion, and anti-analysis tricks—when unpacking protected binaries for research or hardening lessons.
Overview
CTF Reverse is an agent skill for the Ship phase that explains CTF anti-analysis and reverse-engineering techniques from documented competition writeups.
Install
npx skills add https://github.com/ljagiello/ctf-skills --skill ctf-reverseWhat is this skill?
- CTF-focused techniques beyond core anti-analysis taxonomy (links to anti-analysis.md)
- SIGILL handler execution-mode switching (Hack.lu 2015)
- SIGFPE side-channel via strace signal counting (PlaidCTF 2017)
- Instruction trace inversion with Keystone and Unicorn (MeePwn CTF 2017)
- Call-less chaining and parent-patched child dumps via process_vm_writev (THC/Google CTF examples)
Adoption & trust: 5k installs on skills.sh; 2.3k GitHub stars; 1/3 security scanners passed (skills.sh audits).
What problem does it solve?
You hit a CTF or research binary using signal handlers, trace games, or parent-child patching and lack a playbook beyond generic anti-debug lists.
Who is it for?
Security-curious solo builders doing CTFs, malware analysis practice, or appsec research who want writeup-style technique maps.
Skip if: Founders who only need routine dependency scanning, OAuth setup, or shipping a Next.js MVP without native binary analysis.
When should I use this skill?
You are reversing a CTF or research binary that uses signal handlers, emulation/trace inversion, or dynamic unpacking patterns from named competitions.
What do I get? / Deliverables
You get named technique families and competition references so your agent can suggest concrete analysis angles (handlers, emulation, memory dumps) instead of guessing.
- Technique-to-writeup mapping
- Suggested analysis workflow per anti-pattern family
Recommended Skills
Journey fit
Ship/security is the canonical shelf because the content maps to analyzing malicious or obfuscated binaries and defensive understanding, not greenfield product build. Security subphase fits anti-analysis and reverse workflows aimed at understanding hostile or puzzle binaries rather than routine app features.
How it compares
Specialized reverse-engineering lore for puzzles—not a production SAST scanner or compliance checklist.
Common Questions / FAQ
Who is ctf-reverse for?
Developers and security hobbyists analyzing obfuscated or anti-analysis binaries in CTF settings or focused research sessions.
When should I use ctf-reverse?
During Ship/security reviews or dedicated RE sessions when a binary uses signal tricks, emulator challenges, or dynamic unpacking patterns described in the table of contents.
Is ctf-reverse safe to install?
Check the Security Audits panel on this Prism page; content is educational but may guide running untrusted binaries and invasive debugging on your machine.
SKILL.md
READMESKILL.md - Ctf Reverse
# CTF Reverse - Anti-Analysis CTF Writeups CTF-specific anti-analysis techniques: signal-handler tricks, instruction-trace inversion, call-less function chaining, parent-patched child binary dumping. For the core anti-analysis taxonomy (Linux/Windows anti-debug, anti-VM, anti-DBI, code integrity, anti-disassembly), see [anti-analysis.md](anti-analysis.md). ## Table of Contents - [SIGILL Handler for Execution Mode Switching (Hack.lu 2015)](#sigill-handler-for-execution-mode-switching-hacklu-2015) - [SIGFPE Signal Handler Side-Channel via strace Counting (PlaidCTF 2017)](#sigfpe-signal-handler-side-channel-via-strace-counting-plaidctf-2017) - [Instruction Trace Inversion with Keystone and Unicorn (MeePwn CTF 2017)](#instruction-trace-inversion-with-keystone-and-unicorn-meepwn-ctf-2017) - [Call-less Function Chaining via Stack Frame Manipulation (THC CTF 2018)](#call-less-function-chaining-via-stack-frame-manipulation-thc-ctf-2018) - [Parent-Patched Child Binary Dump via strace process_vm_writev (Google CTF Quals 2018)](#parent-patched-child-binary-dump-via-strace-process_vm_writev-google-ctf-quals-2018) - [ConfuserEx Dynamic Module Dump via Constructor Breakpoint (Kaspersky 2018)](#confuserex-dynamic-module-dump-via-constructor-breakpoint-kaspersky-2018) --- ## SIGILL Handler for Execution Mode Switching (Hack.lu 2015) Binaries may install SIGILL (illegal instruction) handlers to switch between x86 and x86-64 execution modes or implement custom opcode dispatch: 1. **Signal registration:** `signal(SIGILL, handler)` installs a callback for illegal instruction exceptions 2. **Mode switching:** The handler modifies the saved instruction pointer or segment registers to switch between 32-bit and 64-bit code 3. **Custom opcodes:** Invalid x86 instructions trigger the handler, which interprets operand bytes as custom VM opcodes ```c // Signal handler decodes "illegal" instructions as custom opcodes void sigill_handler(int sig, siginfo_t *info, void *ucontext) { ucontext_t *ctx = (ucontext_t *)ucontext; unsigned char *pc = (unsigned char *)ctx->uc_mcontext.gregs[REG_RIP]; // Decode custom opcode from bytes at PC // Advance PC past the custom instruction ctx->uc_mcontext.gregs[REG_RIP] += opcode_length; } ``` **Key insight:** If a binary installs signal handlers for SIGILL/SIGSEGV/SIGTRAP early in execution, suspect custom instruction dispatch. Trace signal deliveries with `strace -e signal` or set GDB to not intercept: `handle SIGILL nostop pass`. --- ## SIGFPE Signal Handler Side-Channel via strace Counting (PlaidCTF 2017) Binary uses SIGFPE signal handlers for control flow, making static analysis unreliable. Brute-force by counting SIGFPE signals via strace — correct input characters produce more signals. ```bash # Count SIGFPE signals per input character guess for c in {a..z} {A..Z} {0..9}; do count=$(echo -n "${c}AAAAAAA" | strace -e signal=SIGFPE ./binary 2>&1 | grep -c SIGFPE) echo "$c: $count" done # Character producing the most SIGFPEs is correct # Repeat for each position, extending the known prefix ``` **Key insight:** Signal handlers (SIGFPE, SIGSEGV, SIGILL) create implicit control flow invisible to static analysis. The number of signals raised correlates with validation progress. Counting signals via `strace -e signal=SIGFPE` turns opaque signal-based validation into a measurable side-channel for character-by-character brute-force. --- ## Instruction Trace Inversion with Keystone and Unicorn (MeePwn CTF 2017) UPX-packed binary applies a sequence of arithmetic-only transforms (sub, add, xor, rol, ror) to the flag. No memory side-effects — purely register arithmetic. IDAPython traces non-jump instructions, the sequence is then inverted to recover the flag. **Inversion rules:** - Reverse the instruction sequence (last instruction first) - Swap inverse pairs: `add ↔ sub`, `rol ↔ ror`, `xor` is self-inverse ```python # IDAPython: collect non-jump instructions in the obfuscated rou