-
-
Save dlevi309/d2b1ad9979a55e5cb2621c1cf85872f3 to your computer and use it in GitHub Desktop.
Reachable Mach services from the app sandbox on iOS 16.1
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
// cc reachable_services_get.m -o reachable_services_get -framework Foundation | |
#import <Foundation/Foundation.h> | |
#import <servers/bootstrap.h> | |
void enumerateMachServices() { | |
NSDictionary<NSString*, id>* dict = [NSDictionary dictionaryWithContentsOfFile:@"/System/Library/xpc/launchd.plist"]; | |
NSDictionary<NSString*, id>* launchDaemons = dict[@"LaunchDaemons"]; | |
for (NSString* key in launchDaemons) { | |
NSDictionary<NSString*, id>* job = launchDaemons[key]; | |
NSDictionary<NSString*, id>* machServices = job[@"MachServices"]; | |
for (NSString* serviceName in machServices) { | |
mach_port_t service_port = MACH_PORT_NULL; | |
kern_return_t err = bootstrap_look_up(bootstrap_port, serviceName.UTF8String, &service_port); | |
if (!err) { | |
printf("%s\n", serviceName.UTF8String); | |
mach_port_deallocate(mach_task_self_, service_port); | |
} | |
} | |
} | |
} | |
int main(int argc, char *argv[], char *envp[]) { | |
@autoreleasepool { | |
enumerateMachServices(); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment