Skip to content

Commit f6f229b

Browse files
committed
add: MockUbiquitousKV tools
1 parent 9da482f commit f6f229b

File tree

18 files changed

+456
-170
lines changed

18 files changed

+456
-170
lines changed

dylib_dobby_hook.xcodeproj/project.pbxproj

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@
5252
B5822CA92CBFFC020062383F /* Logger.h in Headers */ = {isa = PBXBuildFile; fileRef = B5822CA82CBFFC020062383F /* Logger.h */; };
5353
B5938B222DA7E45300FA82B0 /* ishotHack.m in Sources */ = {isa = PBXBuildFile; fileRef = B5938B212DA7E45300FA82B0 /* ishotHack.m */; };
5454
B5938B242DA7E5D100FA82B0 /* BoltAIHack.m in Sources */ = {isa = PBXBuildFile; fileRef = B5938B232DA7E5D100FA82B0 /* BoltAIHack.m */; };
55+
B59D6A2A2E503ED90004D71D /* MockUbiquitousKeyValueStore.h in Headers */ = {isa = PBXBuildFile; fileRef = B59D6A292E503ED90004D71D /* MockUbiquitousKeyValueStore.h */; };
56+
B59D6A2C2E503F010004D71D /* MockUbiquitousKeyValueStore.m in Sources */ = {isa = PBXBuildFile; fileRef = B59D6A2B2E503F010004D71D /* MockUbiquitousKeyValueStore.m */; };
5557
B5A7D30F2C548B71003D4C7F /* HackProtocolDefault.h in Headers */ = {isa = PBXBuildFile; fileRef = B5A7D30E2C548B71003D4C7F /* HackProtocolDefault.h */; };
5658
B5A7D3112C548BAB003D4C7F /* HackProtocolDefault.m in Sources */ = {isa = PBXBuildFile; fileRef = B5A7D3102C548BAB003D4C7F /* HackProtocolDefault.m */; };
5759
B5A7D3142C549130003D4C7F /* ForkLiftHelperHack.m in Sources */ = {isa = PBXBuildFile; fileRef = B5A7D3132C549130003D4C7F /* ForkLiftHelperHack.m */; };
@@ -138,6 +140,8 @@
138140
B5822CA82CBFFC020062383F /* Logger.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Logger.h; sourceTree = "<group>"; };
139141
B5938B212DA7E45300FA82B0 /* ishotHack.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ishotHack.m; sourceTree = "<group>"; };
140142
B5938B232DA7E5D100FA82B0 /* BoltAIHack.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BoltAIHack.m; sourceTree = "<group>"; };
143+
B59D6A292E503ED90004D71D /* MockUbiquitousKeyValueStore.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MockUbiquitousKeyValueStore.h; sourceTree = "<group>"; };
144+
B59D6A2B2E503F010004D71D /* MockUbiquitousKeyValueStore.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MockUbiquitousKeyValueStore.m; sourceTree = "<group>"; };
141145
B5A7D30E2C548B71003D4C7F /* HackProtocolDefault.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HackProtocolDefault.h; sourceTree = "<group>"; };
142146
B5A7D3102C548BAB003D4C7F /* HackProtocolDefault.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = HackProtocolDefault.m; sourceTree = "<group>"; };
143147
B5A7D3132C549130003D4C7F /* ForkLiftHelperHack.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ForkLiftHelperHack.m; sourceTree = "<group>"; };
@@ -234,7 +238,6 @@
234238
children = (
235239
B57AEDBB2C5009F200B9C5FB /* dtrace_kill.d */,
236240
B57AEDBD2C5009F200B9C5FB /* mac_patch_helper */,
237-
B57AEDBE2C5009F200B9C5FB /* patch.json */,
238241
B57AEDBC2C5009F200B9C5FB /* SMJobBlessUtil-python3.py */,
239242
38350C072B53F96100DD52B3 /* insert_dylib */,
240243
);
@@ -298,6 +301,8 @@
298301
B581601D2BE894A2001DDB9B /* utils */ = {
299302
isa = PBXGroup;
300303
children = (
304+
B59D6A2B2E503F010004D71D /* MockUbiquitousKeyValueStore.m */,
305+
B59D6A292E503ED90004D71D /* MockUbiquitousKeyValueStore.h */,
301306
38D1AC272B54C9C100E6CB9E /* Constant.h */,
302307
38D1AC292B54CA4D00E6CB9E /* Constant.m */,
303308
B58160162BE88569001DDB9B /* EncryptionUtils.h */,
@@ -351,6 +356,7 @@
351356
isa = PBXHeadersBuildPhase;
352357
buildActionMask = 2147483647;
353358
files = (
359+
B59D6A2A2E503ED90004D71D /* MockUbiquitousKeyValueStore.h in Headers */,
354360
B5EAA9E02C8C3FAF008C4089 /* URLSessionHook.h in Headers */,
355361
B513ADD72CB95D0B00F5DC97 /* LocalizationManager.h in Headers */,
356362
B5FECEAD2BC4FC29008916D6 /* common_ret.h in Headers */,
@@ -486,6 +492,7 @@
486492
B5369DD02CC4C1DF00A81211 /* VidhubHack.m in Sources */,
487493
B5938B222DA7E45300FA82B0 /* ishotHack.m in Sources */,
488494
2853DED92E17A39E0045A97A /* LiveWallpaperHack.m in Sources */,
495+
B59D6A2C2E503F010004D71D /* MockUbiquitousKeyValueStore.m in Sources */,
489496
38E2ECD32DC48DCA00D76D10 /* ProxymanHelperHack.m in Sources */,
490497
9CE4C5D12CCA7C3600593C78 /* JSONUtils.m in Sources */,
491498
B5938B242DA7E5D100FA82B0 /* BoltAIHack.m in Sources */,

dylib_dobby_hook/apps/DevUtilsHack.m

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,26 @@ - (BOOL)hack {
4343
uintptr_t setAppPatchPtr = [setAppPatchPtrs[0] unsignedIntegerValue];
4444
write_mem((void*)setAppPatchPtr,(uint8_t *)setAppPatchTarget,sizeof(setAppPatchTarget) / sizeof(setAppPatchTarget[0]));
4545

46-
return YES;
46+
//
47+
//#if defined(__arm64__) || defined(__aarch64__)
48+
// NSString* devHex = @"20 00 80 52 C0 03 5F D6 FF 83 01 D1 FA 67 01 A9 F8 5F 02 A9 F6 57 03 A9 F4 4F 04 A9";
49+
// uintptr_t devAddr = 0x3c10;
50+
//#elif defined(__x86_64__)
51+
// NSString* devHex = @"55 48 89 E5 B8 01 00 00 00 5D C3 55 48 89 E5 41 57 41 56 41 55 41 54 53 48 83 EC 28";
52+
// uintptr_t devAddr = 0x3340;
53+
//#endif
54+
//
55+
// NSArray* devPtrs1 = [MemoryUtils getPtrFromMachineCode:(NSString*)@"/Contents/Frameworks/Sparkle.framework/Versions/A/Sparkle"
56+
// machineCode:(NSString*)devHex
57+
// count:(int)1];
58+
// uintptr_t devPtrs2 = [MemoryUtils getPtrFromAddress:(NSString*)@"/Contents/Frameworks/Sparkle.framework/Versions/A/Sparkle"
59+
// targetFunctionAddress:(uintptr_t)devAddr];
60+
// // /Contents/Frameworks/Sparkle.framework/Versions/A/Sparkle > +[SPUDownloadData supportsSecureCoding]:
61+
// IMP imp = method_getImplementation(class_getClassMethod(objc_getClass("SPUDownloadData"), @selector(supportsSecureCoding)));
62+
// NSLogger(@"+[SPUDownloadData supportsSecureCoding] From Hex is 0x%llx", [devPtrs1[0] unsignedLongLongValue]);
63+
// NSLogger(@"+[SPUDownloadData supportsSecureCoding] From VA is 0x%lx", devPtrs2);
64+
// NSLogger(@"+[SPUDownloadData supportsSecureCoding] IMP: %p", imp);
65+
66+
return YES;
4767
}
4868
@end

dylib_dobby_hook/apps/InfuseHack.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ - (BOOL)hack {
3939

4040
[MemoryUtils hookInstanceMethod:
4141
objc_getClass("FCInAppPurchaseServiceFreemium")
42-
originalSelector:NSSelectorFromString(@"iapVersionStatus")
42+
originalSelector:NSSelectorFromString(@"iapStatusWithExpirationDate:")
4343
swizzledClass:[self class]
4444
swizzledSelector:@selector(ret1)
4545
];

dylib_dobby_hook/apps/PaddleBaseHack.m

Lines changed: 45 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -260,55 +260,56 @@ - (id)hook__dataTaskWithRequest:(NSURLRequest *)request
260260
- (BOOL)hack {
261261

262262
if ([[Constant getCurrentAppName] containsString:@"com.movist.MovistPro"]) {
263-
//2.13.0(230)
264-
NSString* targetApp = @"/Contents/MacOS/Movist Pro";
265-
NSLogger(@"Movist Pro start...");
266-
NSArray *CheckPtr = [MemoryUtils getPtrFromMachineCode:targetApp machineCode:@"4d 6f 76 69 73 74 20 50 72 6f 2e 64 65 62 75 67 2e 64 79 6c 69 62" count:1];
267-
uint8_t PatchHex[15] = {0x6c,0x69,0x62,0x5f,0x68,0x61,0x63,0x6b,0x2e,0x64,0x79,0x6c,0x69,0x62,0x00};
263+
// TODO:
264+
// //2.13.0(230)
265+
// NSString* targetApp = @"/Contents/MacOS/Movist Pro";
266+
// NSLogger(@"Movist Pro start...");
267+
// NSArray *CheckPtr = [MemoryUtils getPtrFromMachineCode:targetApp machineCode:@"4d 6f 76 69 73 74 20 50 72 6f 2e 64 65 62 75 67 2e 64 79 6c 69 62" count:1];
268+
// uint8_t PatchHex[15] = {0x6c,0x69,0x62,0x5f,0x68,0x61,0x63,0x6b,0x2e,0x64,0x79,0x6c,0x69,0x62,0x00};
268269

269-
for (NSNumber *item in CheckPtr) {
270-
//NSLogger(@"dylib name: %@",[MemoryUtils readMachineCodeStringAtAddress:item.unsignedIntegerValue length:9]);
271-
write_mem((void*)[item unsignedIntegerValue],(uint8_t *)PatchHex,15);
272-
//NSLogger(@"dylib name after: %@",[MemoryUtils readMachineCodeStringAtAddress:item.unsignedIntegerValue length:9]);
273-
}
270+
// for (NSNumber *item in CheckPtr) {
271+
// //NSLogger(@"dylib name: %@",[MemoryUtils readMachineCodeStringAtAddress:item.unsignedIntegerValue length:9]);
272+
// write_mem((void*)[item unsignedIntegerValue],(uint8_t *)PatchHex,15);
273+
// //NSLogger(@"dylib name after: %@",[MemoryUtils readMachineCodeStringAtAddress:item.unsignedIntegerValue length:9]);
274+
// }
274275

275-
#if defined(__arm64__) || defined(__aarch64__)
276-
NSString *sub_1000064EE = @"F4 4F BE A9 FD 7B 01 A9 FD 43 00 91 08 2A 00 B0 00 D9 45 F9 86 7E 10 94 F3 03 00 AA C2 28 00 F0 42 C0 0C 91 6A 80 10 94 C2 28 00 F0";
277-
278-
#elif defined(__x86_64__)
279-
NSString *sub_1000064EE = @"55 48 89 E5 41 57 41 56 53 50 48 8B 3D 49 EB 62 00 48 8B 35 A2 CF 62 00 4C 8B 3D 6B 2A 5F 00 41 FF D7 48 89 C3 48 8B 35 8E DD 62 00 48 8D 15 E7 CD 60";
280-
281-
#endif
282-
[MemoryUtils hookWithMachineCode:targetApp
283-
machineCode:sub_1000064EE
284-
fake_func:(void *)hook_sub_1000064EE
285-
count:1
286-
];
276+
// #if defined(__arm64__) || defined(__aarch64__)
277+
// NSString *sub_1000064EE = @"F4 4F BE A9 FD 7B 01 A9 FD 43 00 91 08 2A 00 B0 00 D9 45 F9 86 7E 10 94 F3 03 00 AA C2 28 00 F0 42 C0 0C 91 6A 80 10 94 C2 28 00 F0";
278+
279+
// #elif defined(__x86_64__)
280+
// NSString *sub_1000064EE = @"55 48 89 E5 41 57 41 56 53 50 48 8B 3D 49 EB 62 00 48 8B 35 A2 CF 62 00 4C 8B 3D 6B 2A 5F 00 41 FF D7 48 89 C3 48 8B 35 8E DD 62 00 48 8D 15 E7 CD 60";
281+
282+
// #endif
283+
// [MemoryUtils hookWithMachineCode:targetApp
284+
// machineCode:sub_1000064EE
285+
// fake_func:(void *)hook_sub_1000064EE
286+
// count:1
287+
// ];
287288

288289

289-
#if defined(__arm64__) || defined(__aarch64__)
290-
NSString *sub_1000060E0 = @"FF 83 05 D1 E9 23 0F 6D FC 6F 10 A9 FA 67 11 A9 F8 5F 12 A9 F6 57 13 A9 F4 4F 14 A9 FD 7B 15 A9 FD 43 05 91 A8 26 00 B0 08 51 41 F9 08 01 40 F9";
291-
292-
#elif defined(__x86_64__)
293-
NSString *sub_1000060E0 = @"55 48 89 E5 41 57 41 56 41 55 41 54 53 48 81 EC 28 01 00 00 48 8B 05 DD 2A 5F 00 48 8B 00 48 89 45 D0 48 8B 3D 0F EF 62 00 48 8B 35 E0 D1 62 00";
294-
#endif
295-
[MemoryUtils hookWithMachineCode:targetApp
296-
machineCode:sub_1000060E0
297-
fake_func:(void *)hook_sub_1000060E0
298-
count:1
299-
];
290+
// #if defined(__arm64__) || defined(__aarch64__)
291+
// NSString *sub_1000060E0 = @"FF 83 05 D1 E9 23 0F 6D FC 6F 10 A9 FA 67 11 A9 F8 5F 12 A9 F6 57 13 A9 F4 4F 14 A9 FD 7B 15 A9 FD 43 05 91 A8 26 00 B0 08 51 41 F9 08 01 40 F9";
292+
293+
// #elif defined(__x86_64__)
294+
// NSString *sub_1000060E0 = @"55 48 89 E5 41 57 41 56 41 55 41 54 53 48 81 EC 28 01 00 00 48 8B 05 DD 2A 5F 00 48 8B 00 48 89 45 D0 48 8B 3D 0F EF 62 00 48 8B 35 E0 D1 62 00";
295+
// #endif
296+
// [MemoryUtils hookWithMachineCode:targetApp
297+
// machineCode:sub_1000060E0
298+
// fake_func:(void *)hook_sub_1000060E0
299+
// count:1
300+
// ];
300301

301-
#if defined(__arm64__) || defined(__aarch64__)
302-
NSString *sub_100018770 = @"FC 6F BA A9 FA 67 01 A9 F8 5F 02 A9 F6 57 03 A9 F4 4F 04 A9 FD 7B 05 A9 FD 43 01 91 FF 03 02 D1 A1 03 15 F8 A0 03 14 F8";
303-
304-
#elif defined(__x86_64__)
305-
NSString *sub_100018770 = @"55 48 89 E5 41 57 41 56 41 55 41 54 53 48 81 EC A8 00 00 00 48 89 75 C0 48 89 7D 90 31 FF E8 CF 64 51 00 48 89 85 60 FF FF FF 48 8B 40 F8 48 89";
306-
#endif
307-
[MemoryUtils hookWithMachineCode:targetApp
308-
machineCode:sub_100018770
309-
fake_func:(void *)ret1
310-
count:1
311-
];
302+
// #if defined(__arm64__) || defined(__aarch64__)
303+
// NSString *sub_100018770 = @"FC 6F BA A9 FA 67 01 A9 F8 5F 02 A9 F6 57 03 A9 F4 4F 04 A9 FD 7B 05 A9 FD 43 01 91 FF 03 02 D1 A1 03 15 F8 A0 03 14 F8";
304+
305+
// #elif defined(__x86_64__)
306+
// NSString *sub_100018770 = @"55 48 89 E5 41 57 41 56 41 55 41 54 53 48 81 EC A8 00 00 00 48 89 75 C0 48 89 7D 90 31 FF E8 CF 64 51 00 48 89 85 60 FF FF FF 48 8B 40 F8 48 89";
307+
// #endif
308+
// [MemoryUtils hookWithMachineCode:targetApp
309+
// machineCode:sub_100018770
310+
// fake_func:(void *)ret1
311+
// count:1
312+
// ];
312313

313314

314315
}

dylib_dobby_hook/apps/ishotHack.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ - (BOOL)hack {
4242
swizzledSelector:@selector(ishot_hk_displayRegisteredInfo)
4343
];
4444

45-
//NSLog(@"displayRegisteredInfoIMP : %p",displayRegisteredInfoIMP);
45+
//NSLogger(@"displayRegisteredInfoIMP : %p",displayRegisteredInfoIMP);
4646
ishot_istrial();
4747

4848
return YES;

dylib_dobby_hook/utils/CommonRetOC.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555

5656
- (void)hook_AllSecItem;
5757
- (void)hook_AllSecCode:teamIdentifier;
58+
- (void)hook_AllCloudKit;
5859

5960
- (void)record_NSURL:filter;
6061
@end

dylib_dobby_hook/utils/CommonRetOC.m

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#import "CommonRetOC.h"
1010
#import <CloudKit/CloudKit.h>
1111
#import "MockCKContainer.h"
12+
#import "MockUbiquitousKeyValueStore.h"
1213
#import "URLSessionHook.h"
1314
#import "common_ret.h"
1415
#import "Logger.h"
@@ -72,9 +73,9 @@ - (BOOL)hack {
7273

7374

7475
+ (id)hook_defaultStore{
75-
NSLogger(@"hook_defaultStore");
76-
// return [NSUserDefaults standardUserDefaults];
77-
return NULL;
76+
NSLogger(@"hook_defaultStore");
77+
return [MockUbiquitousKeyValueStore defaultStore];
78+
// return class_createInstance([NSUbiquitousKeyValueStore class], 0);
7879
}
7980

8081

@@ -125,6 +126,29 @@ - (void)hook_AllSecItem{
125126
tiny_hook(SecItemCopyMatching, hk_SecItemCopyMatching,(void *)&SecItemCopyMatching_ori);
126127
}
127128

129+
- (void)hook_AllCloudKit{
130+
NSLogger(@"hook_AllCloudKit");
131+
[MemoryUtils hookClassMethod:
132+
NSClassFromString(@"NSUbiquitousKeyValueStore")
133+
originalSelector:NSSelectorFromString(@"defaultStore")
134+
swizzledClass:[self class]
135+
swizzledSelector:@selector(hook_defaultStore)];
136+
137+
[MemoryUtils hookClassMethod:
138+
NSClassFromString(@"CKContainer")
139+
originalSelector:NSSelectorFromString(@"containerWithIdentifier:")
140+
swizzledClass:[self class]
141+
swizzledSelector:@selector(hook_containerWithIdentifier:)];
142+
[MemoryUtils hookClassMethod:
143+
NSClassFromString(@"CKContainer")
144+
originalSelector:NSSelectorFromString(@"defaultContainer")
145+
swizzledClass:[self class]
146+
swizzledSelector:@selector(hook_defaultContainer)
147+
148+
];
149+
}
150+
151+
128152
- (void)hook_AllSecCode:teamIdentifier{
129153
static dispatch_once_t onceToken;
130154
static BOOL hasHooked = NO;

dylib_dobby_hook/utils/Constant.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,11 @@ + (NSString *)getCurrentAppName {
6868
+ (BOOL) isFirstOpen {
6969
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
7070
NSString *currentVersion = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]; // 获取当前的版本号
71-
NSString *storedVersion = [defaults objectForKey:@"appVersion"]; // 获取存储的版本号
71+
NSString *storedVersion = [defaults objectForKey:@"inject_appVersion"]; // 获取存储的版本号
7272

7373
if (!storedVersion || ![storedVersion isEqualToString:currentVersion]) {
7474
// 这是第一次打开,或者是升级后第一次打开,你可以做一些初始化的操作
75-
[defaults setObject:currentVersion forKey:@"appVersion"]; // 更新版本号
75+
[defaults setObject:currentVersion forKey:@"inject_appVersion"]; // 更新版本号
7676
[defaults synchronize]; // 同步到磁盘
7777
return true;
7878
}

dylib_dobby_hook/utils/JSONUtils.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
//
77

88
#import "JSONUtils.h"
9+
#import "Logger.h"
910

1011
@implementation JSONUtils
1112

@@ -35,7 +36,7 @@ + (NSDictionary *)dictionaryFromJsonString:(NSString *)jsonString {
3536
NSDictionary *jsonDict = [NSJSONSerialization JSONObjectWithData:jsonData options:NSJSONReadingMutableContainers error:&error];
3637

3738
if (error) {
38-
NSLog(@"Error parsing JSON: %@", error.localizedDescription);
39+
NSLogger(@"Error parsing JSON: %@", error.localizedDescription);
3940
return nil;
4041
}
4142

dylib_dobby_hook/utils/Logger.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#ifdef DEBUG
1818
#define NSLogger(fmt, ...) \
1919
NSLog((@"%s [Line %d] >>>>>> " fmt), \
20-
__PRETTY_FUNCTION__, \
20+
__func__, \
2121
__LINE__, ##__VA_ARGS__)
2222
#else
2323
#define NSLogger(fmt, ...) do {} while (0)

0 commit comments

Comments
 (0)