This commit is contained in:
opa334 2022-09-04 03:04:09 +02:00
parent b85398e4fa
commit 5bb621c4fe
6 changed files with 51 additions and 44 deletions

View File

@ -1,6 +1,6 @@
Package: com.opa334.trollstoreroothelper Package: com.opa334.trollstoreroothelper
Name: trollstoreroothelper Name: trollstoreroothelper
Version: 1.0.3 Version: 1.0.4
Architecture: iphoneos-arm Architecture: iphoneos-arm
Description: An awesome tool of some sort!! Description: An awesome tool of some sort!!
Maintainer: opa334 Maintainer: opa334

View File

@ -230,6 +230,9 @@ NSDictionary* dumpEntitlements(NSString* binaryPath)
struct mach_header_universal header; struct mach_header_universal header;
fread(&header,sizeof(header),1,machoFile); 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) if(header.magic == FAT_MAGIC || header.magic == FAT_CIGAM)
{ {
fseek(machoFile,0,SEEK_SET); fseek(machoFile,0,SEEK_SET);
@ -250,57 +253,61 @@ NSDictionary* dumpEntitlements(NSString* binaryPath)
continue; continue;
} }
fseek(machoFile,s32(fatArch.offset, swpFat),SEEK_SET); archOffset = s32(fatArch.offset, swpFat);
struct mach_header_universal header; break;
fread(&header,sizeof(header),1,machoFile); }
}
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 if(header.magic == MH_MAGIC_UNIVERSAL || header.magic == MH_CIGAM_UNIVERSAL)
uint32_t offset = s32(fatArch.offset, swpFat) + sizeof(header); {
for(int c = 0; c < s32(header.ncmds, swp); c++) 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); fseek(machoFile,offset,SEEK_SET);
struct load_command cmd; fread(&codeSignCommand,sizeof(codeSignCommand),1,machoFile);
fread(&cmd,sizeof(cmd),1,machoFile); uint32_t codeSignCmdOffset = archOffset + s32(codeSignCommand.dataoff, swp);
uint32_t normalizedCmd = s32(cmd.cmd,swp); fseek(machoFile, codeSignCmdOffset, SEEK_SET);
if(normalizedCmd == LC_CODE_SIGNATURE) 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; uint32_t itemCount = SWAP32(superBlob.count);
fseek(machoFile,offset,SEEK_SET); for(int i = 0; i < itemCount; i++)
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); fseek(machoFile, codeSignCmdOffset + sizeof(superBlob) + i * sizeof(struct CSBlob),SEEK_SET);
for(int i = 0; i < itemCount; i++) 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); uint32_t entitlementsLengthTmp;
struct CSBlob blob; fread(&entitlementsLengthTmp, sizeof(uint32_t), 1, machoFile);
fread(&blob, sizeof(struct CSBlob), 1, machoFile); entitlementsLength = SWAP32(entitlementsLengthTmp);
fseek(machoFile, codeSignCmdOffset + SWAP32(blob.offset),SEEK_SET); entitlementsData = malloc(entitlementsLength - 8);
uint32_t blobMagic; fread(&entitlementsData[0], entitlementsLength - 8, 1, machoFile);
fread(&blobMagic, sizeof(uint32_t), 1, machoFile); break;
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;
}
} }
} }
break;
} }
offset += cmd.cmdsize; break;
} }
offset += cmd.cmdsize;
} }
} }

View File

@ -52,7 +52,7 @@
<string>iPhoneOS</string> <string>iPhoneOS</string>
</array> </array>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>1.0.3</string> <string>1.0.4</string>
<key>LSRequiresIPhoneOS</key> <key>LSRequiresIPhoneOS</key>
<true/> <true/>
<key>UIDeviceFamily</key> <key>UIDeviceFamily</key>

View File

@ -1,6 +1,6 @@
Package: com.opa334.trollstorehelper Package: com.opa334.trollstorehelper
Name: TrollStore Helper Name: TrollStore Helper
Version: 1.0.3 Version: 1.0.4
Architecture: iphoneos-arm Architecture: iphoneos-arm
Description: Helper app to install and manage TrollStore! Description: Helper app to install and manage TrollStore!
Maintainer: opa334 Maintainer: opa334

View File

@ -50,7 +50,7 @@
<string>iPhoneOS</string> <string>iPhoneOS</string>
</array> </array>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>1.0.3</string> <string>1.0.4</string>
<key>LSRequiresIPhoneOS</key> <key>LSRequiresIPhoneOS</key>
<true/> <true/>
<key>UIDeviceFamily</key> <key>UIDeviceFamily</key>

View File

@ -1,6 +1,6 @@
Package: com.opa334.trollstore Package: com.opa334.trollstore
Name: TrollStore Name: TrollStore
Version: 1.0.3 Version: 1.0.4
Architecture: iphoneos-arm Architecture: iphoneos-arm
Description: An awesome application! Description: An awesome application!
Maintainer: opa334 Maintainer: opa334