
Análise binária tudo-em-um do macOS: análise de Mach-O, desmontagem ARM64, assinaturas de código e depuração.
Uma ferramenta nativa de análise de binários macOS que oferece parsing Mach-O, desmontagem ARM64 e depuração de processos. Construída inteiramente em Swift com zero dependências externas.
| Funcionalidade | Descrição |
|---|---|
| Parsing Mach-O | Cabeçalhos, segmentos, seções, símbolos, dylibs, strings |
| Assinaturas de Código | Entitlements, CDHash, informações de assinatura, ID da equipe |
| Desmontagem ARM64 | Decodificador completo de instruções com anotação PAC |
| Depuração de Processos | Anexar, breakpoints, memória, registradores |
| Biblioteca Swift | Embutir em seus próprios projetos |
| Saída JSON | Formato de saída amigável para scripts |
# 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/
Analisar estrutura binária Mach-O:
# 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
Desmontar código ARM64:
# 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
Veja quais funcionalidades estão disponíveis:
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
Anexar a processos em execução (requer assinatura):
# 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>
Adicione MachScope ao seu Package.swift:
dependencies: [
.package(url: "https://github.com/sadopc/machscope.git", from: "1.0.0")
]
Então use em seu código:
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
A principal vantagem do MachScope: biblioteca nativa Swift que você pode embutir em suas próprias ferramentas.
Licença MIT — Veja LICENSE para detalhes.
Contribuições bem-vindas! Por favor, leia o Guia de Contribuição primeiro.
# Run tests before submitting
swift test
# Format code
xcrun swift-format -i -r Sources/ Tests/
Construído com ❤️ em Swift
| Ferramenta | Linguagem | Biblioteca? | ARM64 PAC | Depurador |
|---|
| MachScope | Swift | ✅ Sim | ✅ Sim | ✅ Sim |
| otool | C | ❌ Não | ❌ Não | ❌ Não |
| objdump | C | ❌ Não | ❌ Não | ❌ Não |
| jtool2 | C | ❌ Não | ✅ Sim | ❌ Não |
| Hopper | — | ❌ Não | ✅ Sim | ❌ Não |