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>
66 lines
2.3 KiB
C
66 lines
2.3 KiB
C
/*
|
|
* path_a_ssh_internal.h -- SSH helper wrappers shared between the
|
|
* Path A jailbreak and mobileactivationd-replacement flows.
|
|
*
|
|
* Not a public API; internal to the bypass module. The wrappers hide
|
|
* the raw libssh2 session/channel lifecycle so that path_a_ssh.c only
|
|
* deals in high-level "open / exec / scp / close" operations.
|
|
*/
|
|
|
|
#ifndef BYPASS_PATH_A_SSH_INTERNAL_H
|
|
#define BYPASS_PATH_A_SSH_INTERNAL_H
|
|
|
|
#include <stddef.h>
|
|
#include <sys/types.h>
|
|
|
|
/* Opaque session handle owned by path_a_ssh_helpers.c. */
|
|
typedef struct ssh_sess ssh_sess_t;
|
|
|
|
/*
|
|
* ssh_open -- Establish a libssh2 session with password authentication.
|
|
*
|
|
* host/user/password must be non-NULL. On success *sess_out is set to a
|
|
* heap-allocated handle that the caller frees with ssh_close(). Returns
|
|
* 0 on success, -1 on any failure (socket, handshake, auth).
|
|
*/
|
|
int ssh_open(ssh_sess_t **sess_out, const char *host, int port,
|
|
const char *user, const char *password);
|
|
|
|
/*
|
|
* ssh_exec -- Run a single command over SSH and capture its stdout.
|
|
*
|
|
* If exit_code_out is non-NULL the remote exit status is written there.
|
|
* If stdout_buf/stdout_cap are non-zero, up to (stdout_cap-1) bytes of
|
|
* stdout are copied; the buffer is always NUL-terminated on success.
|
|
*
|
|
* Returns 0 on a successful RPC round-trip (regardless of remote exit
|
|
* code) or -1 if the channel / transport itself failed.
|
|
*/
|
|
int ssh_exec(ssh_sess_t *sess, const char *cmd, int *exit_code_out,
|
|
char *stdout_buf, size_t stdout_cap);
|
|
|
|
/*
|
|
* ssh_scp_upload -- Push a local file to remote_path via SCP.
|
|
*
|
|
* The destination inode is created with the given unix mode. Returns 0
|
|
* on success, -1 on any error (read failure, SCP channel rejection,
|
|
* truncated write).
|
|
*/
|
|
int ssh_scp_upload(ssh_sess_t *sess, const char *local_path,
|
|
const char *remote_path, mode_t mode);
|
|
|
|
/*
|
|
* ssh_close -- Disconnect and free a session created by ssh_open. Safe
|
|
* to call with a NULL handle.
|
|
*/
|
|
void ssh_close(ssh_sess_t *sess);
|
|
|
|
/*
|
|
* ssh_global_init / ssh_global_exit -- Reference-counted libssh2_init
|
|
* wrappers. Helpers call them from ssh_open/ssh_close so tests do not
|
|
* need to coordinate global init. Not for direct use.
|
|
*/
|
|
int ssh_global_init(void);
|
|
void ssh_global_exit(void);
|
|
|
|
#endif /* BYPASS_PATH_A_SSH_INTERNAL_H */
|