├── Makefile
├── ent.plist
├── sbbundleids.c
├── sblaunch.c
├── sbopenurl.c
└── sburlschemes.c
/Makefile:
--------------------------------------------------------------------------------
1 | BINS := sblaunch sburlschemes sbopenurl sbbundleids
2 | all: $(BINS)
3 | %: %.c ent.plist
4 | igcc -o $@ $< -std=gnu99 -framework CoreFoundation -framework SpringBoardServices
5 | ldid -Sent.plist $@
6 | clean:
7 | rm -f $(BINS)
8 |
--------------------------------------------------------------------------------
/ent.plist:
--------------------------------------------------------------------------------
1 | com.apple.springboard.debugapplicationscom.apple.springboard.opensensitiveurl
2 |
3 |
--------------------------------------------------------------------------------
/sbbundleids.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 |
5 | CFArrayRef SBSCopyApplicationDisplayIdentifiers(bool onlyActive, bool debuggable);
6 |
7 | int main() {
8 | char buf[1024];
9 | CFArrayRef ary = SBSCopyApplicationDisplayIdentifiers(false, false);
10 | for(CFIndex i = 0; i < CFArrayGetCount(ary); i++) {
11 | CFStringGetCString(CFArrayGetValueAtIndex(ary, i),buf, sizeof(buf), kCFStringEncodingUTF8);
12 | printf("%s\n", buf);
13 | }
14 | return 0;
15 | }
16 |
--------------------------------------------------------------------------------
/sblaunch.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #define SBSApplicationLaunchUnlockDevice 4
4 | #define SBSApplicationDebugOnNextLaunch_plus_SBSApplicationLaunchWaitForDebugger 0x402
5 |
6 | bool SBSProcessIDForDisplayIdentifier(CFStringRef id, pid_t *pid);
7 | int SBSLaunchApplicationWithIdentifier(CFStringRef id, char flags);
8 | int SBSLaunchApplicationForDebugging(CFStringRef bundleID, CFURLRef openURL, CFArrayRef arguments, CFDictionaryRef environment, CFStringRef stdout, CFStringRef stderr, char flags);
9 |
10 | int main(int argc, char **argv) {
11 | bool p = false;
12 | const char *url = NULL;
13 | const char *bundle;
14 | int flags = SBSApplicationLaunchUnlockDevice;
15 |
16 | int c;
17 | while((c = getopt(argc, argv, "pdbu:")) != -1)
18 | switch(c) {
19 | case 'p': p = true; break;
20 | case 'd': flags |= SBSApplicationDebugOnNextLaunch_plus_SBSApplicationLaunchWaitForDebugger; break;
21 | case 'b': flags |= 1; break;
22 | case 'u': url = optarg; break;
23 | default: goto usage;
24 | }
25 | if(optind == argc) goto usage;
26 | bundle = argv[optind];
27 |
28 | CFMutableArrayRef arguments = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks);
29 | while(++optind != argc) CFArrayAppendValue(arguments, CFStringCreateWithCString(NULL, argv[optind], kCFStringEncodingUTF8));
30 |
31 |
32 | CFStringRef cs = CFStringCreateWithCString(NULL, bundle, kCFStringEncodingUTF8);
33 | CFURLRef cu = url ? CFURLCreateWithBytes(NULL, url, strlen(url), kCFStringEncodingUTF8, NULL) : NULL;
34 | if(url && !cu) {
35 | fprintf(stderr, "invalid URL\n");
36 | return 1;
37 | }
38 | int err;
39 | if(err = SBSLaunchApplicationForDebugging(cs, cu, arguments, NULL, NULL, NULL, flags)) {
40 | fprintf(stderr, "SBSLaunchApplicationWithIdentifier failed: %d\n", err);
41 | return 1;
42 | }
43 | if(p) {
44 | pid_t pid;
45 | while(!SBSProcessIDForDisplayIdentifier(cs, &pid)) {
46 | usleep(50000);
47 | }
48 | printf("%d\n", (int) pid);
49 | }
50 | return 0;
51 |
52 | usage:
53 | fprintf(stderr, "Usage: sblaunch [-p] [-d] [-b] [-u url] [arguments...]\n"
54 | " -p: print pid\n"
55 | " -d: launch for debugging\n"
56 | " -b: launch in background\n"
57 | );
58 | return 1;
59 | }
60 |
--------------------------------------------------------------------------------
/sbopenurl.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | #define SBSApplicationLaunchUnlockDevice 4
5 | #define SBSApplicationDebugOnNextLaunch_plus_SBSApplicationLaunchWaitForDebugger 0x402
6 |
7 | bool SBSOpenSensitiveURLAndUnlock(CFURLRef url, char flags);
8 |
9 | int main(int argc, char **argv) {
10 | if(argc != 2) {
11 | fprintf(stderr, "Usage: sbopenurl url\n");
12 | }
13 | CFURLRef cu = CFURLCreateWithBytes(NULL, argv[1], strlen(argv[1]), kCFStringEncodingUTF8, NULL);
14 | if(!cu) {
15 | fprintf(stderr, "invalid URL\n");
16 | return 1;
17 | }
18 | int fd = dup(2);
19 | close(2);
20 | bool ret = SBSOpenSensitiveURLAndUnlock(cu, 1);
21 | if(!ret) {
22 | dup2(fd, 2);
23 | fprintf(stderr, "SBSOpenSensitiveURLAndUnlock failed\n");
24 | return 1;
25 | }
26 | return 0;
27 | }
28 |
--------------------------------------------------------------------------------
/sburlschemes.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | CFArrayRef SBSCopyPublicURLSchemes();
5 |
6 | int main() {
7 | char buf[1024];
8 | CFArrayRef ary = SBSCopyPublicURLSchemes();
9 | for(CFIndex i = 0; i < CFArrayGetCount(ary); i++) {
10 | CFStringGetCString(CFArrayGetValueAtIndex(ary, i),buf, sizeof(buf), kCFStringEncodingUTF8);
11 | printf("%s\n", buf);
12 | }
13 | return 0;
14 | }
15 |
--------------------------------------------------------------------------------