
All-in-One-macOS-Binäranalyse: Mach-O-Parsing, ARM64-Disassemblierung, Codesignaturen und Debugging.
Ein natives macOS-Binäranalyse-Tool, das Mach-O-Parsing, ARM64-Disassemblierung und Prozess-Debugging bietet. Vollständig in Swift geschrieben, ohne externe Abhängigkeiten.
| Funktion | Beschreibung |
|---|---|
| Mach-O-Parsing | Headers, Segmente, Sections, Symbole, Dylibs, Strings |
| Codesignaturen | Berechtigungen, CDHash, Signierinformationen, Team-ID |
| ARM64-Disassemblierung | Vollständiger Instruktionsdecoder mit PAC-Annotation |
| Prozess-Debugging | Anhängen, Breakpoints, Speicher, Register |
| Swift-Bibliothek | In eigene Projekte einbettbar |
| JSON-Ausgabe | Skriptfreundliches Ausgabeformat |
# 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/
Analysiere die Mach-O-Binärstruktur:
# Basic analysis
machscope parse /bin/ls
# Full analysis
machscope parse /bin/ls --all
# Specific sections
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
# JSON output for scripting
machscope parse /bin/ls --json --all > analysis.json
Disassembliere ARM64-Code:
# List functions
machscope disasm /bin/ls --list-functions
# Disassemble from address
machscope disasm /bin/ls --address 0x100003f40 --length 50
# Show instruction bytes
machscope disasm /bin/ls --show-bytes
Sieh nach, welche Funktionen verfügbar sind:
machscope check-permissions
Ausgabe:
Feature Status Notes
------------------------------------------------------------
Static Analysis ✓ Ready No special permissions needed
Disassembly ✓ Ready No special permissions needed
Debugger ✗ Denied Missing debugger entitlement
An laufende Prozesse anhängen (erfordert Signierung):
# First, sign with debugger entitlement
codesign --force --sign - --entitlements Resources/MachScope.entitlements .build/debug/machscope
# Enable Developer Tools in System Settings > Privacy & Security
# Attach to process
machscope debug <pid>
Füge MachScope zu deiner Package.swift hinzu:
dependencies: [
.package(url: "https://github.com/sadopc/machscope.git", from: "1.0.0")
]
Dann in deinem Code:
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
Hauptvorteil von MachScope: Swift-native Bibliothek, die du in deine eigenen Werkzeuge einbetten kannst.
MIT-Lizenz – Siehe LICENSE für Details.
Beiträge sind willkommen! Bitte lies zuerst den Leitfaden zum Mitwirken.
# Run tests before submitting
swift test
# Format code
xcrun swift-format -i -r Sources/ Tests/
Mit ❤️ in Swift erstellt
| Werkzeug | Sprache | Bibliothek? | ARM64 PAC | Debugger |
|---|
| MachScope | Swift | ✅ Ja | ✅ Ja | ✅ Ja |
| otool | C | ❌ Nein | ❌ Nein | ❌ Nein |
| objdump | C | ❌ Nein | ❌ Nein | ❌ Nein |
| jtool2 | C | ❌ Nein | ✅ Ja | ❌ Nein |
| Hopper | — | ❌ Nein | ✅ Ja | ❌ Nein |