Skip to content

Instantly share code, notes, and snippets.

@PoomSmart
Last active February 16, 2022 23:11
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PoomSmart/7410b770427f2c839969fe8aee8fecf8 to your computer and use it in GitHub Desktop.
Save PoomSmart/7410b770427f2c839969fe8aee8fecf8 to your computer and use it in GitHub Desktop.
Read the entitlements of iOS application at run-time
#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