Last active
February 16, 2022 23:11
-
-
Save PoomSmart/7410b770427f2c839969fe8aee8fecf8 to your computer and use it in GitHub Desktop.
Read the entitlements of iOS application at run-time
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <substrate.h> | |
#import <HBLog.h> | |
typedef struct __CFRuntimeBase { | |
uintptr_t _cfisa; | |
uint8_t _cfinfo[4]; | |
#ifdef __LP64__ | |
uint32_t _rc; | |
#endif | |
} CFRuntimeBase; | |
struct __SecTask { | |
CFRuntimeBase base; | |
audit_token_t token; | |
Boolean entitlementsLoaded; | |
CFDictionaryRef entitlements; | |
int lastFailure; | |
}; | |
typedef struct __SecTask *SecTaskRef; | |
extern SecTaskRef SecTaskCreateFromSelf(CFAllocatorRef); | |
%ctor { | |
MSImageRef ref = MSGetImageByName("/System/Library/Frameworks/Security.framework/Security"); | |
bool (*SecTaskLoadEntitlements)(SecTaskRef, CFErrorRef *) = MSFindSymbol(ref, "_SecTaskLoadEntitlements"); | |
SecTaskRef secTask = SecTaskCreateFromSelf(NULL); | |
if (SecTaskLoadEntitlements(secTask, NULL)) { | |
HBLogInfo(@"Entitlements: %@", secTask->entitlements); | |
} else { | |
HBLogInfo(@"Error reading entitlements"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment