From 5bb621c4fe0ca07276d7f1d683a3c28f41b13323 Mon Sep 17 00:00:00 2001 From: opa334 Date: Sun, 4 Sep 2022 03:04:09 +0200 Subject: [PATCH] 1.0.4 --- Helper/control | 2 +- Helper/main.m | 85 ++++++++++++++------------ PersistenceHelper/Resources/Info.plist | 2 +- PersistenceHelper/control | 2 +- Store/Resources/Info.plist | 2 +- Store/control | 2 +- 6 files changed, 51 insertions(+), 44 deletions(-) diff --git a/Helper/control b/Helper/control index d89e573..855c170 100644 --- a/Helper/control +++ b/Helper/control @@ -1,6 +1,6 @@ Package: com.opa334.trollstoreroothelper Name: trollstoreroothelper -Version: 1.0.3 +Version: 1.0.4 Architecture: iphoneos-arm Description: An awesome tool of some sort!! Maintainer: opa334 diff --git a/Helper/main.m b/Helper/main.m index 75b9ef0..4bdbc81 100644 --- a/Helper/main.m +++ b/Helper/main.m @@ -230,6 +230,9 @@ NSDictionary* dumpEntitlements(NSString* binaryPath) struct mach_header_universal header; fread(&header,sizeof(header),1,machoFile); + uint32_t archOffset = 0; + + // Get arch offset if FAT binary if(header.magic == FAT_MAGIC || header.magic == FAT_CIGAM) { fseek(machoFile,0,SEEK_SET); @@ -250,57 +253,61 @@ NSDictionary* dumpEntitlements(NSString* binaryPath) continue; } - fseek(machoFile,s32(fatArch.offset, swpFat),SEEK_SET); - struct mach_header_universal header; - fread(&header,sizeof(header),1,machoFile); + archOffset = s32(fatArch.offset, swpFat); + break; + } + } - BOOL swp = header.magic == MH_CIGAM_UNIVERSAL; + fseek(machoFile,archOffset,SEEK_SET); + fread(&header,sizeof(header),1,machoFile); - // This code is cursed, don't stare at it too long or it will stare back at you - uint32_t offset = s32(fatArch.offset, swpFat) + sizeof(header); - for(int c = 0; c < s32(header.ncmds, swp); c++) + if(header.magic == MH_MAGIC_UNIVERSAL || header.magic == MH_CIGAM_UNIVERSAL) + { + BOOL swp = header.magic == MH_CIGAM_UNIVERSAL; + // This code is cursed, don't stare at it too long or it will stare back at you + uint32_t offset = archOffset + sizeof(header); + for(int c = 0; c < s32(header.ncmds, swp); c++) + { + fseek(machoFile,offset,SEEK_SET); + struct load_command cmd; + fread(&cmd,sizeof(cmd),1,machoFile); + uint32_t normalizedCmd = s32(cmd.cmd,swp); + if(normalizedCmd == LC_CODE_SIGNATURE) { + struct linkedit_data_command codeSignCommand; fseek(machoFile,offset,SEEK_SET); - struct load_command cmd; - fread(&cmd,sizeof(cmd),1,machoFile); - uint32_t normalizedCmd = s32(cmd.cmd,swp); - if(normalizedCmd == LC_CODE_SIGNATURE) + fread(&codeSignCommand,sizeof(codeSignCommand),1,machoFile); + uint32_t codeSignCmdOffset = archOffset + s32(codeSignCommand.dataoff, swp); + fseek(machoFile, codeSignCmdOffset, SEEK_SET); + struct CSSuperBlob superBlob; + fread(&superBlob, sizeof(superBlob), 1, machoFile); + if(SWAP32(superBlob.magic) == CS_MAGIC_EMBEDDED_SIGNATURE) // YES starting here everything is swapped no matter if CIGAM or MAGIC... { - struct linkedit_data_command codeSignCommand; - fseek(machoFile,offset,SEEK_SET); - fread(&codeSignCommand,sizeof(codeSignCommand),1,machoFile); - uint32_t codeSignCmdOffset = s32(fatArch.offset, swpFat) + s32(codeSignCommand.dataoff, swp); - fseek(machoFile, codeSignCmdOffset, SEEK_SET); - struct CSSuperBlob superBlob; - fread(&superBlob, sizeof(superBlob), 1, machoFile); - if(SWAP32(superBlob.magic) == CS_MAGIC_EMBEDDED_SIGNATURE) + uint32_t itemCount = SWAP32(superBlob.count); + for(int i = 0; i < itemCount; i++) { - uint32_t itemCount = SWAP32(superBlob.count); - for(int i = 0; i < itemCount; i++) + fseek(machoFile, codeSignCmdOffset + sizeof(superBlob) + i * sizeof(struct CSBlob),SEEK_SET); + struct CSBlob blob; + fread(&blob, sizeof(struct CSBlob), 1, machoFile); + fseek(machoFile, codeSignCmdOffset + SWAP32(blob.offset),SEEK_SET); + uint32_t blobMagic; + fread(&blobMagic, sizeof(uint32_t), 1, machoFile); + if(SWAP32(blobMagic) == CS_MAGIC_EMBEDDED_ENTITLEMENTS) { - fseek(machoFile, codeSignCmdOffset + sizeof(superBlob) + i * sizeof(struct CSBlob),SEEK_SET); - struct CSBlob blob; - fread(&blob, sizeof(struct CSBlob), 1, machoFile); - fseek(machoFile, codeSignCmdOffset + SWAP32(blob.offset),SEEK_SET); - uint32_t blobMagic; - fread(&blobMagic, sizeof(uint32_t), 1, machoFile); - if(SWAP32(blobMagic) == CS_MAGIC_EMBEDDED_ENTITLEMENTS) - { - uint32_t entitlementsLengthTmp; - fread(&entitlementsLengthTmp, sizeof(uint32_t), 1, machoFile); - entitlementsLength = SWAP32(entitlementsLengthTmp); - entitlementsData = malloc(entitlementsLength - 8); - fread(&entitlementsData[0], entitlementsLength - 8, 1, machoFile); - break; - } + uint32_t entitlementsLengthTmp; + fread(&entitlementsLengthTmp, sizeof(uint32_t), 1, machoFile); + entitlementsLength = SWAP32(entitlementsLengthTmp); + entitlementsData = malloc(entitlementsLength - 8); + fread(&entitlementsData[0], entitlementsLength - 8, 1, machoFile); + break; } } - - break; } - offset += cmd.cmdsize; + break; } + + offset += cmd.cmdsize; } } diff --git a/PersistenceHelper/Resources/Info.plist b/PersistenceHelper/Resources/Info.plist index 597db31..2818f6d 100644 --- a/PersistenceHelper/Resources/Info.plist +++ b/PersistenceHelper/Resources/Info.plist @@ -52,7 +52,7 @@ iPhoneOS CFBundleVersion - 1.0.3 + 1.0.4 LSRequiresIPhoneOS UIDeviceFamily diff --git a/PersistenceHelper/control b/PersistenceHelper/control index 7315cc5..36422fa 100644 --- a/PersistenceHelper/control +++ b/PersistenceHelper/control @@ -1,6 +1,6 @@ Package: com.opa334.trollstorehelper Name: TrollStore Helper -Version: 1.0.3 +Version: 1.0.4 Architecture: iphoneos-arm Description: Helper app to install and manage TrollStore! Maintainer: opa334 diff --git a/Store/Resources/Info.plist b/Store/Resources/Info.plist index a399920..1b107f7 100644 --- a/Store/Resources/Info.plist +++ b/Store/Resources/Info.plist @@ -50,7 +50,7 @@ iPhoneOS CFBundleVersion - 1.0.3 + 1.0.4 LSRequiresIPhoneOS UIDeviceFamily diff --git a/Store/control b/Store/control index 68b7e5c..808c568 100644 --- a/Store/control +++ b/Store/control @@ -1,6 +1,6 @@ Package: com.opa334.trollstore Name: TrollStore -Version: 1.0.3 +Version: 1.0.4 Architecture: iphoneos-arm Description: An awesome application! Maintainer: opa334