feat: real Path A implementation, cert extraction, mock test harness
Converts the Path A pipeline from stubs to a working implementation for A5-A11 devices, adds real certificate extraction via lockdownd and ECDSA P-256 signing, and introduces a comprehensive mock-based test suite. Activation - cert_extract: lockdownd-backed DeviceCertificate, AccountTokenCertificate, UniqueDeviceCertificate with base64 decode and CertificateChain array fallback. - signer: OpenSSL EVP ECDSA P-256 sign/verify with DER-encoded signatures plus a test keypair generator. - record.c: 3 of 6 cert fields now populate from live device data. AccountTokenSignature signs when TR4MPASS_SIGNING_KEY is set. FairPlayKeyData, RKCData, SepNonce remain documented stubs (SEP-blocked per 26.3-vulnerability.md). Path A bypass - path_a_ramdisk: iBSS/iBEC/devicetree/trustcache/ramdisk upload via libirecovery, reconnect handling between DFU and recovery stages, iBoot go/bootx commands, SSH readiness poll. - path_a_ssh: libssh2 + SCP. Mounts rootfs rw (apfs then hfs), runs AMFI patcher, backs up and replaces /usr/libexec/mobileactivationd with a user-supplied patched binary, verifies mode. Build, CLI, config - Makefile: add libssh2 dependency, split test targets into hw-independent (make test) and full mock (make test-mocks). - env_config + cli_flags: 12 new --flags for ramdisk, SSH, signing paths; flags map to TR4MPASS_* env vars. --verbose prints summary. - start.sh slimmed; helpers extracted to start-helpers.sh. Test suite (20 to 248 tests) - Mock framework under tests/mocks/ intercepts libimobiledevice, libirecovery, libusb, libssh2, libcurl, plus mobileactivation and afc. Staging API in mock_control.h. - Unit tests per module: cert_extract, signer, ramdisk, SSH jailbreak, env_config. - Integration tests in tests/integration/: 6 Path A E2E scenarios (happy path, exploit fail, reconnect timeout, SSH auth fail, SCP fail, missing env) and 3 Path B scenarios (identity manipulation works, nonce barrier rejection is handled cleanly, signal detection). Path B tests verify the tool reports the SEP barrier failure rather than misclaiming success. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
5b758931ac
commit
30807c8ef6
58 changed files with 7967 additions and 1210 deletions
66
tests/mocks/mock_irecv_internal.h
Normal file
66
tests/mocks/mock_irecv_internal.h
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
/*
|
||||
* mock_irecv_internal.h -- Shared state for libirecovery mock.
|
||||
*/
|
||||
|
||||
#ifndef TR4MPASS_MOCK_IRECV_INTERNAL_H
|
||||
#define TR4MPASS_MOCK_IRECV_INTERNAL_H
|
||||
|
||||
#include "mock_internal.h"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#include <libirecovery.h>
|
||||
|
||||
struct irecv_client_private {
|
||||
uint32_t magic;
|
||||
struct irecv_device_info info;
|
||||
char serial_buf[128];
|
||||
};
|
||||
|
||||
#define IRECV_MAGIC 0x49525256u /* "IRRV" */
|
||||
|
||||
#define MOCK_SETENV_SLOTS 16
|
||||
|
||||
typedef struct {
|
||||
char var[64];
|
||||
int error;
|
||||
int in_use;
|
||||
} mock_irecv_setenv_result_t;
|
||||
|
||||
/* Phase 3: per-path staged errors for irecv_send_file().
|
||||
* Each slot matches via strstr() on the path argument; the first unconsumed
|
||||
* match wins and the slot is marked consumed. */
|
||||
#define IRECV_SEND_FILE_STAGES 8
|
||||
|
||||
typedef struct {
|
||||
char path_needle[128]; /* match via strstr() against the filename */
|
||||
int error_code;
|
||||
int in_use;
|
||||
int consumed;
|
||||
} irecv_send_file_stage_t;
|
||||
|
||||
/* Phase 3: FIFO of staged irecv_open errors. Each call to
|
||||
* irecv_open_with_ecid consumes one slot (or returns success if empty). */
|
||||
#define IRECV_OPEN_ERROR_SLOTS 8
|
||||
|
||||
typedef struct {
|
||||
int error_code;
|
||||
int in_use;
|
||||
int consumed;
|
||||
} irecv_open_error_slot_t;
|
||||
|
||||
extern char g_irecv_cmd_expect[256];
|
||||
extern int g_irecv_cmd_expect_active;
|
||||
extern size_t *g_irecv_file_upload_bytes_out;
|
||||
extern int g_irecv_file_upload_active;
|
||||
extern mock_irecv_setenv_result_t g_irecv_setenv_results[MOCK_SETENV_SLOTS];
|
||||
extern int g_irecv_setenv_default_error;
|
||||
extern int g_irecv_open_error; /* backwards-compat sticky flag */
|
||||
extern irecv_open_error_slot_t g_irecv_open_error_slots[IRECV_OPEN_ERROR_SLOTS];
|
||||
extern irecv_send_file_stage_t g_irecv_send_file_stages[IRECV_SEND_FILE_STAGES];
|
||||
extern uint32_t g_irecv_info_pid;
|
||||
extern uint64_t g_irecv_info_ecid;
|
||||
extern char g_irecv_info_serial[128];
|
||||
|
||||
#endif /* TR4MPASS_MOCK_IRECV_INTERNAL_H */
|
||||
Loading…
Add table
Add a link
Reference in a new issue