
All-in-one per l'analisi binaria su macOS: parsing Mach-O, disassemblaggio ARM64, firme del codice e debugging.
Strumento nativo di analisi binaria per macOS che offre parsing Mach-O, disassemblaggio ARM64 e debug di processi. Realizzato interamente in Swift senza dipendenze esterne.
| Funzionalità | Descrizione |
|---|---|
| Parsing Mach-O | Header, segmenti, sezioni, simboli, dylib, stringhe |
| Firme del codice | Entitlement, CDHash, informazioni sulla firma, team ID |
| Disassemblaggio ARM64 | Decodifica completa delle istruzioni con annotazione PAC |
| Debug di processi | Attach, breakpoint, memoria, registri |
| Libreria Swift | Incorporabile nei tuoi progetti |
| Output JSON | Formato adatto allo scripting |
# Build
swift build
# Parse a binary
swift run machscope parse /bin/ls
# Parse a macOS app
swift run machscope parse /Applications/Calculator.app/Contents/MacOS/Calculator
# View entitlements
swift run machscope parse /Applications/Safari.app/Contents/MacOS/Safari --entitlements
# JSON output
swift run machscope parse /bin/ls --json
brew install sadopc/tap/machscope
git clone https://github.com/sadopc/machscope.git
cd MachScope
swift build -c release
sudo cp .build/release/machscope /usr/local/bin/
Analizza la struttura dei binari Mach-O:
# Analisi di base
machscope parse /bin/ls
# Analisi completa
machscope parse /bin/ls --all
# Sezioni specifiche
machscope parse /path/to/binary --symbols
machscope parse /path/to/binary --dylibs
machscope parse /path/to/binary --strings
machscope parse /path/to/binary --signatures
machscope parse /path/to/binary --entitlements
# Output JSON per scripting
machscope parse /bin/ls --json --all > analysis.json
Disassembla codice ARM64:
# Elenca funzioni
machscope disasm /bin/ls --list-functions
# Disassembla da un indirizzo
machscope disasm /bin/ls --address 0x100003f40 --length 50
# Mostra byte dell'istruzione
machscope disasm /bin/ls --show-bytes
Controlla quali funzionalità sono disponibili:
machscope check-permissions
Output:
Feature Status Notes
------------------------------------------------------------
Static Analysis ✓ Ready No special permissions needed
Disassembly ✓ Ready No special permissions needed
Debugger ✗ Denied Missing debugger entitlement
Collegati a processi in esecuzione (richiede firma):
# Prima, firma con entitlement per debugger
codesign --force --sign - --entitlements Resources/MachScope.entitlements .build/debug/machscope
# Abilita Strumenti sviluppatore in Impostazioni di Sistema > Privacy e Sicurezza
# Collegati al processo
machscope debug <pid>
Aggiungi MachScope al tuo Package.swift:
dependencies: [
.package(url: "https://github.com/sadopc/machscope.git", from: "1.0.0")
]
Poi usalo nel tuo codice:
import MachOKit
import Disassembler
// Parse a binary
let binary = try MachOBinary(path: "/bin/ls")
print("CPU: \(binary.header.cpuType)")
print("Segments: \(binary.segments.count)")
// Check entitlements
if let signature = try binary.parseCodeSignature(),
let entitlements = signature.entitlements {
for key in entitlements.keys {
print("\(key): \(entitlements[key] ?? "nil")")
}
}
// Disassemble
let disasm = ARM64Disassembler(binary: binary)
let result = try disasm.disassembleFunction("_main", from: binary)
for instruction in result.instructions {
print(disasm.format(instruction))
}
MachScope/
├── Sources/
│ ├── MachOKit/ # Core Mach-O parsing library
│ ├── Disassembler/ # ARM64 instruction decoder
│ ├── DebuggerCore/ # Process debugging
│ └── MachScope/ # CLI application
├── Tests/ # Test suites (319+ tests)
├── Resources/ # Entitlements for code signing
└── docs/ # Documentation
Il vantaggio principale di MachScope: una libreria nativa Swift che puoi incorporare nei tuoi strumenti.
Licenza MIT — Vedi LICENSE per i dettagli.
I contributi sono benvenuti! Leggi prima la Guida per contribuire.
# Esegui i test prima di inviare
swift test
# Formatta il codice
xcrun swift-format -i -r Sources/ Tests/
Realizzato con ❤️ in Swift
| Strumento | Linguaggio | Libreria? | ARM64 PAC | Debugger |
|---|
| MachScope | Swift | ✅ Sì | ✅ Sì | ✅ Sì |
| otool | C | ❌ No | ❌ No | ❌ No |
| objdump | C | ❌ No | ❌ No | ❌ No |
| jtool2 | C | ❌ No | ✅ Sì | ❌ No |
| Hopper | — | ❌ No | ✅ Sì | ❌ No |