p4nda0s/reverse-skills

rev-unicorn-debug

Debug and emulate specific code fragments or functions using the Unicorn engine.

All-time #7545 Trending #7820 First seen Apr 9, 2026
8-week activity · all time api

Installation

$ npx skills add p4nda0s/reverse-skills --skill rev-unicorn-debug

Summary

  • Debug and emulate specific code fragments or functions using the Unicorn engine.
  • Activate when the user wants to emulate a function with Unicorn, trace binary execution without running the full program, decrypt or decode data by emulating the algorithm, or bypass environment dependencies (JNI, syscalls, libc) during emulation.

Similar popular skills

Related neighbors and high-traction skills in the same topics — useful to compare before installing.

Also in this package

Other skills from p4nda0s/reverse-skills.

npx skills add p4nda0s/reverse-skills

Browse all from p4nda0s/reverse-skills

More details

Agent compatibility

Declared targets from SKILL.md / docs. Unmarked agents are not listed — the skill may still install via the CLI.

Claude Code Not declared
Cursor Not declared
Codex Not declared
GitHub Copilot Not declared
Windsurf Not declared
Gemini CLI Not declared
Cline Not declared
OpenCode Not declared

Repository health

Stars 2.1K
License MIT
Default branch main
Open issues 1
Status Active

Package contents

Files included with this skill beyond the listing page.

  • skill md SKILL.md 4,462 B
  • docs SUMMARY.md 3,977 B

History

  1. First seen on skills.sh
  2. First recorded snapshot · 1,532 installs

SKILL.md

rev-unicorn-debug - Unicorn Emulation Debugger

Debug and emulate specific code fragments or functions using the Unicorn engine. Analyze context dependencies (JNI, syscalls, library functions) and simulate them through hook mechanisms to complete the user's debugging goal.


Core Principles

  1. Load file raw first — do NOT parse ELF/PE/Mach-O headers. Read the file as raw bytes and map directly into Unicorn memory. We only need to emulate specific functions, not the entire binary. If raw loading fails (code references segments at specific addresses), then parse minimally — only map the segments needed.
  2. Identify context dependencies — analyze the target code for external calls (JNI, syscalls, libc, imports) and hook them to provide simulated responses.
  3. Use callbacks extensively — leverage Unicorn's hook system for debugging, tracing, error recovery, and environment simulation.
  4. Iterative fix — when emulation crashes, use the callback info to diagnose and fix (map missing memory, hook unhandled calls, fix register state).
  5. Minimal trace output — prefer block-level tracing over instruction-level. Only enable instruction trace on small targeted ranges. Use counters and summaries instead of per-step logging.

Environment Simulation Strategy

Before emulating, read the target function and identify what it calls. Hook external dependencies by address and simulate in Python:

Category Examples Simulation Strategy
libc malloc, free, memcpy, strlen, printf Hook address, implement logic in Python (bump allocator for malloc)
JNI GetStringUTFChars, FindClass, GetMethodID Build fake JNIEnv function table in UC memory, write RET stubs at each entry, hook stub addresses
Syscalls read, write, mmap, ioctl Hook UCHOOKINTR, dispatch by syscall number
C++ runtime operator new, __cxa_throw Hook and simulate
Library calls pthreadmutexlock, dlopen Hook and return success/stub

Hook pattern: Register a UCHOOKCODE callback. When PC hits a known import address, execute the Python simulation, then set PC = LR to skip the original function.


Callback Types to Use

Callback Purpose
UCHOOKCODE Intercept import calls by address; instruction-level trace (use sparingly, narrow range only)
UCHOOKBLOCK Block-level trace (preferred over instruction trace)
UCHOOKMEM_UNMAPPED Auto-map missing pages to recover from unmapped access errors
`UCHOOKMEM_READ \ UCHOOKMEM_WRITE` Trace memory access on targeted data ranges only
UCHOOKINTR Intercept SVC/INT for syscall simulation

Iterative Debugging Workflow

When emulation fails, follow this loop:

  1. Run — start emulation, let it crash
  2. Read callback output — which address faulted? What type (read/write/fetch)?
  3. Diagnose:

- Unmapped memory fetch → missing code page, map it - Unmapped memory read/write → missing data section or uninitialized pointer, map or hook - Hitting an import stub → identify the function, add a simulation hook - Infinite loop → add a code hook with execution counter, stop after threshold

  1. Fix — add the hook / map the memory / adjust registers
  2. Re-run — repeat until the target function completes

Architecture Quick Reference

Arch Uc Const Mode SP LR Args Return Syscall
ARM64 UCARCHARM64 UCMODELITTLE_ENDIAN SP X30 X0-X7 X0 X8 + SVC #0
ARM32 UCARCHARM UCMODETHUMB / UCMODEARM SP LR R0-R3 R0 R7 + SVC #0
x86-64 UCARCHX86 UCMODE64 RSP (stack) RDI,RSI,RDX,RCX,R8,R9 RAX RAX + syscall
x86-32 UCARCHX86 UCMODE32 ESP (stack) (stack) EAX EAX + int 0x80
MIPS32 UCARCHMIPS UCMODEMIPS32 + UCMODEBIG_ENDIAN $sp $ra $a0-$a3 $v0 $v0 + syscall