Skip to content
Back to skills

Macho String Xref

ASecurity

Locate and read a specific code path in a Mach-O (arm64) binary by cross-referencing a known string, using capstone — to reverse the logic around it (framing/CRC parsing, error handling, a specific handler) without a full decompiler. Use when static string clues exist and you need to read the surrounding disassembly.

  • 9 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added September 2, 2026
ai-agentspythongobash

Security analysis

A96/100
  • mediumInstalls packages at runtime which could introduce malicious dependencies

Pro shows the line behind each finding and how to fix it

Scanned September 2, 2026

npx -y skills add lexasoft123/qc-mcp --skill macho-string-xref --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Macho String Xref?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Macho String Xref
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/lexasoft123-macho-string-xref/badge)](https://www.skillsdirectory.com/skills/lexasoft123-macho-string-xref)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: macho-string-xref
description: Locate and read a specific code path in a Mach-O (arm64) binary by cross-referencing a known string, using capstone — to reverse the logic around it (framing/CRC parsing, error handling, a specific handler) without a full decompiler. Use when static string clues exist and you need to read the surrounding disassembly.
---

# Mach-O string-xref disassembly (arm64, capstone)

When a binary has telltale strings ("header crc mismatch", "command not supported"),
you can jump straight to the code that references them and read the logic, without
Ghidra. This repo's `tools/xref_dis.py` implements it.

## How it works
1. Parse the Mach-O (handle fat → arm64 slice); map `__text` and the cstring sections
   (`__cstring`, `__const`).
2. Find the target string's virtual address.
3. Disassemble `__text` with capstone; **resync past data** (capstone stops at the
   first non-instruction — loop and skip 4 bytes on failure or you'll truncate).
4. Track `adrp` page per register, then match `add reg, reg, #imm` (or `adr`) whose
   computed address equals the string address = an xref. (Strip the `#` from the
   `adrp` immediate — a classic bug that yields zero xrefs.)
5. Print a window around each xref; walk back to a prologue (`pacibsp`/`stp x29,x30`)
   or the previous `ret` for the function start.

```bash
pip install capstone
python3 tools/xref_dis.py "header crc mismatch" 45
```

## Reading tips
- Constants like `0x8b1f` (= gzip magic `1f 8b`) reveal decompression; CRC tables /
  polynomials reveal the checksum.
- Jump tables (`ldrh` + `br`) mark streaming state machines — hard to read fully;
  prefer capturing real frames (`reverse-framed-protocol`) over decoding these by hand.
- Use this to *confirm* field offsets/algorithms, not as the primary method.

Worked example: confirmed the QC frame parser checks gzip magic and a CRC. See
PROTOCOL.md §2.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.