134 Commits

Author SHA1 Message Date
blacktop 498b0bd9bf chore: refactor enosys detection and add unit tests 2026-05-03 09:24:18 -06:00
ThePraeceps 29d37aca51 fix(kernelcache): detect enosys syscalls by instruction pattern matching (#1178) 2026-05-03 09:08:47 -06:00
blacktop 4f23763438 feat(extract): auto-decrypt remote kernelcaches via wiki keys
`ipsw download ipsw --kernel` now fetches firmware keys from
theapplewiki and decrypts encrypted kernelcaches inline. Unencrypted
members in the same IPSW pass through unchanged.

- pkg/img4: DecryptPayload reuses Payload.GetData for decompression,
  removing the duplicate LZSS/LZFSE branches.
- pkg/kernelcache: ParseImg4Data switches to img4.ParsePayload and
  exports ErrEncryptedKernelCache so callers can detect the missing-key
  case via errors.Is.
- internal/commands/extract: new keyed remote path with all-or-nothing
  preflight; the encryption-status peek lets unencrypted variants
  succeed even when the wiki has no entry for them.

  closes #1193
2026-04-27 15:57:23 -06:00
ThePraeceps d3ca9d7519 feat(symbolicate): add syscall, mach trap, and MIG symbols to output (#1158) 2026-04-04 17:40:13 -06:00
blacktop f024b63fce fix: ipsw kernel cpp cmd 2026-03-11 00:01:54 -06:00
blacktop 196d77de6f feat: add kernel C++ parsing to symbolicate cmds and APIs
Add API endpoints and CLI support for discovering C++ classes and symbolication of kernelcaches, refactor Mach-O handling, and improve symbol collection.

- API: add /kernel/cpp and /kernel/symbolicate routes, request param structs, response types, and openKernel helper. Use cpp scanner and signature parsing to return classes and symbol maps.
- CLI: wire scanner LogStats flag, refactor kernel symbolicate command (schema writer helper, improved signature parsing, and symbol matching logic). Add tests for symbolicator schema and kernel symbol matching.
- Signature pkg: add kernel C++ symbol extraction (pkg/signature/kernel_cpp.go) and SymbolicateMachO to symbolicate already-open Mach-Os; integrate C++ symbols into symbol map and update signature matching/logging behavior.
- Internal: refactor in-memory DB lookups (findMachOByUUID, findSymbolByAddr) to reduce duplication. Improve symbols collection for kernel Mach-Os (collectKernelMachoSymbols, extra kernel symbols from signature/C++), add helpers to append symbols.
- Kernelcache CPP: add LogStats option and conditional logging of scan stats.
- Crashlog/ips: update wording to reflect kernel symbols are from kernel analysis and store KernelSymbols earlier in processing; parse signatures only when configured.

Also add unit tests for new symbolication helpers and kernel C++ signature handling. Overall this consolidates kernel symbol discovery, improves reuse, and surfaces C++-derived symbols in symbol maps.
2026-03-10 12:20:12 -06:00
blacktop 51d7926804 Update helpers.go 2026-03-10 10:54:29 -06:00
blacktop ffa9d925f9 chore: add unit tests for C++ kernelcache scanner helper functions
Tests cover trackStaticValueInstruction option flags
(acceptAnyLoadAddr, propagateLoadAddrInAdd), pointer cache section
filtering, and 32-bit MOVZ/MOVK instruction handling.
2026-03-10 10:22:44 -06:00
blacktop 9c861ee7cd fix: refactor disassembly API for type safety and performance
Update all disassembly code to use new cgo-based decoder API with
stack-allocated instruction structs instead of heap-allocated
pointers. Add instruction filtering to skip decoding operations that
register tracking doesn't care about, avoiding expensive CGo calls.

Key changes:
- Replace Decompose with DecomposeInto using stack allocation
- Add mayBeTrackedInstruction filter for common tracked ops
- Introduce helper functions for safe operand/register access
- Fix metaclass pointer index to use caller index for efficiency
- Remove root file special-casing in pointer index builder
- Add comprehensive unit tests for tracking options and helpers
2026-03-10 10:22:24 -06:00
blacktop 27e8ec23ad chore: refactor disassembly code to use new instruction representation
- Updated disassembly functions to utilize the new `disassemble.Inst` type instead of `disassemble.Instruction`.
- Modified operand retrieval functions to accommodate the new instruction structure.
- Enhanced error handling and logging for instruction decoding failures.
- Improved JSON output for disassembly to ensure disassembly strings are preserved.
- Refactored various components across the disassembly package, including Mach-O and dyld handling, to streamline instruction processing.
- Added tests to validate the new disassembly behavior and ensure backward compatibility.
2026-03-09 21:13:33 -06:00
blacktop 368742585b feat(tests): add comprehensive tests for micro instruction handling and class name recovery 2026-03-09 20:28:16 -06:00
blacktop e140388c45 Update bench_test.go 2026-03-09 20:16:29 -06:00
blacktop 08ae49f8e2 feat: add initial implementation of kernelcache class scanner and vtable resolver
- Introduced `types.go` to define core structures and configurations for the scanner.
- Implemented the `Scanner` type for discovering classes in kernelcache Mach-O files.
- Added methods for scanning, resolving vtables, and handling class metadata.
- Created `vtable.go` to manage vtable-related functionalities, including detection and resolution of vtables.
- Implemented various utility functions for class name recovery and symbol handling.
- Established mechanisms for deduplication of discovered classes and handling of potential virtual function stubs.
2026-03-09 20:11:00 -06:00
blacktop 4b0e4eec3d feat(kernelcache): enhance version parsing with regex and caching 2026-03-07 17:14:59 -07:00
blacktop 7fea36dbe3 fix: Add safe operand access helpers to prevent out-of-bounds panics 2026-02-23 11:22:00 -07:00
blacktop 889ae1f792 fix: ipsw dsc xref commad 2026-02-21 13:16:53 -07:00
blacktop 8e6f2c554b chore: modernize to 1.26
Refactor string concatenation to use strings.Builder for improved performance in multiple files
2026-02-12 10:02:01 -07:00
blacktop 04f7fe7627 feat(symbolicate): enhance kernelcache extraction for specific devices and improve logging 2025-12-05 14:58:58 -07:00
blacktop aa63352b6c fix: ipsw kernel mig command on newer kernels 2025-11-17 12:24:40 -07:00
blacktop 356a242b29 fix: ipsw diff, symbolicate and mig hangs on 26.2 beta 2025-11-04 15:06:13 -07:00
blacktop 17135297aa fix: ipsw kernel dec --output issue #901 2025-10-19 20:13:53 -06:00
blacktop fb02c65d22 chore: various command typos 2025-07-15 16:41:41 -06:00
blacktop 124589b5b9 Update kernelcache.go 2025-06-29 13:40:56 -06:00
blacktop 3cded00f59 feat: revamp ipsw img4 commands to bring inline with tools like img4lib (#784) 2025-06-28 01:54:40 -06:00
blacktop bdd14cf31d feat: add --json flag to ipsw kernel kexts cmd 2025-06-21 13:47:29 -06:00
blacktop 3071fd6748 fix: file close issue in ipsw kernel kext cmd #775 2025-06-20 13:19:37 -06:00
blacktop 7c752b9793 chore: update syscalls 2025-06-09 16:56:43 -06:00
blacktop a2ccd26880 chore: cleanup macho disass helper code 2025-05-04 13:01:07 -06:00
blacktop 6cca9a980d refactor: replace interface{} with any and simplify loop constructs 2025-03-26 22:53:29 -06:00
blacktop 9d101bf4ac chore(deps): bump deps 2025-02-24 19:19:02 -07:00
blacktop 0168aac759 chore: update syscalls DB 2025-02-21 20:31:24 -07:00
blacktop baf40ee017 chore: add skipped old MIG routine names 2024-07-25 00:00:15 -06:00
blacktop 9f89101f13 chore: add routine number to ipsw kernel mig output 2024-07-24 23:30:41 -06:00
blacktop 8b558b5a3b feat: add mig to ipsw kernel symbolication 2024-07-24 19:49:20 -06:00
blacktop c21208ddc5 feat: 🆕 ipsw kernel mig command 2024-07-24 19:39:35 -06:00
blacktop 79738d8e01 feat: add syscalls and mach_traps to ipsw kernel sym cmd 2024-07-20 22:49:41 -06:00
blacktop db36f61022 chore: update syscall list 2024-06-11 03:51:16 -06:00
blacktop 2b5ccd520c chore: add debug log to kernelcache extraction for single slice fat machos 2024-06-03 09:15:04 -06:00
blacktop fc119c44f9 chore: update syscalls 2024-01-25 16:30:59 -07:00
blacktop 980f67b245 fix: add error if detected encrypted device-tree #389 2024-01-21 16:32:56 -07:00
blacktop 1673ee487a feat: add ability to filter the extracted kernelcaches to a single device 2024-01-06 23:07:58 -07:00
blacktop ea1d8365c2 Update kernelcache.go 2023-11-20 10:58:06 -07:00
blacktop 172025f25f fix: ipsw extract --kernel --json output to include devices 🥝 2023-08-03 17:54:19 +12:00
blacktop 726b5a926c feat: add ability to extract SPTM firmware via ipsw extract --sptm 2023-06-08 21:58:28 -06:00
blacktop 9aa4d1ae81 chore: update ipsw kernel syscall and mach cmds 2023-06-06 14:41:46 -06:00
blacktop 1d5867c84e fix: use both JSON and xnu src for ipsw kernel syscall 2023-05-25 19:07:51 -06:00
blacktop 55e7c74776 Update syscall.go 2023-05-25 17:44:58 -06:00
blacktop 195d0ce851 feat: add color to ipsw kernel syscall command 🌈 2023-05-25 17:19:56 -06:00
blacktop 5b01b128e7 Update mach_trap.go 2023-05-19 10:38:35 -06:00
blacktop 521c8b15b6 chore: improve ipsw kernel mach cmd output formatting 2023-05-19 10:16:56 -06:00