|
1 | | -#import <Foundation/Foundation.h> |
2 | 1 | #include <dlfcn.h> |
| 2 | +#include <time.h> |
| 3 | +#import <Foundation/Foundation.h> |
3 | 4 |
|
4 | 5 | static void* _SMJobSubmit; |
| 6 | +static int last_inst_time = 0; |
| 7 | +static void nouse(){} |
| 8 | +static void* _CFPropertyListCreateData = (void*)nouse; |
| 9 | + |
| 10 | +%hookf(CFDataRef, _CFPropertyListCreateData, CFAllocatorRef allocator, CFPropertyListRef propertyList, CFPropertyListFormat format, CFOptionFlags options, CFErrorRef* error) { |
| 11 | + if (CFGetTypeID(propertyList) == CFDictionaryGetTypeID()) { |
| 12 | + NSDictionary* info = (__bridge NSDictionary*)propertyList; |
| 13 | + if (info[@"Service"] != nil && [info[@"Service"] isEqualToString:@"com.apple.mobile.installation_proxy"]) { |
| 14 | + last_inst_time = time(0); |
| 15 | + } |
| 16 | + NSLog(@"_SMJobSubmit => _CFPropertyListCreateData info: %@", info); |
| 17 | + } |
| 18 | + return %orig; |
| 19 | +} |
5 | 20 |
|
6 | 21 | %hookf(Boolean, _SMJobSubmit, CFStringRef domain, CFDictionaryRef job, CFTypeID auth, CFErrorRef *outError) |
7 | 22 | { |
8 | 23 | NSMutableDictionary* mjob = [(__bridge NSDictionary*)job mutableCopy]; |
9 | 24 | if (job != nil && mjob[@"ProgramArguments"] != nil) |
10 | 25 | { |
11 | 26 | NSArray* argv = mjob[@"ProgramArguments"]; |
12 | | - |
13 | 27 | NSLog(@"_SMJobSubmit argv=%@", argv); |
14 | 28 |
|
15 | | - if ([argv[0] hasSuffix:@"/debugserver"]) |
16 | | - { |
17 | | - NSMutableArray* new_argv = [argv mutableCopy]; |
18 | | - |
19 | | - new_argv[0] = @"/var/jb/usr/bin/debugserver_xcode"; |
| 29 | + NSString *path = argv.firstObject; |
| 30 | + NSLog(@"_SMJobSubmit path=%@", path); |
20 | 31 |
|
21 | | - mjob[@"UserName"] = @"root"; |
22 | | - mjob[@"ProgramArguments"] = new_argv; |
23 | | - } |
24 | | - |
25 | | - job = (__bridge_retained CFDictionaryRef)mjob; |
| 32 | + if (time(0) - last_inst_time > 3) // 防止影响Xcode安装调试普通App |
| 33 | + { |
| 34 | + if ([path hasSuffix:@"/debugserver"]) |
| 35 | + { |
| 36 | + NSMutableArray* new_argv = [argv mutableCopy]; |
| 37 | + new_argv[0] = @"/var/jb/usr/bin/debugserver_xcode"; |
| 38 | + mjob[@"UserName"] = @"root"; |
| 39 | + mjob[@"ProgramArguments"] = new_argv; |
| 40 | + job = (__bridge_retained CFDictionaryRef)mjob; |
| 41 | + } |
| 42 | + } |
26 | 43 | } |
| 44 | + |
27 | 45 | return %orig; |
28 | 46 | } |
29 | 47 |
|
|
0 commit comments