Project restructuring
This commit is contained in:
50
c8_remote/include/checkm8.h
Normal file
50
c8_remote/include/checkm8.h
Normal file
@@ -0,0 +1,50 @@
|
||||
#ifndef CHECKM8_TOOL_CHECKM8_H
|
||||
#define CHECKM8_TOOL_CHECKM8_H
|
||||
|
||||
#include "checkm8_config.h"
|
||||
|
||||
#define CHECKM8_SUCCESS 0
|
||||
#define CHECKM8_FAIL_INVARGS -1
|
||||
#define CHECKM8_FAIL_NODEV -2
|
||||
#define CHECKM8_FAIL_NOEXP -3
|
||||
#define CHECKM8_FAIL_NOTDONE -4
|
||||
#define CHECKM8_FAIL_XFER -5
|
||||
#define CHECKM8_FAIL_NOINST -6
|
||||
#define CHECKM8_FAIL_PROT -7
|
||||
|
||||
#define IS_CHECKM8_FAIL(code) code < 0
|
||||
|
||||
#if CHECKM8_PLATFORM == 8010
|
||||
|
||||
#define DEV_IDVENDOR 0x05AC
|
||||
#define DEV_IDPRODUCT 0x1227
|
||||
#define DFU_IMAGE_BASE 0x1800B0000
|
||||
|
||||
#else
|
||||
#error "Unspported checkm8 platform"
|
||||
#endif
|
||||
|
||||
struct pwned_device
|
||||
{
|
||||
enum
|
||||
{
|
||||
DEV_NORMAL,
|
||||
DEV_PWNED
|
||||
} status;
|
||||
|
||||
unsigned int idVendor;
|
||||
unsigned int idProduct;
|
||||
|
||||
struct payload *installed;
|
||||
|
||||
#ifdef WITH_ARDUINO
|
||||
int ard_fd;
|
||||
#else
|
||||
struct libusb_device_bundle *bundle;
|
||||
#endif
|
||||
};
|
||||
|
||||
struct pwned_device *exploit_device();
|
||||
void free_device(struct pwned_device *dev);
|
||||
|
||||
#endif //CHECKM8_TOOL_CHECKM8_H
|
||||
25
c8_remote/include/command.h
Normal file
25
c8_remote/include/command.h
Normal file
@@ -0,0 +1,25 @@
|
||||
#ifndef CHECKM8_TOOL_COMMAND_H
|
||||
#define CHECKM8_TOOL_COMMAND_H
|
||||
|
||||
#include "checkm8.h"
|
||||
|
||||
#define CMD_USB_READ_LIMIT 0xFF0
|
||||
|
||||
struct dev_cmd_resp
|
||||
{
|
||||
int ret;
|
||||
unsigned long long magic;
|
||||
unsigned char *data;
|
||||
int len;
|
||||
};
|
||||
|
||||
struct dev_cmd_resp *dev_memset(struct pwned_device *dev, long long addr, unsigned char c, int len);
|
||||
struct dev_cmd_resp *dev_memcpy(struct pwned_device *dev, long long dest, long long src, int len);
|
||||
struct dev_cmd_resp *dev_exec(struct pwned_device *dev, int response_len, int nargs, unsigned long long *args);
|
||||
|
||||
struct dev_cmd_resp *dev_read_memory(struct pwned_device *dev, long long addr, int len);
|
||||
struct dev_cmd_resp *dev_write_memory(struct pwned_device *dev, long long addr, unsigned char *data, int len);
|
||||
|
||||
void free_dev_cmd_resp(struct dev_cmd_resp *resp);
|
||||
|
||||
#endif //CHECKM8_TOOL_COMMAND_H
|
||||
32
c8_remote/include/payload.h
Normal file
32
c8_remote/include/payload.h
Normal file
@@ -0,0 +1,32 @@
|
||||
#ifndef CHECKM8_TOOL_PAYLOAD_H
|
||||
#define CHECKM8_TOOL_PAYLOAD_H
|
||||
|
||||
#include "checkm8.h"
|
||||
|
||||
#define PAYLOAD_AES_BIN CHECKM8_BIN_BASE "payloads/payload_aes.bin"
|
||||
#define PAYLOAD_SYSREG_BIN CHECKM8_BIN_BASE "payloads/payload_sysreg.bin"
|
||||
#define PAYLOAD_SYNC_BIN CHECKM8_BIN_BASE "payloads/payload_sync.bin"
|
||||
|
||||
typedef enum
|
||||
{
|
||||
PAYLOAD_SYNC,
|
||||
PAYLOAD_AES,
|
||||
PAYLOAD_SYSREG
|
||||
} PAYLOAD_T;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
SRAM,
|
||||
DRAM
|
||||
} LOCATION_T;
|
||||
|
||||
#define RESP_VALUE(buf, type, i) ((type *) buf)[i]
|
||||
|
||||
int install_payload(struct pwned_device *dev, PAYLOAD_T p, LOCATION_T loc);
|
||||
int uninstall_payload(struct pwned_device *dev, PAYLOAD_T p);
|
||||
|
||||
struct dev_cmd_resp *execute_payload(struct pwned_device *dev, PAYLOAD_T p, int nargs, ...);
|
||||
struct dev_cmd_resp *read_payload(struct pwned_device *dev, long long addr, int len);
|
||||
struct dev_cmd_resp *write_payload(struct pwned_device *dev, long long addr, unsigned char *data, int len);
|
||||
|
||||
#endif //CHECKM8_TOOL_PAYLOAD_H
|
||||
51
c8_remote/include/usb_helpers.h
Normal file
51
c8_remote/include/usb_helpers.h
Normal file
@@ -0,0 +1,51 @@
|
||||
#ifndef CHECKM8_TOOL_LIBUSB_HELPERS_H
|
||||
#define CHECKM8_TOOL_LIBUSB_HELPERS_H
|
||||
|
||||
#include "checkm8.h"
|
||||
|
||||
#define MAX_PACKET_SIZE 0x800
|
||||
|
||||
#ifndef WITH_ARDUINO
|
||||
#include "libusb.h"
|
||||
|
||||
struct libusb_device_bundle
|
||||
{
|
||||
struct libusb_context *ctx;
|
||||
struct libusb_device *device;
|
||||
struct libusb_device_handle *handle;
|
||||
struct libusb_device_descriptor *descriptor;
|
||||
};
|
||||
#endif
|
||||
|
||||
int open_device_session(struct pwned_device *dev);
|
||||
int close_device_session(struct pwned_device *dev);
|
||||
int is_device_session_open(struct pwned_device *dev);
|
||||
|
||||
int partial_ctrl_transfer(struct pwned_device *dev,
|
||||
unsigned char bmRequestType, unsigned char bRequest,
|
||||
unsigned short wValue, unsigned short wIndex,
|
||||
unsigned char *data, unsigned short data_len,
|
||||
unsigned int timeout);
|
||||
|
||||
int no_error_ctrl_transfer(struct pwned_device *dev,
|
||||
unsigned char bmRequestType, unsigned char bRequest,
|
||||
unsigned short wValue, unsigned short wIndex,
|
||||
unsigned char *data, unsigned short data_len,
|
||||
unsigned int timeout);
|
||||
|
||||
int no_error_ctrl_transfer_data(struct pwned_device *dev,
|
||||
unsigned char bmRequestType, unsigned char bRequest,
|
||||
unsigned short wValue, unsigned short wIndex,
|
||||
unsigned char *data, unsigned short data_len,
|
||||
unsigned int timeout);
|
||||
|
||||
int ctrl_transfer(struct pwned_device *dev,
|
||||
unsigned char bmRequestType, unsigned char bRequest,
|
||||
unsigned short wValue, unsigned short wIndex,
|
||||
unsigned char *data, unsigned short data_len,
|
||||
unsigned int timeout);
|
||||
|
||||
int reset(struct pwned_device *dev);
|
||||
int serial_descriptor(struct pwned_device *dev, unsigned char *serial_buf, int len);
|
||||
|
||||
#endif //CHECKM8_TOOL_LIBUSB_HELPERS_H
|
||||
Reference in New Issue
Block a user