diff --git a/Exploits/fastPathSign/src/.gitignore b/Exploits/fastPathSign/src/.gitignore new file mode 100644 index 0000000..1c62076 --- /dev/null +++ b/Exploits/fastPathSign/src/.gitignore @@ -0,0 +1,3 @@ +external/include/choma +external/lib/libchoma.* +external/lib/libcrypto.a \ No newline at end of file diff --git a/Exploits/fastPathSign/src/external/.gitignore b/Exploits/fastPathSign/src/external/.keep similarity index 100% rename from Exploits/fastPathSign/src/external/.gitignore rename to Exploits/fastPathSign/src/external/.keep diff --git a/Exploits/fastPathSign/src/external/include/choma/Base64.h b/Exploits/fastPathSign/src/external/include/choma/Base64.h deleted file mode 100644 index a09d3ea..0000000 --- a/Exploits/fastPathSign/src/external/include/choma/Base64.h +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef BASE64_H -#define BASE64_H - -#include -#include - -char *base64_encode(const unsigned char *data, - size_t input_length, - size_t *output_length); - -#endif // BASE64_H \ No newline at end of file diff --git a/Exploits/fastPathSign/src/external/include/choma/BufferedStream.h b/Exploits/fastPathSign/src/external/include/choma/BufferedStream.h deleted file mode 100644 index bfad1b2..0000000 --- a/Exploits/fastPathSign/src/external/include/choma/BufferedStream.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef BUFFERED_STREAM_H -#define BUFFERED_STREAM_H - -#include "MemoryStream.h" -#include - -#define BUFFERED_STREAM_FLAG_AUTO_EXPAND (1 << 0) - -typedef struct BufferedStreamContext { - uint8_t *buffer; - size_t bufferSize; - uint32_t subBufferStart; - size_t subBufferSize; -} BufferedStreamContext; - -MemoryStream *buffered_stream_init_from_buffer_nocopy(void *buffer, size_t bufferSize, uint32_t flags); -MemoryStream *buffered_stream_init_from_buffer(void *buffer, size_t bufferSize, uint32_t flags); - -#endif // BUFFERED_STREAM_H \ No newline at end of file diff --git a/Exploits/fastPathSign/src/external/include/choma/CSBlob.h b/Exploits/fastPathSign/src/external/include/choma/CSBlob.h deleted file mode 100644 index 0eee4d1..0000000 --- a/Exploits/fastPathSign/src/external/include/choma/CSBlob.h +++ /dev/null @@ -1,118 +0,0 @@ -#ifndef CS_BLOB_H -#define CS_BLOB_H - -#include -#include -#include -#include - -#include "FAT.h" -#include "MachO.h" -#include "MemoryStream.h" - -// Blob index -typedef struct __BlobIndex { - uint32_t type; - uint32_t offset; -} CS_BlobIndex; - -// CMS superblob -typedef struct __SuperBlob { - uint32_t magic; - uint32_t length; - uint32_t count; - CS_BlobIndex index[]; -} CS_SuperBlob; - -typedef struct __GenericBlob { - uint32_t magic; /* magic number */ - uint32_t length; /* total length of blob */ - char data[]; -} CS_GenericBlob; - -// CMS blob magic types -typedef enum { - CSMAGIC_REQUIREMENT = 0xfade0c00, - CSMAGIC_REQUIREMENTS = 0xfade0c01, - CSMAGIC_CODEDIRECTORY = 0xfade0c02, - CSMAGIC_EMBEDDED_SIGNATURE = 0xfade0cc0, - CSMAGIC_EMBEDDED_SIGNATURE_OLD = 0xfade0b02, - CSMAGIC_EMBEDDED_ENTITLEMENTS = 0xfade7171, - CSMAGIC_EMBEDDED_DER_ENTITLEMENTS = 0xfade7172, - CSMAGIC_DETACHED_SIGNATURE = 0xfade0cc1, - CSMAGIC_BLOBWRAPPER = 0xfade0b01, - CSMAGIC_EMBEDDED_LAUNCH_CONSTRAINT = 0xfade8181, -} CS_BlobMagic; - -typedef enum { - CSSLOT_CODEDIRECTORY = 0, - CSSLOT_INFOSLOT = 1, - CSSLOT_REQUIREMENTS = 2, - CSSLOT_RESOURCEDIR = 3, - CSSLOT_APPLICATION = 4, - CSSLOT_ENTITLEMENTS = 5, - CSSLOT_DER_ENTITLEMENTS = 7, - CSSLOT_LAUNCH_CONSTRAINT_SELF = 8, - CSSLOT_LAUNCH_CONSTRAINT_PARENT = 9, - CSSLOT_LAUNCH_CONSTRAINT_RESPONSIBLE = 10, - CSSLOT_LIBRARY_CONSTRAINT = 11, - - CSSLOT_ALTERNATE_CODEDIRECTORIES = 0x1000, /* first alternate CodeDirectory, if any */ - CSSLOT_ALTERNATE_CODEDIRECTORY_MAX = 5, /* max number of alternate CD slots */ - CSSLOT_ALTERNATE_CODEDIRECTORY_LIMIT = CSSLOT_ALTERNATE_CODEDIRECTORIES + CSSLOT_ALTERNATE_CODEDIRECTORY_MAX, /* one past the last */ - - CSSLOT_SIGNATURESLOT = 0x10000, - CSSLOT_IDENTIFICATIONSLOT = 0x10001, - CSSLOT_TICKETSLOT = 0x10002, -} CS_SlotType; - -typedef struct s_CS_DecodedBlob { - struct s_CS_DecodedBlob *next; - uint32_t type; - MemoryStream *stream; -} CS_DecodedBlob; - -typedef struct s_CS_DecodedSuperBlob { - uint32_t magic; - struct s_CS_DecodedBlob *firstBlob; -} CS_DecodedSuperBlob; - -// Convert blob magic to readable blob type string -const char *cs_blob_magic_to_string(uint32_t magic); -const char *cs_slot_type_to_string(uint32_t slotType); - -// Extract Code Signature to file -int macho_extract_cs_to_file(MachO *macho, CS_SuperBlob *superblob); - -int macho_find_code_signature_bounds(MachO *macho, uint32_t *offsetOut, uint32_t *sizeOut); - -CS_SuperBlob *macho_read_code_signature(MachO *macho); - -int macho_replace_code_signature(MachO *macho, CS_SuperBlob *superblob); - -CS_DecodedBlob *csd_blob_init(uint32_t type, CS_GenericBlob *blobData); -int csd_blob_read(CS_DecodedBlob *blob, uint64_t offset, size_t size, void *outBuf); -int csd_blob_write(CS_DecodedBlob *blob, uint64_t offset, size_t size, const void *inBuf); -int csd_blob_insert(CS_DecodedBlob *blob, uint64_t offset, size_t size, const void *inBuf); -int csd_blob_delete(CS_DecodedBlob *blob, uint64_t offset, size_t size); -int csd_blob_read_string(CS_DecodedBlob *blob, uint64_t offset, char **outString); -int csd_blob_write_string(CS_DecodedBlob *blob, uint64_t offset, const char *string); -int csd_blob_get_size(CS_DecodedBlob *blob); -uint32_t csd_blob_get_type(CS_DecodedBlob *blob); -void csd_blob_set_type(CS_DecodedBlob *blob, uint32_t type); -void csd_blob_free(CS_DecodedBlob *blob); - -CS_DecodedSuperBlob *csd_superblob_init(void); -CS_DecodedSuperBlob *csd_superblob_decode(CS_SuperBlob *superblob); -CS_SuperBlob *csd_superblob_encode(CS_DecodedSuperBlob *decodedSuperblob); -CS_DecodedBlob *csd_superblob_find_blob(CS_DecodedSuperBlob *superblob, uint32_t type, uint32_t *indexOut); -int csd_superblob_insert_blob_after_blob(CS_DecodedSuperBlob *superblob, CS_DecodedBlob *blobToInsert, CS_DecodedBlob *afterBlob); -int csd_superblob_insert_blob_at_index(CS_DecodedSuperBlob *superblob, CS_DecodedBlob *blobToInsert, uint32_t atIndex); -int csd_superblob_append_blob(CS_DecodedSuperBlob *superblob, CS_DecodedBlob *blobToAppend); -int csd_superblob_remove_blob(CS_DecodedSuperBlob *superblob, CS_DecodedBlob *blobToRemove); // <- Important: When calling this, caller is responsible for freeing blobToRemove -int csd_superblob_remove_blob_at_index(CS_DecodedSuperBlob *superblob, uint32_t atIndex); -int csd_superblob_print_content(CS_DecodedSuperBlob *decodedSuperblob, MachO *macho, bool printAllSlots, bool verifySlots); -void csd_superblob_free(CS_DecodedSuperBlob *decodedSuperblob); - - -#endif // CS_BLOB_H \ No newline at end of file diff --git a/Exploits/fastPathSign/src/external/include/choma/CodeDirectory.h b/Exploits/fastPathSign/src/external/include/choma/CodeDirectory.h deleted file mode 100644 index 36cca20..0000000 --- a/Exploits/fastPathSign/src/external/include/choma/CodeDirectory.h +++ /dev/null @@ -1,55 +0,0 @@ -#ifndef CODE_DIRECTORY_H -#define CODE_DIRECTORY_H - -#include -#include -#include - -#include "MachO.h" -#include "CSBlob.h" -#include "FAT.h" -#include "MachOByteOrder.h" -#include "MachOLoadCommand.h" -#include "MemoryStream.h" - -// Code directory blob header -typedef struct __CodeDirectory { - uint32_t magic; - uint32_t length; - uint32_t version; - uint32_t flags; - uint32_t hashOffset; - uint32_t identOffset; - uint32_t nSpecialSlots; - uint32_t nCodeSlots; - uint32_t codeLimit; - uint8_t hashSize; - uint8_t hashType; - uint8_t platform; - uint8_t pageSize; - uint32_t spare2; - - /* Version 0x20100 */ - uint32_t scatterOffset; - uint32_t teamOffset; -} CS_CodeDirectory -__attribute__ ((aligned(1))); - -enum CS_HashType { - CS_HASHTYPE_SHA160_160 = 1, - CS_HASHTYPE_SHA256_256 = 2, - CS_HASHTYPE_SHA256_160 = 3, - CS_HASHTYPE_SHA384_384 = 4, -}; - -char *csd_code_directory_copy_identifier(CS_DecodedBlob *codeDirBlob, uint32_t *offsetOut); -char *csd_code_directory_copy_team_id(CS_DecodedBlob *codeDirBlob, uint32_t *offsetOut); -int csd_code_directory_set_team_id(CS_DecodedBlob *codeDirBlob, char *newTeamID); -uint32_t csd_code_directory_get_flags(CS_DecodedBlob *codeDirBlob); -void csd_code_directory_set_flags(CS_DecodedBlob *codeDirBlob, uint32_t flags); -uint8_t csd_code_directory_get_hash_type(CS_DecodedBlob *codeDirBlob); -void csd_code_directory_set_hash_type(CS_DecodedBlob *codeDirBlob, uint8_t hashType); -int csd_code_directory_print_content(CS_DecodedBlob *codeDirBlob, MachO *macho, bool printSlots, bool verifySlots); -void csd_code_directory_update(CS_DecodedBlob *codeDirBlob, MachO *macho); - -#endif // CODE_DIRECTORY_H \ No newline at end of file diff --git a/Exploits/fastPathSign/src/external/include/choma/FAT.h b/Exploits/fastPathSign/src/external/include/choma/FAT.h deleted file mode 100644 index 102133b..0000000 --- a/Exploits/fastPathSign/src/external/include/choma/FAT.h +++ /dev/null @@ -1,46 +0,0 @@ -#ifndef MACHO_H -#define MACHO_H - -#include -#include -#include -#include -#include -#include - -#include "MemoryStream.h" -typedef struct MachO MachO; - -// A FAT structure can either represent a FAT file with multiple slices, in which the slices will be loaded into the slices attribute -// Or a single slice MachO, in which case it serves as a compatibility layer and the single slice will also be loaded into the slices attribute -typedef struct FAT -{ - MemoryStream *stream; - MachO **slices; - uint32_t slicesCount; - int fileDescriptor; -} FAT; - -int fat_read_at_offset(FAT *fat, uint64_t offset, size_t size, void *outBuf); - -MemoryStream *fat_get_stream(FAT *fat); - -// Initialise a FAT structure from a memory stream -FAT *fat_init_from_memory_stream(MemoryStream *stream); - -// Initialise a FAT structure using the path to the file -FAT *fat_init_from_path(const char *filePath); - -// Find macho with cputype and cpusubtype in FAT, returns NULL if not found -MachO *fat_find_slice(FAT *fat, cpu_type_t cputype, cpu_subtype_t cpusubtype); - -// Create a FAT structure from an array of MachO structures -FAT *fat_create_for_macho_array(char *firstInputPath, MachO **machoArray, int machoArrayCount); - -// Add a MachO to the FAT structure -int fat_add_macho(FAT *fat, MachO *macho); - -// Free all elements of the FAT structure -void fat_free(FAT *fat); - -#endif // MACHO_H \ No newline at end of file diff --git a/Exploits/fastPathSign/src/external/include/choma/FileStream.h b/Exploits/fastPathSign/src/external/include/choma/FileStream.h deleted file mode 100644 index 3cab1ea..0000000 --- a/Exploits/fastPathSign/src/external/include/choma/FileStream.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef FILE_STREAM_H -#define FILE_STREAM_H - -#include "MemoryStream.h" - -#define FILE_STREAM_SIZE_AUTO 0 -#define FILE_STREAM_FLAG_WRITABLE (1 << 0) -#define FILE_STREAM_FLAG_AUTO_EXPAND (1 << 1) - -typedef struct FileStreamContext { - int fd; - size_t fileSize; - uint32_t bufferStart; - size_t bufferSize; -} FileStreamContext; - -MemoryStream *file_stream_init_from_file_descriptor_nodup(int fd, uint32_t bufferStart, size_t bufferSize, uint32_t flags); -MemoryStream *file_stream_init_from_file_descriptor(int fd, uint32_t bufferStart, size_t bufferSize, uint32_t flags); -MemoryStream *file_stream_init_from_path(const char *path, uint32_t bufferStart, size_t bufferSize, uint32_t flags); - -#endif // FILE_STREAM_H \ No newline at end of file diff --git a/Exploits/fastPathSign/src/external/include/choma/Host.h b/Exploits/fastPathSign/src/external/include/choma/Host.h deleted file mode 100644 index 56051c0..0000000 --- a/Exploits/fastPathSign/src/external/include/choma/Host.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef HOST_H -#define HOST_H - -#include "FAT.h" - -// Retrieve the preferred MachO slice from a FAT -// Preferred slice as in the slice that the kernel would use when loading the file -MachO *fat_find_preferred_slice(FAT *fat); - -#endif // HOST_H \ No newline at end of file diff --git a/Exploits/fastPathSign/src/external/include/choma/MachO.h b/Exploits/fastPathSign/src/external/include/choma/MachO.h deleted file mode 100644 index 1b933ba..0000000 --- a/Exploits/fastPathSign/src/external/include/choma/MachO.h +++ /dev/null @@ -1,68 +0,0 @@ -#ifndef MACHO_SLICE_H -#define MACHO_SLICE_H - -#include -#include -#include -#include "MemoryStream.h" -#include "FAT.h" - -typedef struct MachOSegment -{ - struct segment_command_64 command; - struct section_64 sections[]; -} __attribute__((__packed__)) MachOSegment; - -typedef struct FilesetMachO { - char *entry_id; - uint64_t vmaddr; - uint64_t fileoff; - FAT *underlyingMachO; -} FilesetMachO; - -typedef struct MachO { - MemoryStream *stream; - bool isSupported; - struct mach_header_64 machHeader; - struct fat_arch_64 archDescriptor; - - uint32_t filesetCount; - FilesetMachO *filesetMachos; - - uint32_t segmentCount; - MachOSegment **segments; -} MachO; - -// Read data from a MachO at a specified offset -int macho_read_at_offset(MachO *macho, uint64_t offset, size_t size, void *outBuf); - -// Write data from a MachO at a specified offset, auto expands, only works if opened via macho_init_for_writing -int macho_write_at_offset(MachO *macho, uint64_t offset, size_t size, void *inBuf); - -MemoryStream *macho_get_stream(MachO *macho); -uint32_t macho_get_filetype(MachO *macho); - -// Perform translation between file offsets and virtual addresses -int macho_translate_fileoff_to_vmaddr(MachO *macho, uint64_t fileoff, uint64_t *vmaddrOut, MachOSegment **segmentOut); -int macho_translate_vmaddr_to_fileoff(MachO *macho, uint64_t vmaddr, uint64_t *fileoffOut, MachOSegment **segmentOut); - -// Read data from a MachO at a specified virtual address -int macho_read_at_vmaddr(MachO *macho, uint64_t vmaddr, size_t size, void *outBuf); - -int macho_enumerate_load_commands(MachO *macho, void (^enumeratorBlock)(struct load_command loadCommand, uint64_t offset, void *cmd, bool *stop)); - -// Initialise a MachO object from a MemoryStream and it's corresponding FAT arch descriptor -MachO *macho_init(MemoryStream *stream, struct fat_arch_64 archDescriptor); - -// Initialize a single slice macho for writing to it -MachO *macho_init_for_writing(const char *filePath); - -// Create an array of MachO objects from an array of paths -MachO **macho_array_create_for_paths(char **inputPaths, int inputPathsCount); - -// Check if a MachO is encrypted -bool macho_is_encrypted(MachO *macho); - -void macho_free(MachO *macho); - -#endif // MACHO_SLICE_H \ No newline at end of file diff --git a/Exploits/fastPathSign/src/external/include/choma/MachOByteOrder.h b/Exploits/fastPathSign/src/external/include/choma/MachOByteOrder.h deleted file mode 100644 index 510df98..0000000 --- a/Exploits/fastPathSign/src/external/include/choma/MachOByteOrder.h +++ /dev/null @@ -1,171 +0,0 @@ -#ifndef MACHO_BYTE_ORDER_H -#define MACHO_BYTE_ORDER_H - -#include -#include - -// 8-bit integers needed for CodeDirectory -#define BIG_TO_HOST(n) _Generic((n), \ - int8_t: n, \ - uint8_t: n, \ - int16_t: OSSwapBigToHostInt16(n), \ - uint16_t: OSSwapBigToHostInt16(n), \ - int32_t: OSSwapBigToHostInt32(n), \ - uint32_t: OSSwapBigToHostInt32(n), \ - int64_t: OSSwapBigToHostInt64(n), \ - uint64_t: OSSwapBigToHostInt64(n) \ -) - -#define HOST_TO_BIG(n) _Generic((n), \ - int8_t: n, \ - uint8_t: n, \ - uint16_t: OSSwapHostToBigInt16(n), \ - int16_t: OSSwapHostToBigInt16(n), \ - int32_t: OSSwapHostToBigInt32(n), \ - uint32_t: OSSwapHostToBigInt32(n), \ - int64_t: OSSwapHostToBigInt64(n), \ - uint64_t: OSSwapHostToBigInt64(n) \ -) - -#define LITTLE_TO_HOST(n) _Generic((n), \ - int8_t: n, \ - uint8_t: n, \ - int16_t: OSSwapLittleToHostInt16(n), \ - uint16_t: OSSwapLittleToHostInt16(n), \ - int32_t: OSSwapLittleToHostInt32(n), \ - uint32_t: OSSwapLittleToHostInt32(n), \ - int64_t: OSSwapLittleToHostInt64(n), \ - uint64_t: OSSwapLittleToHostInt64(n) \ -) - -#define HOST_TO_LITTLE(n) _Generic((n), \ - int8_t: n, \ - uint8_t: n, \ - int16_t: OSSwapHostToLittleInt16(n), \ - uint16_t: OSSwapHostToLittleInt16(n), \ - int32_t: OSSwapHostToLittleInt32(n), \ - uint32_t: OSSwapHostToLittleInt32(n), \ - int64_t: OSSwapHostToLittleInt64(n), \ - uint64_t: OSSwapHostToLittleInt64(n) \ -) - -#define HOST_TO_LITTLE_APPLIER(instance, member) \ - (instance)->member = HOST_TO_LITTLE((instance)->member) - -#define HOST_TO_BIG_APPLIER(instance, member) \ - (instance)->member = HOST_TO_BIG((instance)->member) - -#define LITTLE_TO_HOST_APPLIER(instance, member) \ - (instance)->member = LITTLE_TO_HOST((instance)->member) - -#define BIG_TO_HOST_APPLIER(instance, member) \ - (instance)->member = BIG_TO_HOST((instance)->member) - -#define FAT_HEADER_APPLY_BYTE_ORDER(fh, applier) \ - applier(fh, magic); \ - applier(fh, nfat_arch); - -#define FAT_ARCH_APPLY_BYTE_ORDER(arch, applier) \ - applier(arch, cputype); \ - applier(arch, cpusubtype); \ - applier(arch, offset); \ - applier(arch, size); \ - applier(arch, align); \ - -#define FAT_ARCH_64_APPLY_BYTE_ORDER(arch, applier) \ - applier(arch, cputype); \ - applier(arch, cpusubtype); \ - applier(arch, offset); \ - applier(arch, size); \ - applier(arch, align); \ - applier(arch, reserved); \ - -#define MACH_HEADER_APPLY_BYTE_ORDER(mh, applier) \ - applier(mh, magic); \ - applier(mh, cputype); \ - applier(mh, cpusubtype); \ - applier(mh, filetype); \ - applier(mh, ncmds); \ - applier(mh, sizeofcmds); \ - applier(mh, reserved); - -#define LOAD_COMMAND_APPLY_BYTE_ORDER(lc, applier) \ - applier(lc, cmd); \ - applier(lc, cmdsize); - -#define LINKEDIT_DATA_COMMAND_APPLY_BYTE_ORDER(lc, applier) \ - applier(lc, cmd); \ - applier(lc, cmdsize); \ - applier(lc, dataoff); \ - applier(lc, datasize); - -#define ENCRYPTION_INFO_COMMAND_APPLY_BYTE_ORDER(eic, applier) \ - applier(eic, cmd); \ - applier(eic, cmdsize); \ - applier(eic, cryptoff); \ - applier(eic, cryptsize); \ - applier(eic, cryptid); - -#define BLOB_INDEX_APPLY_BYTE_ORDER(bi, applier) \ - applier(bi, type); \ - applier(bi, offset); - -#define SUPERBLOB_APPLY_BYTE_ORDER(sb, applier) \ - applier(sb, magic); \ - applier(sb, length); \ - applier(sb, count); - -#define GENERIC_BLOB_APPLY_BYTE_ORDER(gb, applier) \ - applier(gb, magic); \ - applier(gb, length); - -#define CODE_DIRECTORY_APPLY_BYTE_ORDER(cd, applier) \ - applier(cd, magic); \ - applier(cd, length); \ - applier(cd, version); \ - applier(cd, flags); \ - applier(cd, hashOffset); \ - applier(cd, identOffset); \ - applier(cd, nSpecialSlots); \ - applier(cd, nCodeSlots); \ - applier(cd, codeLimit); \ - applier(cd, hashSize); \ - applier(cd, hashType); \ - applier(cd, platform); \ - applier(cd, pageSize); \ - applier(cd, spare2); \ - applier(cd, scatterOffset); \ - applier(cd, teamOffset); - -#define SEGMENT_COMMAND_64_APPLY_BYTE_ORDER(sc64, applier) \ - applier(sc64, cmd); \ - applier(sc64, cmdsize); \ - applier(sc64, fileoff); \ - applier(sc64, filesize); \ - applier(sc64, vmaddr); \ - applier(sc64, vmsize); \ - applier(sc64, flags); \ - applier(sc64, initprot); \ - applier(sc64, maxprot); \ - applier(sc64, nsects); - -#define SECTION_64_APPLY_BYTE_ORDER(sc64, applier) \ - applier(sc64, addr); \ - applier(sc64, align); \ - applier(sc64, flags); \ - applier(sc64, nreloc); \ - applier(sc64, offset); \ - applier(sc64, reserved1); \ - applier(sc64, reserved2); \ - applier(sc64, reserved3); \ - applier(sc64, size); - -#define FILESET_ENTRY_COMMAND_APPLY_BYTE_ORDER(fse, applier) \ - applier(fse, cmd); \ - applier(fse, cmdsize); \ - applier(fse, vmaddr); \ - applier(fse, fileoff); \ - applier(fse, entry_id.offset); \ - applier(fse, reserved); \ - -#endif // MACHO_BYTE_ORDER_H \ No newline at end of file diff --git a/Exploits/fastPathSign/src/external/include/choma/MachOLoadCommand.h b/Exploits/fastPathSign/src/external/include/choma/MachOLoadCommand.h deleted file mode 100644 index ae5514a..0000000 --- a/Exploits/fastPathSign/src/external/include/choma/MachOLoadCommand.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef MACHO_LOAD_COMMAND_H -#define MACHO_LOAD_COMMAND_H - -#include -#include "MachO.h" -#include "FileStream.h" -#include "MachOByteOrder.h" -#include "CSBlob.h" - -// Convert load command to load command name -char *load_command_to_string(int loadCommand); -void update_segment_command_64(MachO *macho, const char *segmentName, uint64_t vmaddr, uint64_t vmsize, uint64_t fileoff, uint64_t filesize); -void update_lc_code_signature(MachO *macho, uint64_t size); -int update_load_commands_for_coretrust_bypass(MachO *macho, CS_SuperBlob *superblob, uint64_t originalCodeSignatureSize, uint64_t originalMachOSize); - -#endif // MACHO_LOAD_COMMAND_H \ No newline at end of file diff --git a/Exploits/fastPathSign/src/external/include/choma/MemoryStream.h b/Exploits/fastPathSign/src/external/include/choma/MemoryStream.h deleted file mode 100644 index ba00102..0000000 --- a/Exploits/fastPathSign/src/external/include/choma/MemoryStream.h +++ /dev/null @@ -1,60 +0,0 @@ -#ifndef MEMORY_STREAM_H -#define MEMORY_STREAM_H - -#include -#include -#include -#include -#include -#include -#include - -#define MEMORY_STREAM_FLAG_OWNS_DATA (1 << 0) -#define MEMORY_STREAM_FLAG_MUTABLE (1 << 1) -#define MEMORY_STREAM_FLAG_AUTO_EXPAND (1 << 2) - -#define MEMORY_STREAM_SIZE_INVALID (size_t)-1 - -// A generic memory IO interface that is used throughout this project -// Can be backed by anything, just the functions have to be implemented -typedef struct s_MemoryStream { - void *context; - uint32_t flags; - - int (*read)(struct s_MemoryStream *stream, uint64_t offset, size_t size, void *outBuf); - int (*write)(struct s_MemoryStream *stream, uint64_t offset, size_t size, const void *inBuf); - int (*getSize)(struct s_MemoryStream *stream, size_t *sizeOut); - uint8_t *(*getRawPtr)(struct s_MemoryStream *stream); - - int (*trim)(struct s_MemoryStream *stream, size_t trimAtStart, size_t trimAtEnd); - int (*expand)(struct s_MemoryStream *stream, size_t expandAtStart, size_t expandAtEnd); - - struct s_MemoryStream *(*hardclone)(struct s_MemoryStream *stream); - struct s_MemoryStream *(*softclone)(struct s_MemoryStream *stream); - void (*free)(struct s_MemoryStream *stream); -} MemoryStream; - -int memory_stream_read(MemoryStream *stream, uint64_t offset, size_t size, void *outBuf); -int memory_stream_write(MemoryStream *stream, uint64_t offset, size_t size, const void *inBuf); - -int memory_stream_insert(MemoryStream *stream, uint64_t offset, size_t size, const void *inBuf); -int memory_stream_delete(MemoryStream *stream, uint64_t offset, size_t size); - -int memory_stream_read_string(MemoryStream *stream, uint64_t offset, char **outString); -int memory_stream_write_string(MemoryStream *stream, uint64_t offset, const char *string); - -size_t memory_stream_get_size(MemoryStream *stream); -uint8_t *memory_stream_get_raw_pointer(MemoryStream *stream); -uint32_t memory_stream_get_flags(MemoryStream *stream); - -MemoryStream *memory_stream_softclone(MemoryStream *stream); -MemoryStream *memory_stream_hardclone(MemoryStream *stream); -int memory_stream_trim(MemoryStream *stream, size_t trimAtStart, size_t trimAtEnd); -int memory_stream_expand(MemoryStream *stream, size_t expandAtStart, size_t expandAtEnd); - -void memory_stream_free(MemoryStream *stream); - -int memory_stream_copy_data(MemoryStream *originStream, uint64_t originOffset, MemoryStream *targetStream, uint64_t targetOffset, size_t size); -int memory_stream_find_memory(MemoryStream *stream, uint64_t searchStartOffset, uint64_t searchEndOffset, void *bytes, void *mask, size_t nbytes, uint16_t alignment, uint64_t *foundOffsetOut); - -#endif // MEMORY_STREAM_H \ No newline at end of file diff --git a/Exploits/fastPathSign/src/external/include/choma/PatchFinder.h b/Exploits/fastPathSign/src/external/include/choma/PatchFinder.h deleted file mode 100644 index 84cc117..0000000 --- a/Exploits/fastPathSign/src/external/include/choma/PatchFinder.h +++ /dev/null @@ -1,75 +0,0 @@ -#ifndef PATCHFINDER_H -#define PATCHFINDER_H - -#include -#include "MachO.h" - -enum { - PF_METRIC_TYPE_PATTERN, - PF_METRIC_TYPE_STRING, - PF_METRIC_TYPE_XREF, -}; - -typedef struct s_PFSection { - MachO *macho; - uint64_t fileoff; - uint64_t vmaddr; - uint64_t size; - uint8_t *cache; - bool ownsCache; -} PFSection; - -PFSection *pfsec_init_from_macho(MachO *macho, const char *filesetEntryId, const char *segName, const char *sectName); -int pfsec_read_reloff(PFSection *section, uint64_t rel, size_t size, void *outBuf); -uint32_t pfsec_read32_reloff(PFSection *section, uint64_t rel); -int pfsec_read_at_address(PFSection *section, uint64_t vmaddr, void *outBuf, size_t size); -uint32_t pfsec_read32(PFSection *section, uint64_t vmaddr); -uint64_t pfsec_read64(PFSection *section, uint64_t vmaddr); -int pfsec_read_string(PFSection *section, uint64_t vmaddr, char **outString); -int pfsec_set_cached(PFSection *section, bool cached); -uint64_t pfsec_find_prev_inst(PFSection *section, uint64_t startAddr, uint32_t searchCount, uint32_t inst, uint32_t mask); -uint64_t pfsec_find_next_inst(PFSection *section, uint64_t startAddr, uint32_t searchCount, uint32_t inst, uint32_t mask); -uint64_t pfsec_find_function_start(PFSection *section, uint64_t midAddr); -void pfsec_free(PFSection *section); - - -typedef struct s_MetricShared { - uint32_t type; -} MetricShared; - -typedef struct s_PFPatternMetric { - MetricShared shared; - - void *bytes; - void *mask; - size_t nbytes; - uint16_t alignment; -} PFPatternMetric; - -typedef struct s_PFStringMetric { - MetricShared shared; - - char *string; -} PFStringMetric; - -typedef enum { - XREF_TYPE_MASK_CALL = (1 << 0), - XREF_TYPE_MASK_REFERENCE = (1 << 1), - XREF_TYPE_MASK_ALL = (XREF_TYPE_MASK_CALL | XREF_TYPE_MASK_REFERENCE), -} PFXrefTypeMask; - -typedef struct s_PFXrefMetric { - MetricShared shared; - - uint64_t address; - PFXrefTypeMask typeMask; -} PFXrefMetric; - -PFPatternMetric *pfmetric_pattern_init(void *bytes, void *mask, size_t nbytes, uint16_t alignment); -PFStringMetric *pfmetric_string_init(const char *string); -PFXrefMetric *pfmetric_xref_init(uint64_t address, PFXrefTypeMask types); -void pfmetric_free(void *metric); - -void pfmetric_run_in_range(PFSection *section, uint64_t startAddr, uint64_t endAddr, void *metric, void (^matchBlock)(uint64_t vmaddr, bool *stop)); -void pfmetric_run(PFSection *section, void *metric, void (^matchBlock)(uint64_t vmaddr, bool *stop)); -#endif \ No newline at end of file diff --git a/Exploits/fastPathSign/src/external/include/choma/PatchFinder_arm64.h b/Exploits/fastPathSign/src/external/include/choma/PatchFinder_arm64.h deleted file mode 100644 index c487bd6..0000000 --- a/Exploits/fastPathSign/src/external/include/choma/PatchFinder_arm64.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef PATCHFINDER_ARM64_H -#define PATCHFINDER_ARM64_H - -#include "PatchFinder.h" - -typedef enum { - ARM64_XREF_TYPE_B = 0, - ARM64_XREF_TYPE_BL = 1, - ARM64_XREF_TYPE_ADR = 2, - ARM64_XREF_TYPE_ADRP_ADD = 3, - ARM64_XREF_TYPE_ADRP_LDR = 4, - ARM64_XREF_TYPE_ADRP_STR = 5, -} Arm64XrefType; - -typedef enum { - ARM64_XREF_TYPE_MASK_B = (1 << ARM64_XREF_TYPE_B), - ARM64_XREF_TYPE_MASK_BL = (1 << ARM64_XREF_TYPE_BL), - ARM64_XREF_TYPE_MASK_CALL = (ARM64_XREF_TYPE_MASK_B | ARM64_XREF_TYPE_MASK_BL), - - ARM64_XREF_TYPE_MASK_ADR = (1 << ARM64_XREF_TYPE_ADR), - ARM64_XREF_TYPE_MASK_ADRP_ADD = (1 << ARM64_XREF_TYPE_ADRP_ADD), - ARM64_XREF_TYPE_MASK_ADRP_LDR = (1 << ARM64_XREF_TYPE_ADRP_LDR), - ARM64_XREF_TYPE_MASK_ADRP_STR = (1 << ARM64_XREF_TYPE_ADRP_STR), - ARM64_XREF_TYPE_MASK_REFERENCE = (ARM64_XREF_TYPE_MASK_ADR | ARM64_XREF_TYPE_MASK_ADRP_ADD | ARM64_XREF_TYPE_MASK_ADRP_LDR | ARM64_XREF_TYPE_MASK_ADRP_STR), - - ARM64_XREF_TYPE_ALL = (ARM64_XREF_TYPE_MASK_CALL | ARM64_XREF_TYPE_MASK_REFERENCE), -} Arm64XrefTypeMask; - -uint64_t pfsec_arm64_resolve_adrp_ldr_str_add_reference(PFSection *section, uint64_t adrpAddr, uint64_t ldrStrAddAddr); -uint64_t pfsec_arm64_resolve_adrp_ldr_str_add_reference_auto(PFSection *section, uint64_t ldrStrAddAddr); -uint64_t pfsec_arm64_resolve_stub(PFSection *section, uint64_t stubAddr); -void pfsec_arm64_enumerate_xrefs(PFSection *section, Arm64XrefTypeMask types, void (^xrefBlock)(Arm64XrefType type, uint64_t source, uint64_t target, bool *stop)); -#endif \ No newline at end of file diff --git a/Exploits/fastPathSign/src/external/include/choma/SignOSSL.h b/Exploits/fastPathSign/src/external/include/choma/SignOSSL.h deleted file mode 100644 index f1be620..0000000 --- a/Exploits/fastPathSign/src/external/include/choma/SignOSSL.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef SIGN_OSSL_H -#define SIGN_OSSL_H - -#ifndef DISABLE_SIGNING - -#include -#include -#include -#include -#include -#include -#include - -unsigned char *signWithRSA(unsigned char *inputData, size_t inputDataLength, unsigned char *key, size_t key_len, size_t *outputDataLength); - -#endif - -#endif // SIGN_OSSL_H - -// 0xA422 \ No newline at end of file diff --git a/Exploits/fastPathSign/src/external/include/choma/Util.h b/Exploits/fastPathSign/src/external/include/choma/Util.h deleted file mode 100644 index e4ccf64..0000000 --- a/Exploits/fastPathSign/src/external/include/choma/Util.h +++ /dev/null @@ -1,34 +0,0 @@ -#ifndef UTIL_H -#define UTIL_H - -#include -#include -#include - -typedef struct s_optional_uint64 { - bool isSet; - uint64_t value; -} optional_uint64_t; -#define OPT_UINT64_IS_SET(x) (x.isSet) -#define OPT_UINT64_GET_VAL(x) (x.value) -#define OPT_UINT64_NONE (optional_uint64_t){.isSet = false, .value = 0} -#define OPT_UINT64(x) (optional_uint64_t){.isSet = true, .value = x} - - -typedef struct s_optional_bool { - bool isSet; - bool value; -} optional_bool; -#define OPT_BOOL_IS_SET(x) (x.isSet) -#define OPT_BOOL_GET_VAL(x) (x.value) -#define OPT_BOOL_NONE (optional_bool){.isSet = false, .value = false} -#define OPT_BOOL(x) (optional_bool){.isSet = true, .value = x} - -int64_t sxt64(int64_t value, uint8_t bits); -int memcmp_masked(const void *str1, const void *str2, unsigned char* mask, size_t n); -uint64_t align_to_size(int size, int alignment); -int count_digits(int64_t num); -void print_hash(uint8_t *hash, size_t size); -void enumerate_range(uint64_t start, uint64_t end, uint16_t alignment, size_t nbytes, bool (^enumerator)(uint64_t cur)); - -#endif \ No newline at end of file diff --git a/Exploits/fastPathSign/src/external/include/choma/arm64.h b/Exploits/fastPathSign/src/external/include/choma/arm64.h deleted file mode 100644 index 9affc1d..0000000 --- a/Exploits/fastPathSign/src/external/include/choma/arm64.h +++ /dev/null @@ -1,94 +0,0 @@ -#ifndef ARM64_H -#define ARM64_H - -#include "Util.h" - -typedef enum { - // registers - ARM64_REG_TYPE_X, - ARM64_REG_TYPE_W, - - // vector shit - ARM64_REG_TYPE_Q, - ARM64_REG_TYPE_D, - ARM64_REG_TYPE_S, - ARM64_REG_TYPE_H, - ARM64_REG_TYPE_B, -} arm64_register_type; - -enum { - ARM64_REG_MASK_ANY_FLAG = (1 << 0), - ARM64_REG_MASK_X_W = (1 << 1), - ARM64_REG_MASK_VECTOR = (1 << 2), - ARM64_REG_MASK_ALL = (ARM64_REG_MASK_X_W | ARM64_REG_MASK_VECTOR), - - ARM64_REG_MASK_ANY_X_W = (ARM64_REG_MASK_X_W | ARM64_REG_MASK_ANY_FLAG), - ARM64_REG_MASK_ANY_VECTOR = (ARM64_REG_MASK_VECTOR | ARM64_REG_MASK_ANY_FLAG), - ARM64_REG_MASK_ANY_ALL = (ARM64_REG_MASK_ALL | ARM64_REG_MASK_ANY_FLAG), -}; - -typedef enum { - LDR_STR_TYPE_ANY, // NOTE: "ANY" will inevitably also match STUR and LDUR instructions - LDR_STR_TYPE_POST_INDEX, - LDR_STR_TYPE_PRE_INDEX, - LDR_STR_TYPE_UNSIGNED, -} arm64_ldr_str_type; - -typedef struct s_arm64_register { - uint8_t mask; - arm64_register_type type; - uint8_t num; -} arm64_register; - -#define ARM64_REG(type_, num_) (arm64_register){.mask = ARM64_REG_MASK_ALL, .type = type_, .num = num_} -#define ARM64_REG_X(x) ARM64_REG(ARM64_REG_TYPE_X, x) -#define ARM64_REG_W(x) ARM64_REG(ARM64_REG_TYPE_W, x) -#define ARM64_REG_Q(x) ARM64_REG(ARM64_REG_TYPE_Q, x) -#define ARM64_REG_S(x) ARM64_REG(ARM64_REG_TYPE_S, x) -#define ARM64_REG_H(x) ARM64_REG(ARM64_REG_TYPE_H, x) -#define ARM64_REG_B(x) ARM64_REG(ARM64_REG_TYPE_B, x) -#define ARM64_REG_ANY (arm64_register){.mask = ARM64_REG_MASK_ANY_ALL, .type = 0, .num = 0} -#define ARM64_REG_ANY_X_W (arm64_register){.mask = ARM64_REG_MASK_ANY_X_W, .type = 0, .num = 0} -#define ARM64_REG_ANY_VECTOR (arm64_register){.mask = ARM64_REG_MASK_ANY_VECTOR, .type = 0, .num = 0} -#define ARM64_REG_GET_TYPE(x) (x.type) -#define ARM64_REG_IS_X(x) (x.type == ARM64_REG_TYPE_X) -#define ARM64_REG_IS_W(x) (x.type == ARM64_REG_TYPE_W) -#define ARM64_REG_IS_VECTOR(x) (x.type == ARM64_REG_TYPE_Q || x.type == ARM64_REG_TYPE_D || x.type == ARM64_REG_TYPE_S || x.type == ARM64_REG_TYPE_H || x.type == ARM64_REG_TYPE_B) -#define ARM64_REG_GET_NUM(x) (x.num & 0x1f) -#define ARM64_REG_IS_ANY(x) (x.mask == ARM64_REG_MASK_ANY_ALL) -#define ARM64_REG_IS_ANY_X_W(x) (x.mask == ARM64_REG_MASK_ANY_X_W) -#define ARM64_REG_IS_ANY_VECTOR(x) (x.mask == ARM64_REG_MASK_ANY_VECTOR) -uint8_t arm64_reg_type_get_width(arm64_register_type type); -const char *arm64_reg_type_get_string(arm64_register_type type); -const char *arm64_reg_get_type_string(arm64_register reg); - -#define ARM64_REG_NUM_SP 31 - -typedef struct s_arm64_cond { - bool isSet; - uint8_t value; -} arm64_cond; -#define ARM64_COND(x) (arm64_cond){.isSet = true, .value = x} -#define ARM64_COND_ANY (arm64_cond){.isSet = false, .value = 0} -#define ARM64_COND_GET_VAL(x) (x.value & 0xf) -#define ARM64_COND_IS_SET(x) x.isSet - -int arm64_gen_b_l(optional_bool optIsBl, optional_uint64_t optOrigin, optional_uint64_t optTarget, uint32_t *bytesOut, uint32_t *maskOut); -int arm64_dec_b_l(uint32_t inst, uint64_t origin, uint64_t *targetOut, bool *isBlOut); -int arm64_gen_b_c_cond(optional_bool optIsBc, optional_uint64_t optOrigin, optional_uint64_t optTarget, arm64_cond optCond, uint32_t *bytesOut, uint32_t *maskOut); -int arm64_dec_b_c_cond(uint32_t inst, uint64_t origin, uint64_t *targetOut, arm64_cond *condOut, bool *isBcOut); -int arm64_gen_adr_p(optional_bool optIsAdrp, optional_uint64_t optOrigin, optional_uint64_t optTarget, arm64_register reg, uint32_t *bytesOut, uint32_t *maskOut); -int arm64_dec_adr_p(uint32_t inst, uint64_t origin, uint64_t *targetOut, arm64_register *registerOut, bool *isAdrpOut); -int arm64_gen_mov_imm(char type, arm64_register destinationReg, optional_uint64_t optImm, optional_uint64_t optShift, uint32_t *bytesOut, uint32_t *maskOut); -int arm64_dec_mov_imm(uint32_t inst, arm64_register *destinationRegOut, uint64_t *immOut, uint64_t *shiftOut, char *typeOut); -int arm64_gen_add_imm(arm64_register destinationReg, arm64_register sourceReg, optional_uint64_t optImm, uint32_t *bytesOut, uint32_t *maskOut); -int arm64_dec_add_imm(uint32_t inst, arm64_register *destinationRegOut, arm64_register *sourceRegOut, uint16_t *immOut); -int arm64_gen_ldr_imm(char type, arm64_ldr_str_type instType, arm64_register destinationReg, arm64_register addrReg, optional_uint64_t optImm, uint32_t *bytesOut, uint32_t *maskOut); -int arm64_dec_ldr_imm(uint32_t inst, arm64_register *destinationReg, arm64_register *addrReg, uint64_t *immOut, char *typeOut, arm64_ldr_str_type *instTypeOut); -int arm64_gen_str_imm(char type, arm64_ldr_str_type instType, arm64_register sourceReg, arm64_register addrReg, optional_uint64_t optImm, uint32_t *bytesOut, uint32_t *maskOut); -int arm64_dec_str_imm(uint32_t inst, arm64_register *sourceRegOut, arm64_register *addrRegOut, uint64_t *immOut, char *typeOut, arm64_ldr_str_type *instTypeOut); -int arm64_gen_ldr_lit(arm64_register destinationReg, optional_uint64_t optImm, uint32_t *bytesOut, uint32_t *maskOut); -int arm64_dec_ldr_lit(uint32_t inst, arm64_register *destinationReg, int64_t *immOut); -int arm64_gen_cb_n_z(optional_bool isCbnz, arm64_register reg, optional_uint64_t optTarget, uint32_t *bytesOut, uint32_t *maskOut); -int arm64_dec_cb_n_z(uint32_t inst, uint64_t origin, bool *isCbnzOut, arm64_register *regOut, uint64_t *targetOut); -#endif \ No newline at end of file diff --git a/Exploits/fastPathSign/src/external/lib/libchoma.a b/Exploits/fastPathSign/src/external/lib/libchoma.a deleted file mode 100644 index 44849e3..0000000 Binary files a/Exploits/fastPathSign/src/external/lib/libchoma.a and /dev/null differ diff --git a/Makefile b/Makefile index e39ebdd..380076d 100644 --- a/Makefile +++ b/Makefile @@ -1,77 +1,87 @@ -TOPTARGETS := all clean +TOPTARGETS := all clean update $(TOPTARGETS): pre_build make_fastPathSign make_roothelper make_trollstore make_trollhelper_embedded make_trollhelper_package assemble_trollstore build_installer15 build_installer64e pre_build: - @rm -rf ./_build 2>/dev/null || true - @mkdir -p ./_build + @rm -rf ./_build 2>/dev/null || true + @mkdir -p ./_build make_fastPathSign: - @$(MAKE) -C ./Exploits/fastPathSign $(MAKECMDGOALS) + @$(MAKE) -C ./Exploits/fastPathSign $(MAKECMDGOALS) make_roothelper: - @$(MAKE) -C ./RootHelper FINALPACKAGE=1 $(MAKECMDGOALS) + @$(MAKE) -C ./RootHelper FINALPACKAGE=1 $(MAKECMDGOALS) make_trollstore: - @$(MAKE) -C ./TrollStore FINALPACKAGE=1 $(MAKECMDGOALS) + @$(MAKE) -C ./TrollStore FINALPACKAGE=1 $(MAKECMDGOALS) ifneq ($(MAKECMDGOALS),clean) make_trollhelper_package: - @$(MAKE) clean -C ./TrollHelper - @cp ./RootHelper/.theos/obj/trollstorehelper ./TrollHelper/Resources/trollstorehelper - @$(MAKE) -C ./TrollHelper FINALPACKAGE=1 package $(MAKECMDGOALS) - @$(MAKE) clean -C ./TrollHelper - @$(MAKE) -C ./TrollHelper THEOS_PACKAGE_SCHEME=rootless FINALPACKAGE=1 package $(MAKECMDGOALS) - @rm ./TrollHelper/Resources/trollstorehelper + @$(MAKE) clean -C ./TrollHelper + @cp ./RootHelper/.theos/obj/trollstorehelper ./TrollHelper/Resources/trollstorehelper + @$(MAKE) -C ./TrollHelper FINALPACKAGE=1 package $(MAKECMDGOALS) + @$(MAKE) clean -C ./TrollHelper + @$(MAKE) -C ./TrollHelper THEOS_PACKAGE_SCHEME=rootless FINALPACKAGE=1 package $(MAKECMDGOALS) + @rm ./TrollHelper/Resources/trollstorehelper make_trollhelper_embedded: - @$(MAKE) clean -C ./TrollHelper - @$(MAKE) -C ./TrollHelper FINALPACKAGE=1 EMBEDDED_ROOT_HELPER=1 $(MAKECMDGOALS) - @cp ./TrollHelper/.theos/obj/TrollStorePersistenceHelper.app/TrollStorePersistenceHelper ./_build/PersistenceHelper_Embedded - @$(MAKE) clean -C ./TrollHelper - @$(MAKE) -C ./TrollHelper FINALPACKAGE=1 EMBEDDED_ROOT_HELPER=1 LEGACY_CT_BUG=1 $(MAKECMDGOALS) - @cp ./TrollHelper/.theos/obj/TrollStorePersistenceHelper.app/TrollStorePersistenceHelper ./_build/PersistenceHelper_Embedded_Legacy_arm64 - @$(MAKE) clean -C ./TrollHelper - @$(MAKE) -C ./TrollHelper FINALPACKAGE=1 EMBEDDED_ROOT_HELPER=1 CUSTOM_ARCHS=arm64e $(MAKECMDGOALS) - @cp ./TrollHelper/.theos/obj/TrollStorePersistenceHelper.app/TrollStorePersistenceHelper ./_build/PersistenceHelper_Embedded_Legacy_arm64e - @$(MAKE) clean -C ./TrollHelper + @$(MAKE) clean -C ./TrollHelper + @$(MAKE) -C ./TrollHelper FINALPACKAGE=1 EMBEDDED_ROOT_HELPER=1 $(MAKECMDGOALS) + @cp ./TrollHelper/.theos/obj/TrollStorePersistenceHelper.app/TrollStorePersistenceHelper ./_build/PersistenceHelper_Embedded + @$(MAKE) clean -C ./TrollHelper + @$(MAKE) -C ./TrollHelper FINALPACKAGE=1 EMBEDDED_ROOT_HELPER=1 LEGACY_CT_BUG=1 $(MAKECMDGOALS) + @cp ./TrollHelper/.theos/obj/TrollStorePersistenceHelper.app/TrollStorePersistenceHelper ./_build/PersistenceHelper_Embedded_Legacy_arm64 + @$(MAKE) clean -C ./TrollHelper + @$(MAKE) -C ./TrollHelper FINALPACKAGE=1 EMBEDDED_ROOT_HELPER=1 CUSTOM_ARCHS=arm64e $(MAKECMDGOALS) + @cp ./TrollHelper/.theos/obj/TrollStorePersistenceHelper.app/TrollStorePersistenceHelper ./_build/PersistenceHelper_Embedded_Legacy_arm64e + @$(MAKE) clean -C ./TrollHelper assemble_trollstore: - @cp ./RootHelper/.theos/obj/trollstorehelper ./TrollStore/.theos/obj/TrollStore.app/trollstorehelper - @cp ./TrollHelper/.theos/obj/TrollStorePersistenceHelper.app/TrollStorePersistenceHelper ./TrollStore/.theos/obj/TrollStore.app/PersistenceHelper - @export COPYFILE_DISABLE=1 - @tar -czvf ./_build/TrollStore.tar -C ./TrollStore/.theos/obj TrollStore.app + @cp ./RootHelper/.theos/obj/trollstorehelper ./TrollStore/.theos/obj/TrollStore.app/trollstorehelper + @cp ./TrollHelper/.theos/obj/TrollStorePersistenceHelper.app/TrollStorePersistenceHelper ./TrollStore/.theos/obj/TrollStore.app/PersistenceHelper + @export COPYFILE_DISABLE=1 + @tar -czvf ./_build/TrollStore.tar -C ./TrollStore/.theos/obj TrollStore.app build_installer15: - @mkdir -p ./_build/tmp15 - @unzip ./Victim/InstallerVictim.ipa -d ./_build/tmp15 - @cp ./_build/PersistenceHelper_Embedded_Legacy_arm64 ./_build/TrollStorePersistenceHelperToInject - @pwnify set-cpusubtype ./_build/TrollStorePersistenceHelperToInject 1 - @ldid -s -K./Victim/victim.p12 ./_build/TrollStorePersistenceHelperToInject - APP_PATH=$$(find ./_build/tmp15/Payload -name "*" -depth 1) ; \ - APP_NAME=$$(basename $$APP_PATH) ; \ - BINARY_NAME=$$(echo "$$APP_NAME" | cut -f 1 -d '.') ; \ - echo $$BINARY_NAME ; \ - pwnify pwn ./_build/tmp15/Payload/$$APP_NAME/$$BINARY_NAME ./_build/TrollStorePersistenceHelperToInject - @pushd ./_build/tmp15 ; \ - zip -vrD ../../_build/TrollHelper_iOS15.ipa * ; \ - popd - @rm ./_build/TrollStorePersistenceHelperToInject - @rm -rf ./_build/tmp15 + @mkdir -p ./_build/tmp15 + @unzip ./Victim/InstallerVictim.ipa -d ./_build/tmp15 + @cp ./_build/PersistenceHelper_Embedded_Legacy_arm64 ./_build/TrollStorePersistenceHelperToInject + @pwnify set-cpusubtype ./_build/TrollStorePersistenceHelperToInject 1 + @ldid -s -K./Victim/victim.p12 ./_build/TrollStorePersistenceHelperToInject + APP_PATH=$$(find ./_build/tmp15/Payload -name "*" -depth 1) ; \ + APP_NAME=$$(basename $$APP_PATH) ; \ + BINARY_NAME=$$(echo "$$APP_NAME" | cut -f 1 -d '.') ; \ + echo $$BINARY_NAME ; \ + pwnify pwn ./_build/tmp15/Payload/$$APP_NAME/$$BINARY_NAME ./_build/TrollStorePersistenceHelperToInject + @pushd ./_build/tmp15 ; \ + zip -vrD ../../_build/TrollHelper_iOS15.ipa * ; \ + popd + @rm ./_build/TrollStorePersistenceHelperToInject + @rm -rf ./_build/tmp15 build_installer64e: - @mkdir -p ./_build/tmp64e - @unzip ./Victim/InstallerVictim.ipa -d ./_build/tmp64e - APP_PATH=$$(find ./_build/tmp64e/Payload -name "*" -depth 1) ; \ - APP_NAME=$$(basename $$APP_PATH) ; \ - BINARY_NAME=$$(echo "$$APP_NAME" | cut -f 1 -d '.') ; \ - echo $$BINARY_NAME ; \ - pwnify pwn64e ./_build/tmp64e/Payload/$$APP_NAME/$$BINARY_NAME ./_build/PersistenceHelper_Embedded_Legacy_arm64e - @pushd ./_build/tmp64e ; \ - zip -vrD ../../_build/TrollHelper_arm64e.ipa * ; \ - popd - @rm -rf ./_build/tmp64e + @mkdir -p ./_build/tmp64e + @unzip ./Victim/InstallerVictim.ipa -d ./_build/tmp64e + APP_PATH=$$(find ./_build/tmp64e/Payload -name "*" -depth 1) ; \ + APP_NAME=$$(basename $$APP_PATH) ; \ + BINARY_NAME=$$(echo "$$APP_NAME" | cut -f 1 -d '.') ; \ + echo $$BINARY_NAME ; \ + pwnify pwn64e ./_build/tmp64e/Payload/$$APP_NAME/$$BINARY_NAME ./_build/PersistenceHelper_Embedded_Legacy_arm64e + @pushd ./_build/tmp64e ; \ + zip -vrD ../../_build/TrollHelper_arm64e.ipa * ; \ + popd + @rm -rf ./_build/tmp64e + endif +update-choma: + rm -rf _build/.choma + mkdir -p _build/.choma + git clone --recursive https://github.com/opa334/ChOma _build/.choma + make -C _build/.choma install TARGET=ios INSTALL_PATH=../../RootHelper/external + make -C _build/.choma clean + make -C _build/.choma install INSTALL_PATH=../../Exploits/fastPathSign/src/external + rm -rf _build/.choma + .PHONY: $(TOPTARGETS) pre_build assemble_trollstore make_trollhelper_package make_trollhelper_embedded build_installer15 build_installer64e \ No newline at end of file diff --git a/RootHelper/.gitignore b/RootHelper/.gitignore index e69de29..1c62076 100644 --- a/RootHelper/.gitignore +++ b/RootHelper/.gitignore @@ -0,0 +1,3 @@ +external/include/choma +external/lib/libchoma.* +external/lib/libcrypto.a \ No newline at end of file diff --git a/RootHelper/external/.keep b/RootHelper/external/.keep new file mode 100644 index 0000000..e69de29 diff --git a/RootHelper/external/include/choma/Base64.h b/RootHelper/external/include/choma/Base64.h deleted file mode 100644 index a09d3ea..0000000 --- a/RootHelper/external/include/choma/Base64.h +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef BASE64_H -#define BASE64_H - -#include -#include - -char *base64_encode(const unsigned char *data, - size_t input_length, - size_t *output_length); - -#endif // BASE64_H \ No newline at end of file diff --git a/RootHelper/external/include/choma/BufferedStream.h b/RootHelper/external/include/choma/BufferedStream.h deleted file mode 100644 index bfad1b2..0000000 --- a/RootHelper/external/include/choma/BufferedStream.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef BUFFERED_STREAM_H -#define BUFFERED_STREAM_H - -#include "MemoryStream.h" -#include - -#define BUFFERED_STREAM_FLAG_AUTO_EXPAND (1 << 0) - -typedef struct BufferedStreamContext { - uint8_t *buffer; - size_t bufferSize; - uint32_t subBufferStart; - size_t subBufferSize; -} BufferedStreamContext; - -MemoryStream *buffered_stream_init_from_buffer_nocopy(void *buffer, size_t bufferSize, uint32_t flags); -MemoryStream *buffered_stream_init_from_buffer(void *buffer, size_t bufferSize, uint32_t flags); - -#endif // BUFFERED_STREAM_H \ No newline at end of file diff --git a/RootHelper/external/include/choma/CSBlob.h b/RootHelper/external/include/choma/CSBlob.h deleted file mode 100644 index 0eee4d1..0000000 --- a/RootHelper/external/include/choma/CSBlob.h +++ /dev/null @@ -1,118 +0,0 @@ -#ifndef CS_BLOB_H -#define CS_BLOB_H - -#include -#include -#include -#include - -#include "FAT.h" -#include "MachO.h" -#include "MemoryStream.h" - -// Blob index -typedef struct __BlobIndex { - uint32_t type; - uint32_t offset; -} CS_BlobIndex; - -// CMS superblob -typedef struct __SuperBlob { - uint32_t magic; - uint32_t length; - uint32_t count; - CS_BlobIndex index[]; -} CS_SuperBlob; - -typedef struct __GenericBlob { - uint32_t magic; /* magic number */ - uint32_t length; /* total length of blob */ - char data[]; -} CS_GenericBlob; - -// CMS blob magic types -typedef enum { - CSMAGIC_REQUIREMENT = 0xfade0c00, - CSMAGIC_REQUIREMENTS = 0xfade0c01, - CSMAGIC_CODEDIRECTORY = 0xfade0c02, - CSMAGIC_EMBEDDED_SIGNATURE = 0xfade0cc0, - CSMAGIC_EMBEDDED_SIGNATURE_OLD = 0xfade0b02, - CSMAGIC_EMBEDDED_ENTITLEMENTS = 0xfade7171, - CSMAGIC_EMBEDDED_DER_ENTITLEMENTS = 0xfade7172, - CSMAGIC_DETACHED_SIGNATURE = 0xfade0cc1, - CSMAGIC_BLOBWRAPPER = 0xfade0b01, - CSMAGIC_EMBEDDED_LAUNCH_CONSTRAINT = 0xfade8181, -} CS_BlobMagic; - -typedef enum { - CSSLOT_CODEDIRECTORY = 0, - CSSLOT_INFOSLOT = 1, - CSSLOT_REQUIREMENTS = 2, - CSSLOT_RESOURCEDIR = 3, - CSSLOT_APPLICATION = 4, - CSSLOT_ENTITLEMENTS = 5, - CSSLOT_DER_ENTITLEMENTS = 7, - CSSLOT_LAUNCH_CONSTRAINT_SELF = 8, - CSSLOT_LAUNCH_CONSTRAINT_PARENT = 9, - CSSLOT_LAUNCH_CONSTRAINT_RESPONSIBLE = 10, - CSSLOT_LIBRARY_CONSTRAINT = 11, - - CSSLOT_ALTERNATE_CODEDIRECTORIES = 0x1000, /* first alternate CodeDirectory, if any */ - CSSLOT_ALTERNATE_CODEDIRECTORY_MAX = 5, /* max number of alternate CD slots */ - CSSLOT_ALTERNATE_CODEDIRECTORY_LIMIT = CSSLOT_ALTERNATE_CODEDIRECTORIES + CSSLOT_ALTERNATE_CODEDIRECTORY_MAX, /* one past the last */ - - CSSLOT_SIGNATURESLOT = 0x10000, - CSSLOT_IDENTIFICATIONSLOT = 0x10001, - CSSLOT_TICKETSLOT = 0x10002, -} CS_SlotType; - -typedef struct s_CS_DecodedBlob { - struct s_CS_DecodedBlob *next; - uint32_t type; - MemoryStream *stream; -} CS_DecodedBlob; - -typedef struct s_CS_DecodedSuperBlob { - uint32_t magic; - struct s_CS_DecodedBlob *firstBlob; -} CS_DecodedSuperBlob; - -// Convert blob magic to readable blob type string -const char *cs_blob_magic_to_string(uint32_t magic); -const char *cs_slot_type_to_string(uint32_t slotType); - -// Extract Code Signature to file -int macho_extract_cs_to_file(MachO *macho, CS_SuperBlob *superblob); - -int macho_find_code_signature_bounds(MachO *macho, uint32_t *offsetOut, uint32_t *sizeOut); - -CS_SuperBlob *macho_read_code_signature(MachO *macho); - -int macho_replace_code_signature(MachO *macho, CS_SuperBlob *superblob); - -CS_DecodedBlob *csd_blob_init(uint32_t type, CS_GenericBlob *blobData); -int csd_blob_read(CS_DecodedBlob *blob, uint64_t offset, size_t size, void *outBuf); -int csd_blob_write(CS_DecodedBlob *blob, uint64_t offset, size_t size, const void *inBuf); -int csd_blob_insert(CS_DecodedBlob *blob, uint64_t offset, size_t size, const void *inBuf); -int csd_blob_delete(CS_DecodedBlob *blob, uint64_t offset, size_t size); -int csd_blob_read_string(CS_DecodedBlob *blob, uint64_t offset, char **outString); -int csd_blob_write_string(CS_DecodedBlob *blob, uint64_t offset, const char *string); -int csd_blob_get_size(CS_DecodedBlob *blob); -uint32_t csd_blob_get_type(CS_DecodedBlob *blob); -void csd_blob_set_type(CS_DecodedBlob *blob, uint32_t type); -void csd_blob_free(CS_DecodedBlob *blob); - -CS_DecodedSuperBlob *csd_superblob_init(void); -CS_DecodedSuperBlob *csd_superblob_decode(CS_SuperBlob *superblob); -CS_SuperBlob *csd_superblob_encode(CS_DecodedSuperBlob *decodedSuperblob); -CS_DecodedBlob *csd_superblob_find_blob(CS_DecodedSuperBlob *superblob, uint32_t type, uint32_t *indexOut); -int csd_superblob_insert_blob_after_blob(CS_DecodedSuperBlob *superblob, CS_DecodedBlob *blobToInsert, CS_DecodedBlob *afterBlob); -int csd_superblob_insert_blob_at_index(CS_DecodedSuperBlob *superblob, CS_DecodedBlob *blobToInsert, uint32_t atIndex); -int csd_superblob_append_blob(CS_DecodedSuperBlob *superblob, CS_DecodedBlob *blobToAppend); -int csd_superblob_remove_blob(CS_DecodedSuperBlob *superblob, CS_DecodedBlob *blobToRemove); // <- Important: When calling this, caller is responsible for freeing blobToRemove -int csd_superblob_remove_blob_at_index(CS_DecodedSuperBlob *superblob, uint32_t atIndex); -int csd_superblob_print_content(CS_DecodedSuperBlob *decodedSuperblob, MachO *macho, bool printAllSlots, bool verifySlots); -void csd_superblob_free(CS_DecodedSuperBlob *decodedSuperblob); - - -#endif // CS_BLOB_H \ No newline at end of file diff --git a/RootHelper/external/include/choma/CodeDirectory.h b/RootHelper/external/include/choma/CodeDirectory.h deleted file mode 100644 index 36cca20..0000000 --- a/RootHelper/external/include/choma/CodeDirectory.h +++ /dev/null @@ -1,55 +0,0 @@ -#ifndef CODE_DIRECTORY_H -#define CODE_DIRECTORY_H - -#include -#include -#include - -#include "MachO.h" -#include "CSBlob.h" -#include "FAT.h" -#include "MachOByteOrder.h" -#include "MachOLoadCommand.h" -#include "MemoryStream.h" - -// Code directory blob header -typedef struct __CodeDirectory { - uint32_t magic; - uint32_t length; - uint32_t version; - uint32_t flags; - uint32_t hashOffset; - uint32_t identOffset; - uint32_t nSpecialSlots; - uint32_t nCodeSlots; - uint32_t codeLimit; - uint8_t hashSize; - uint8_t hashType; - uint8_t platform; - uint8_t pageSize; - uint32_t spare2; - - /* Version 0x20100 */ - uint32_t scatterOffset; - uint32_t teamOffset; -} CS_CodeDirectory -__attribute__ ((aligned(1))); - -enum CS_HashType { - CS_HASHTYPE_SHA160_160 = 1, - CS_HASHTYPE_SHA256_256 = 2, - CS_HASHTYPE_SHA256_160 = 3, - CS_HASHTYPE_SHA384_384 = 4, -}; - -char *csd_code_directory_copy_identifier(CS_DecodedBlob *codeDirBlob, uint32_t *offsetOut); -char *csd_code_directory_copy_team_id(CS_DecodedBlob *codeDirBlob, uint32_t *offsetOut); -int csd_code_directory_set_team_id(CS_DecodedBlob *codeDirBlob, char *newTeamID); -uint32_t csd_code_directory_get_flags(CS_DecodedBlob *codeDirBlob); -void csd_code_directory_set_flags(CS_DecodedBlob *codeDirBlob, uint32_t flags); -uint8_t csd_code_directory_get_hash_type(CS_DecodedBlob *codeDirBlob); -void csd_code_directory_set_hash_type(CS_DecodedBlob *codeDirBlob, uint8_t hashType); -int csd_code_directory_print_content(CS_DecodedBlob *codeDirBlob, MachO *macho, bool printSlots, bool verifySlots); -void csd_code_directory_update(CS_DecodedBlob *codeDirBlob, MachO *macho); - -#endif // CODE_DIRECTORY_H \ No newline at end of file diff --git a/RootHelper/external/include/choma/FAT.h b/RootHelper/external/include/choma/FAT.h deleted file mode 100644 index 102133b..0000000 --- a/RootHelper/external/include/choma/FAT.h +++ /dev/null @@ -1,46 +0,0 @@ -#ifndef MACHO_H -#define MACHO_H - -#include -#include -#include -#include -#include -#include - -#include "MemoryStream.h" -typedef struct MachO MachO; - -// A FAT structure can either represent a FAT file with multiple slices, in which the slices will be loaded into the slices attribute -// Or a single slice MachO, in which case it serves as a compatibility layer and the single slice will also be loaded into the slices attribute -typedef struct FAT -{ - MemoryStream *stream; - MachO **slices; - uint32_t slicesCount; - int fileDescriptor; -} FAT; - -int fat_read_at_offset(FAT *fat, uint64_t offset, size_t size, void *outBuf); - -MemoryStream *fat_get_stream(FAT *fat); - -// Initialise a FAT structure from a memory stream -FAT *fat_init_from_memory_stream(MemoryStream *stream); - -// Initialise a FAT structure using the path to the file -FAT *fat_init_from_path(const char *filePath); - -// Find macho with cputype and cpusubtype in FAT, returns NULL if not found -MachO *fat_find_slice(FAT *fat, cpu_type_t cputype, cpu_subtype_t cpusubtype); - -// Create a FAT structure from an array of MachO structures -FAT *fat_create_for_macho_array(char *firstInputPath, MachO **machoArray, int machoArrayCount); - -// Add a MachO to the FAT structure -int fat_add_macho(FAT *fat, MachO *macho); - -// Free all elements of the FAT structure -void fat_free(FAT *fat); - -#endif // MACHO_H \ No newline at end of file diff --git a/RootHelper/external/include/choma/FileStream.h b/RootHelper/external/include/choma/FileStream.h deleted file mode 100644 index 3cab1ea..0000000 --- a/RootHelper/external/include/choma/FileStream.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef FILE_STREAM_H -#define FILE_STREAM_H - -#include "MemoryStream.h" - -#define FILE_STREAM_SIZE_AUTO 0 -#define FILE_STREAM_FLAG_WRITABLE (1 << 0) -#define FILE_STREAM_FLAG_AUTO_EXPAND (1 << 1) - -typedef struct FileStreamContext { - int fd; - size_t fileSize; - uint32_t bufferStart; - size_t bufferSize; -} FileStreamContext; - -MemoryStream *file_stream_init_from_file_descriptor_nodup(int fd, uint32_t bufferStart, size_t bufferSize, uint32_t flags); -MemoryStream *file_stream_init_from_file_descriptor(int fd, uint32_t bufferStart, size_t bufferSize, uint32_t flags); -MemoryStream *file_stream_init_from_path(const char *path, uint32_t bufferStart, size_t bufferSize, uint32_t flags); - -#endif // FILE_STREAM_H \ No newline at end of file diff --git a/RootHelper/external/include/choma/Host.h b/RootHelper/external/include/choma/Host.h deleted file mode 100644 index 56051c0..0000000 --- a/RootHelper/external/include/choma/Host.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef HOST_H -#define HOST_H - -#include "FAT.h" - -// Retrieve the preferred MachO slice from a FAT -// Preferred slice as in the slice that the kernel would use when loading the file -MachO *fat_find_preferred_slice(FAT *fat); - -#endif // HOST_H \ No newline at end of file diff --git a/RootHelper/external/include/choma/MachO.h b/RootHelper/external/include/choma/MachO.h deleted file mode 100644 index 1b933ba..0000000 --- a/RootHelper/external/include/choma/MachO.h +++ /dev/null @@ -1,68 +0,0 @@ -#ifndef MACHO_SLICE_H -#define MACHO_SLICE_H - -#include -#include -#include -#include "MemoryStream.h" -#include "FAT.h" - -typedef struct MachOSegment -{ - struct segment_command_64 command; - struct section_64 sections[]; -} __attribute__((__packed__)) MachOSegment; - -typedef struct FilesetMachO { - char *entry_id; - uint64_t vmaddr; - uint64_t fileoff; - FAT *underlyingMachO; -} FilesetMachO; - -typedef struct MachO { - MemoryStream *stream; - bool isSupported; - struct mach_header_64 machHeader; - struct fat_arch_64 archDescriptor; - - uint32_t filesetCount; - FilesetMachO *filesetMachos; - - uint32_t segmentCount; - MachOSegment **segments; -} MachO; - -// Read data from a MachO at a specified offset -int macho_read_at_offset(MachO *macho, uint64_t offset, size_t size, void *outBuf); - -// Write data from a MachO at a specified offset, auto expands, only works if opened via macho_init_for_writing -int macho_write_at_offset(MachO *macho, uint64_t offset, size_t size, void *inBuf); - -MemoryStream *macho_get_stream(MachO *macho); -uint32_t macho_get_filetype(MachO *macho); - -// Perform translation between file offsets and virtual addresses -int macho_translate_fileoff_to_vmaddr(MachO *macho, uint64_t fileoff, uint64_t *vmaddrOut, MachOSegment **segmentOut); -int macho_translate_vmaddr_to_fileoff(MachO *macho, uint64_t vmaddr, uint64_t *fileoffOut, MachOSegment **segmentOut); - -// Read data from a MachO at a specified virtual address -int macho_read_at_vmaddr(MachO *macho, uint64_t vmaddr, size_t size, void *outBuf); - -int macho_enumerate_load_commands(MachO *macho, void (^enumeratorBlock)(struct load_command loadCommand, uint64_t offset, void *cmd, bool *stop)); - -// Initialise a MachO object from a MemoryStream and it's corresponding FAT arch descriptor -MachO *macho_init(MemoryStream *stream, struct fat_arch_64 archDescriptor); - -// Initialize a single slice macho for writing to it -MachO *macho_init_for_writing(const char *filePath); - -// Create an array of MachO objects from an array of paths -MachO **macho_array_create_for_paths(char **inputPaths, int inputPathsCount); - -// Check if a MachO is encrypted -bool macho_is_encrypted(MachO *macho); - -void macho_free(MachO *macho); - -#endif // MACHO_SLICE_H \ No newline at end of file diff --git a/RootHelper/external/include/choma/MachOByteOrder.h b/RootHelper/external/include/choma/MachOByteOrder.h deleted file mode 100644 index 510df98..0000000 --- a/RootHelper/external/include/choma/MachOByteOrder.h +++ /dev/null @@ -1,171 +0,0 @@ -#ifndef MACHO_BYTE_ORDER_H -#define MACHO_BYTE_ORDER_H - -#include -#include - -// 8-bit integers needed for CodeDirectory -#define BIG_TO_HOST(n) _Generic((n), \ - int8_t: n, \ - uint8_t: n, \ - int16_t: OSSwapBigToHostInt16(n), \ - uint16_t: OSSwapBigToHostInt16(n), \ - int32_t: OSSwapBigToHostInt32(n), \ - uint32_t: OSSwapBigToHostInt32(n), \ - int64_t: OSSwapBigToHostInt64(n), \ - uint64_t: OSSwapBigToHostInt64(n) \ -) - -#define HOST_TO_BIG(n) _Generic((n), \ - int8_t: n, \ - uint8_t: n, \ - uint16_t: OSSwapHostToBigInt16(n), \ - int16_t: OSSwapHostToBigInt16(n), \ - int32_t: OSSwapHostToBigInt32(n), \ - uint32_t: OSSwapHostToBigInt32(n), \ - int64_t: OSSwapHostToBigInt64(n), \ - uint64_t: OSSwapHostToBigInt64(n) \ -) - -#define LITTLE_TO_HOST(n) _Generic((n), \ - int8_t: n, \ - uint8_t: n, \ - int16_t: OSSwapLittleToHostInt16(n), \ - uint16_t: OSSwapLittleToHostInt16(n), \ - int32_t: OSSwapLittleToHostInt32(n), \ - uint32_t: OSSwapLittleToHostInt32(n), \ - int64_t: OSSwapLittleToHostInt64(n), \ - uint64_t: OSSwapLittleToHostInt64(n) \ -) - -#define HOST_TO_LITTLE(n) _Generic((n), \ - int8_t: n, \ - uint8_t: n, \ - int16_t: OSSwapHostToLittleInt16(n), \ - uint16_t: OSSwapHostToLittleInt16(n), \ - int32_t: OSSwapHostToLittleInt32(n), \ - uint32_t: OSSwapHostToLittleInt32(n), \ - int64_t: OSSwapHostToLittleInt64(n), \ - uint64_t: OSSwapHostToLittleInt64(n) \ -) - -#define HOST_TO_LITTLE_APPLIER(instance, member) \ - (instance)->member = HOST_TO_LITTLE((instance)->member) - -#define HOST_TO_BIG_APPLIER(instance, member) \ - (instance)->member = HOST_TO_BIG((instance)->member) - -#define LITTLE_TO_HOST_APPLIER(instance, member) \ - (instance)->member = LITTLE_TO_HOST((instance)->member) - -#define BIG_TO_HOST_APPLIER(instance, member) \ - (instance)->member = BIG_TO_HOST((instance)->member) - -#define FAT_HEADER_APPLY_BYTE_ORDER(fh, applier) \ - applier(fh, magic); \ - applier(fh, nfat_arch); - -#define FAT_ARCH_APPLY_BYTE_ORDER(arch, applier) \ - applier(arch, cputype); \ - applier(arch, cpusubtype); \ - applier(arch, offset); \ - applier(arch, size); \ - applier(arch, align); \ - -#define FAT_ARCH_64_APPLY_BYTE_ORDER(arch, applier) \ - applier(arch, cputype); \ - applier(arch, cpusubtype); \ - applier(arch, offset); \ - applier(arch, size); \ - applier(arch, align); \ - applier(arch, reserved); \ - -#define MACH_HEADER_APPLY_BYTE_ORDER(mh, applier) \ - applier(mh, magic); \ - applier(mh, cputype); \ - applier(mh, cpusubtype); \ - applier(mh, filetype); \ - applier(mh, ncmds); \ - applier(mh, sizeofcmds); \ - applier(mh, reserved); - -#define LOAD_COMMAND_APPLY_BYTE_ORDER(lc, applier) \ - applier(lc, cmd); \ - applier(lc, cmdsize); - -#define LINKEDIT_DATA_COMMAND_APPLY_BYTE_ORDER(lc, applier) \ - applier(lc, cmd); \ - applier(lc, cmdsize); \ - applier(lc, dataoff); \ - applier(lc, datasize); - -#define ENCRYPTION_INFO_COMMAND_APPLY_BYTE_ORDER(eic, applier) \ - applier(eic, cmd); \ - applier(eic, cmdsize); \ - applier(eic, cryptoff); \ - applier(eic, cryptsize); \ - applier(eic, cryptid); - -#define BLOB_INDEX_APPLY_BYTE_ORDER(bi, applier) \ - applier(bi, type); \ - applier(bi, offset); - -#define SUPERBLOB_APPLY_BYTE_ORDER(sb, applier) \ - applier(sb, magic); \ - applier(sb, length); \ - applier(sb, count); - -#define GENERIC_BLOB_APPLY_BYTE_ORDER(gb, applier) \ - applier(gb, magic); \ - applier(gb, length); - -#define CODE_DIRECTORY_APPLY_BYTE_ORDER(cd, applier) \ - applier(cd, magic); \ - applier(cd, length); \ - applier(cd, version); \ - applier(cd, flags); \ - applier(cd, hashOffset); \ - applier(cd, identOffset); \ - applier(cd, nSpecialSlots); \ - applier(cd, nCodeSlots); \ - applier(cd, codeLimit); \ - applier(cd, hashSize); \ - applier(cd, hashType); \ - applier(cd, platform); \ - applier(cd, pageSize); \ - applier(cd, spare2); \ - applier(cd, scatterOffset); \ - applier(cd, teamOffset); - -#define SEGMENT_COMMAND_64_APPLY_BYTE_ORDER(sc64, applier) \ - applier(sc64, cmd); \ - applier(sc64, cmdsize); \ - applier(sc64, fileoff); \ - applier(sc64, filesize); \ - applier(sc64, vmaddr); \ - applier(sc64, vmsize); \ - applier(sc64, flags); \ - applier(sc64, initprot); \ - applier(sc64, maxprot); \ - applier(sc64, nsects); - -#define SECTION_64_APPLY_BYTE_ORDER(sc64, applier) \ - applier(sc64, addr); \ - applier(sc64, align); \ - applier(sc64, flags); \ - applier(sc64, nreloc); \ - applier(sc64, offset); \ - applier(sc64, reserved1); \ - applier(sc64, reserved2); \ - applier(sc64, reserved3); \ - applier(sc64, size); - -#define FILESET_ENTRY_COMMAND_APPLY_BYTE_ORDER(fse, applier) \ - applier(fse, cmd); \ - applier(fse, cmdsize); \ - applier(fse, vmaddr); \ - applier(fse, fileoff); \ - applier(fse, entry_id.offset); \ - applier(fse, reserved); \ - -#endif // MACHO_BYTE_ORDER_H \ No newline at end of file diff --git a/RootHelper/external/include/choma/MachOLoadCommand.h b/RootHelper/external/include/choma/MachOLoadCommand.h deleted file mode 100644 index ae5514a..0000000 --- a/RootHelper/external/include/choma/MachOLoadCommand.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef MACHO_LOAD_COMMAND_H -#define MACHO_LOAD_COMMAND_H - -#include -#include "MachO.h" -#include "FileStream.h" -#include "MachOByteOrder.h" -#include "CSBlob.h" - -// Convert load command to load command name -char *load_command_to_string(int loadCommand); -void update_segment_command_64(MachO *macho, const char *segmentName, uint64_t vmaddr, uint64_t vmsize, uint64_t fileoff, uint64_t filesize); -void update_lc_code_signature(MachO *macho, uint64_t size); -int update_load_commands_for_coretrust_bypass(MachO *macho, CS_SuperBlob *superblob, uint64_t originalCodeSignatureSize, uint64_t originalMachOSize); - -#endif // MACHO_LOAD_COMMAND_H \ No newline at end of file diff --git a/RootHelper/external/include/choma/MemoryStream.h b/RootHelper/external/include/choma/MemoryStream.h deleted file mode 100644 index ba00102..0000000 --- a/RootHelper/external/include/choma/MemoryStream.h +++ /dev/null @@ -1,60 +0,0 @@ -#ifndef MEMORY_STREAM_H -#define MEMORY_STREAM_H - -#include -#include -#include -#include -#include -#include -#include - -#define MEMORY_STREAM_FLAG_OWNS_DATA (1 << 0) -#define MEMORY_STREAM_FLAG_MUTABLE (1 << 1) -#define MEMORY_STREAM_FLAG_AUTO_EXPAND (1 << 2) - -#define MEMORY_STREAM_SIZE_INVALID (size_t)-1 - -// A generic memory IO interface that is used throughout this project -// Can be backed by anything, just the functions have to be implemented -typedef struct s_MemoryStream { - void *context; - uint32_t flags; - - int (*read)(struct s_MemoryStream *stream, uint64_t offset, size_t size, void *outBuf); - int (*write)(struct s_MemoryStream *stream, uint64_t offset, size_t size, const void *inBuf); - int (*getSize)(struct s_MemoryStream *stream, size_t *sizeOut); - uint8_t *(*getRawPtr)(struct s_MemoryStream *stream); - - int (*trim)(struct s_MemoryStream *stream, size_t trimAtStart, size_t trimAtEnd); - int (*expand)(struct s_MemoryStream *stream, size_t expandAtStart, size_t expandAtEnd); - - struct s_MemoryStream *(*hardclone)(struct s_MemoryStream *stream); - struct s_MemoryStream *(*softclone)(struct s_MemoryStream *stream); - void (*free)(struct s_MemoryStream *stream); -} MemoryStream; - -int memory_stream_read(MemoryStream *stream, uint64_t offset, size_t size, void *outBuf); -int memory_stream_write(MemoryStream *stream, uint64_t offset, size_t size, const void *inBuf); - -int memory_stream_insert(MemoryStream *stream, uint64_t offset, size_t size, const void *inBuf); -int memory_stream_delete(MemoryStream *stream, uint64_t offset, size_t size); - -int memory_stream_read_string(MemoryStream *stream, uint64_t offset, char **outString); -int memory_stream_write_string(MemoryStream *stream, uint64_t offset, const char *string); - -size_t memory_stream_get_size(MemoryStream *stream); -uint8_t *memory_stream_get_raw_pointer(MemoryStream *stream); -uint32_t memory_stream_get_flags(MemoryStream *stream); - -MemoryStream *memory_stream_softclone(MemoryStream *stream); -MemoryStream *memory_stream_hardclone(MemoryStream *stream); -int memory_stream_trim(MemoryStream *stream, size_t trimAtStart, size_t trimAtEnd); -int memory_stream_expand(MemoryStream *stream, size_t expandAtStart, size_t expandAtEnd); - -void memory_stream_free(MemoryStream *stream); - -int memory_stream_copy_data(MemoryStream *originStream, uint64_t originOffset, MemoryStream *targetStream, uint64_t targetOffset, size_t size); -int memory_stream_find_memory(MemoryStream *stream, uint64_t searchStartOffset, uint64_t searchEndOffset, void *bytes, void *mask, size_t nbytes, uint16_t alignment, uint64_t *foundOffsetOut); - -#endif // MEMORY_STREAM_H \ No newline at end of file diff --git a/RootHelper/external/include/choma/PatchFinder.h b/RootHelper/external/include/choma/PatchFinder.h deleted file mode 100644 index 84cc117..0000000 --- a/RootHelper/external/include/choma/PatchFinder.h +++ /dev/null @@ -1,75 +0,0 @@ -#ifndef PATCHFINDER_H -#define PATCHFINDER_H - -#include -#include "MachO.h" - -enum { - PF_METRIC_TYPE_PATTERN, - PF_METRIC_TYPE_STRING, - PF_METRIC_TYPE_XREF, -}; - -typedef struct s_PFSection { - MachO *macho; - uint64_t fileoff; - uint64_t vmaddr; - uint64_t size; - uint8_t *cache; - bool ownsCache; -} PFSection; - -PFSection *pfsec_init_from_macho(MachO *macho, const char *filesetEntryId, const char *segName, const char *sectName); -int pfsec_read_reloff(PFSection *section, uint64_t rel, size_t size, void *outBuf); -uint32_t pfsec_read32_reloff(PFSection *section, uint64_t rel); -int pfsec_read_at_address(PFSection *section, uint64_t vmaddr, void *outBuf, size_t size); -uint32_t pfsec_read32(PFSection *section, uint64_t vmaddr); -uint64_t pfsec_read64(PFSection *section, uint64_t vmaddr); -int pfsec_read_string(PFSection *section, uint64_t vmaddr, char **outString); -int pfsec_set_cached(PFSection *section, bool cached); -uint64_t pfsec_find_prev_inst(PFSection *section, uint64_t startAddr, uint32_t searchCount, uint32_t inst, uint32_t mask); -uint64_t pfsec_find_next_inst(PFSection *section, uint64_t startAddr, uint32_t searchCount, uint32_t inst, uint32_t mask); -uint64_t pfsec_find_function_start(PFSection *section, uint64_t midAddr); -void pfsec_free(PFSection *section); - - -typedef struct s_MetricShared { - uint32_t type; -} MetricShared; - -typedef struct s_PFPatternMetric { - MetricShared shared; - - void *bytes; - void *mask; - size_t nbytes; - uint16_t alignment; -} PFPatternMetric; - -typedef struct s_PFStringMetric { - MetricShared shared; - - char *string; -} PFStringMetric; - -typedef enum { - XREF_TYPE_MASK_CALL = (1 << 0), - XREF_TYPE_MASK_REFERENCE = (1 << 1), - XREF_TYPE_MASK_ALL = (XREF_TYPE_MASK_CALL | XREF_TYPE_MASK_REFERENCE), -} PFXrefTypeMask; - -typedef struct s_PFXrefMetric { - MetricShared shared; - - uint64_t address; - PFXrefTypeMask typeMask; -} PFXrefMetric; - -PFPatternMetric *pfmetric_pattern_init(void *bytes, void *mask, size_t nbytes, uint16_t alignment); -PFStringMetric *pfmetric_string_init(const char *string); -PFXrefMetric *pfmetric_xref_init(uint64_t address, PFXrefTypeMask types); -void pfmetric_free(void *metric); - -void pfmetric_run_in_range(PFSection *section, uint64_t startAddr, uint64_t endAddr, void *metric, void (^matchBlock)(uint64_t vmaddr, bool *stop)); -void pfmetric_run(PFSection *section, void *metric, void (^matchBlock)(uint64_t vmaddr, bool *stop)); -#endif \ No newline at end of file diff --git a/RootHelper/external/include/choma/PatchFinder_arm64.h b/RootHelper/external/include/choma/PatchFinder_arm64.h deleted file mode 100644 index c487bd6..0000000 --- a/RootHelper/external/include/choma/PatchFinder_arm64.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef PATCHFINDER_ARM64_H -#define PATCHFINDER_ARM64_H - -#include "PatchFinder.h" - -typedef enum { - ARM64_XREF_TYPE_B = 0, - ARM64_XREF_TYPE_BL = 1, - ARM64_XREF_TYPE_ADR = 2, - ARM64_XREF_TYPE_ADRP_ADD = 3, - ARM64_XREF_TYPE_ADRP_LDR = 4, - ARM64_XREF_TYPE_ADRP_STR = 5, -} Arm64XrefType; - -typedef enum { - ARM64_XREF_TYPE_MASK_B = (1 << ARM64_XREF_TYPE_B), - ARM64_XREF_TYPE_MASK_BL = (1 << ARM64_XREF_TYPE_BL), - ARM64_XREF_TYPE_MASK_CALL = (ARM64_XREF_TYPE_MASK_B | ARM64_XREF_TYPE_MASK_BL), - - ARM64_XREF_TYPE_MASK_ADR = (1 << ARM64_XREF_TYPE_ADR), - ARM64_XREF_TYPE_MASK_ADRP_ADD = (1 << ARM64_XREF_TYPE_ADRP_ADD), - ARM64_XREF_TYPE_MASK_ADRP_LDR = (1 << ARM64_XREF_TYPE_ADRP_LDR), - ARM64_XREF_TYPE_MASK_ADRP_STR = (1 << ARM64_XREF_TYPE_ADRP_STR), - ARM64_XREF_TYPE_MASK_REFERENCE = (ARM64_XREF_TYPE_MASK_ADR | ARM64_XREF_TYPE_MASK_ADRP_ADD | ARM64_XREF_TYPE_MASK_ADRP_LDR | ARM64_XREF_TYPE_MASK_ADRP_STR), - - ARM64_XREF_TYPE_ALL = (ARM64_XREF_TYPE_MASK_CALL | ARM64_XREF_TYPE_MASK_REFERENCE), -} Arm64XrefTypeMask; - -uint64_t pfsec_arm64_resolve_adrp_ldr_str_add_reference(PFSection *section, uint64_t adrpAddr, uint64_t ldrStrAddAddr); -uint64_t pfsec_arm64_resolve_adrp_ldr_str_add_reference_auto(PFSection *section, uint64_t ldrStrAddAddr); -uint64_t pfsec_arm64_resolve_stub(PFSection *section, uint64_t stubAddr); -void pfsec_arm64_enumerate_xrefs(PFSection *section, Arm64XrefTypeMask types, void (^xrefBlock)(Arm64XrefType type, uint64_t source, uint64_t target, bool *stop)); -#endif \ No newline at end of file diff --git a/RootHelper/external/include/choma/SignOSSL.h b/RootHelper/external/include/choma/SignOSSL.h deleted file mode 100644 index f1be620..0000000 --- a/RootHelper/external/include/choma/SignOSSL.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef SIGN_OSSL_H -#define SIGN_OSSL_H - -#ifndef DISABLE_SIGNING - -#include -#include -#include -#include -#include -#include -#include - -unsigned char *signWithRSA(unsigned char *inputData, size_t inputDataLength, unsigned char *key, size_t key_len, size_t *outputDataLength); - -#endif - -#endif // SIGN_OSSL_H - -// 0xA422 \ No newline at end of file diff --git a/RootHelper/external/include/choma/Util.h b/RootHelper/external/include/choma/Util.h deleted file mode 100644 index e4ccf64..0000000 --- a/RootHelper/external/include/choma/Util.h +++ /dev/null @@ -1,34 +0,0 @@ -#ifndef UTIL_H -#define UTIL_H - -#include -#include -#include - -typedef struct s_optional_uint64 { - bool isSet; - uint64_t value; -} optional_uint64_t; -#define OPT_UINT64_IS_SET(x) (x.isSet) -#define OPT_UINT64_GET_VAL(x) (x.value) -#define OPT_UINT64_NONE (optional_uint64_t){.isSet = false, .value = 0} -#define OPT_UINT64(x) (optional_uint64_t){.isSet = true, .value = x} - - -typedef struct s_optional_bool { - bool isSet; - bool value; -} optional_bool; -#define OPT_BOOL_IS_SET(x) (x.isSet) -#define OPT_BOOL_GET_VAL(x) (x.value) -#define OPT_BOOL_NONE (optional_bool){.isSet = false, .value = false} -#define OPT_BOOL(x) (optional_bool){.isSet = true, .value = x} - -int64_t sxt64(int64_t value, uint8_t bits); -int memcmp_masked(const void *str1, const void *str2, unsigned char* mask, size_t n); -uint64_t align_to_size(int size, int alignment); -int count_digits(int64_t num); -void print_hash(uint8_t *hash, size_t size); -void enumerate_range(uint64_t start, uint64_t end, uint16_t alignment, size_t nbytes, bool (^enumerator)(uint64_t cur)); - -#endif \ No newline at end of file diff --git a/RootHelper/external/include/choma/arm64.h b/RootHelper/external/include/choma/arm64.h deleted file mode 100644 index 9affc1d..0000000 --- a/RootHelper/external/include/choma/arm64.h +++ /dev/null @@ -1,94 +0,0 @@ -#ifndef ARM64_H -#define ARM64_H - -#include "Util.h" - -typedef enum { - // registers - ARM64_REG_TYPE_X, - ARM64_REG_TYPE_W, - - // vector shit - ARM64_REG_TYPE_Q, - ARM64_REG_TYPE_D, - ARM64_REG_TYPE_S, - ARM64_REG_TYPE_H, - ARM64_REG_TYPE_B, -} arm64_register_type; - -enum { - ARM64_REG_MASK_ANY_FLAG = (1 << 0), - ARM64_REG_MASK_X_W = (1 << 1), - ARM64_REG_MASK_VECTOR = (1 << 2), - ARM64_REG_MASK_ALL = (ARM64_REG_MASK_X_W | ARM64_REG_MASK_VECTOR), - - ARM64_REG_MASK_ANY_X_W = (ARM64_REG_MASK_X_W | ARM64_REG_MASK_ANY_FLAG), - ARM64_REG_MASK_ANY_VECTOR = (ARM64_REG_MASK_VECTOR | ARM64_REG_MASK_ANY_FLAG), - ARM64_REG_MASK_ANY_ALL = (ARM64_REG_MASK_ALL | ARM64_REG_MASK_ANY_FLAG), -}; - -typedef enum { - LDR_STR_TYPE_ANY, // NOTE: "ANY" will inevitably also match STUR and LDUR instructions - LDR_STR_TYPE_POST_INDEX, - LDR_STR_TYPE_PRE_INDEX, - LDR_STR_TYPE_UNSIGNED, -} arm64_ldr_str_type; - -typedef struct s_arm64_register { - uint8_t mask; - arm64_register_type type; - uint8_t num; -} arm64_register; - -#define ARM64_REG(type_, num_) (arm64_register){.mask = ARM64_REG_MASK_ALL, .type = type_, .num = num_} -#define ARM64_REG_X(x) ARM64_REG(ARM64_REG_TYPE_X, x) -#define ARM64_REG_W(x) ARM64_REG(ARM64_REG_TYPE_W, x) -#define ARM64_REG_Q(x) ARM64_REG(ARM64_REG_TYPE_Q, x) -#define ARM64_REG_S(x) ARM64_REG(ARM64_REG_TYPE_S, x) -#define ARM64_REG_H(x) ARM64_REG(ARM64_REG_TYPE_H, x) -#define ARM64_REG_B(x) ARM64_REG(ARM64_REG_TYPE_B, x) -#define ARM64_REG_ANY (arm64_register){.mask = ARM64_REG_MASK_ANY_ALL, .type = 0, .num = 0} -#define ARM64_REG_ANY_X_W (arm64_register){.mask = ARM64_REG_MASK_ANY_X_W, .type = 0, .num = 0} -#define ARM64_REG_ANY_VECTOR (arm64_register){.mask = ARM64_REG_MASK_ANY_VECTOR, .type = 0, .num = 0} -#define ARM64_REG_GET_TYPE(x) (x.type) -#define ARM64_REG_IS_X(x) (x.type == ARM64_REG_TYPE_X) -#define ARM64_REG_IS_W(x) (x.type == ARM64_REG_TYPE_W) -#define ARM64_REG_IS_VECTOR(x) (x.type == ARM64_REG_TYPE_Q || x.type == ARM64_REG_TYPE_D || x.type == ARM64_REG_TYPE_S || x.type == ARM64_REG_TYPE_H || x.type == ARM64_REG_TYPE_B) -#define ARM64_REG_GET_NUM(x) (x.num & 0x1f) -#define ARM64_REG_IS_ANY(x) (x.mask == ARM64_REG_MASK_ANY_ALL) -#define ARM64_REG_IS_ANY_X_W(x) (x.mask == ARM64_REG_MASK_ANY_X_W) -#define ARM64_REG_IS_ANY_VECTOR(x) (x.mask == ARM64_REG_MASK_ANY_VECTOR) -uint8_t arm64_reg_type_get_width(arm64_register_type type); -const char *arm64_reg_type_get_string(arm64_register_type type); -const char *arm64_reg_get_type_string(arm64_register reg); - -#define ARM64_REG_NUM_SP 31 - -typedef struct s_arm64_cond { - bool isSet; - uint8_t value; -} arm64_cond; -#define ARM64_COND(x) (arm64_cond){.isSet = true, .value = x} -#define ARM64_COND_ANY (arm64_cond){.isSet = false, .value = 0} -#define ARM64_COND_GET_VAL(x) (x.value & 0xf) -#define ARM64_COND_IS_SET(x) x.isSet - -int arm64_gen_b_l(optional_bool optIsBl, optional_uint64_t optOrigin, optional_uint64_t optTarget, uint32_t *bytesOut, uint32_t *maskOut); -int arm64_dec_b_l(uint32_t inst, uint64_t origin, uint64_t *targetOut, bool *isBlOut); -int arm64_gen_b_c_cond(optional_bool optIsBc, optional_uint64_t optOrigin, optional_uint64_t optTarget, arm64_cond optCond, uint32_t *bytesOut, uint32_t *maskOut); -int arm64_dec_b_c_cond(uint32_t inst, uint64_t origin, uint64_t *targetOut, arm64_cond *condOut, bool *isBcOut); -int arm64_gen_adr_p(optional_bool optIsAdrp, optional_uint64_t optOrigin, optional_uint64_t optTarget, arm64_register reg, uint32_t *bytesOut, uint32_t *maskOut); -int arm64_dec_adr_p(uint32_t inst, uint64_t origin, uint64_t *targetOut, arm64_register *registerOut, bool *isAdrpOut); -int arm64_gen_mov_imm(char type, arm64_register destinationReg, optional_uint64_t optImm, optional_uint64_t optShift, uint32_t *bytesOut, uint32_t *maskOut); -int arm64_dec_mov_imm(uint32_t inst, arm64_register *destinationRegOut, uint64_t *immOut, uint64_t *shiftOut, char *typeOut); -int arm64_gen_add_imm(arm64_register destinationReg, arm64_register sourceReg, optional_uint64_t optImm, uint32_t *bytesOut, uint32_t *maskOut); -int arm64_dec_add_imm(uint32_t inst, arm64_register *destinationRegOut, arm64_register *sourceRegOut, uint16_t *immOut); -int arm64_gen_ldr_imm(char type, arm64_ldr_str_type instType, arm64_register destinationReg, arm64_register addrReg, optional_uint64_t optImm, uint32_t *bytesOut, uint32_t *maskOut); -int arm64_dec_ldr_imm(uint32_t inst, arm64_register *destinationReg, arm64_register *addrReg, uint64_t *immOut, char *typeOut, arm64_ldr_str_type *instTypeOut); -int arm64_gen_str_imm(char type, arm64_ldr_str_type instType, arm64_register sourceReg, arm64_register addrReg, optional_uint64_t optImm, uint32_t *bytesOut, uint32_t *maskOut); -int arm64_dec_str_imm(uint32_t inst, arm64_register *sourceRegOut, arm64_register *addrRegOut, uint64_t *immOut, char *typeOut, arm64_ldr_str_type *instTypeOut); -int arm64_gen_ldr_lit(arm64_register destinationReg, optional_uint64_t optImm, uint32_t *bytesOut, uint32_t *maskOut); -int arm64_dec_ldr_lit(uint32_t inst, arm64_register *destinationReg, int64_t *immOut); -int arm64_gen_cb_n_z(optional_bool isCbnz, arm64_register reg, optional_uint64_t optTarget, uint32_t *bytesOut, uint32_t *maskOut); -int arm64_dec_cb_n_z(uint32_t inst, uint64_t origin, bool *isCbnzOut, arm64_register *regOut, uint64_t *targetOut); -#endif \ No newline at end of file diff --git a/RootHelper/external/lib/libchoma.a b/RootHelper/external/lib/libchoma.a deleted file mode 100644 index 4ec7fc8..0000000 Binary files a/RootHelper/external/lib/libchoma.a and /dev/null differ diff --git a/RootHelper/external/lib/libcrypto.a b/RootHelper/external/lib/libcrypto.a deleted file mode 100644 index 99a37ac..0000000 Binary files a/RootHelper/external/lib/libcrypto.a and /dev/null differ