tr4mpass/include/exploit/exploit.h
2026-08-01 17:06:56 -08:00

54 lines
1.5 KiB
C

/* exploit.h -- Common exploit types and lifecycle API */
#ifndef EXPLOIT_H
#define EXPLOIT_H
#include <stddef.h>
#include <stdint.h>
#include "device/device.h"
#include "device/chip_db.h"
/* Exploit phase constants */
#define EXPLOIT_PHASE_INIT 0
#define EXPLOIT_PHASE_RESET 1
#define EXPLOIT_PHASE_SETUP 2
#define EXPLOIT_PHASE_SPRAY 3
#define EXPLOIT_PHASE_PATCH 4
#define EXPLOIT_PHASE_DONE 5
/*
* exploit_ctx_t -- shared context for any DFU exploit.
*
* Holds the device, chip info, current exploit phase, and the assembled
* payload buffer (ROP chain + shellcode concatenated).
*/
typedef struct {
device_info_t *dev;
const chip_info_t *chip;
int phase; /* EXPLOIT_PHASE_* */
uint8_t *payload_buf;
size_t payload_len;
int skip_clrstatus; /* 1 = DFU already in dfuIDLE, skip CLR_STATUS in stage 3 */
} exploit_ctx_t;
/*
* exploit_init -- Populate ctx from device info. Looks up chip_info via
* cpid, verifies checkm8 vulnerability, allocates payload buffer.
* Returns 0 on success, -1 on failure.
*/
int exploit_init(exploit_ctx_t *ctx, device_info_t *dev);
/*
* exploit_deliver -- Execute the exploit stages (reset, spray, setup, patch).
* The specific exploit is selected based on chip type (currently only checkm8).
* Returns 0 on success, -1 on failure.
*/
int exploit_deliver(exploit_ctx_t *ctx);
/*
* exploit_cleanup -- Free payload buffer and zero the context.
*/
void exploit_cleanup(exploit_ctx_t *ctx);
#endif /* EXPLOIT_H */