Skip to content

Commit

Permalink
fixed: Navicat Premium 17.1.8
Browse files Browse the repository at this point in the history
(cherry picked from commit 6702a8b325b7f4b517eb42a444261c49f5d86fee)
  • Loading branch information
marlkiller authored and marlkiller committed Dec 27, 2024
1 parent fa5e0d0 commit 11762bd
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
19 changes: 15 additions & 4 deletions dylib_dobby_hook/utils/CommonRetOC.m
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,21 @@ + (id)hook_defaultContainer {

- (void)hook_AllSecItem{
NSLogger(@"hook_AllSecItem");
tiny_hook(SecItemAdd, hk_SecItemAdd, NULL);
tiny_hook(SecItemUpdate, hk_SecItemUpdate, NULL);
tiny_hook(SecItemDelete, hk_SecItemDelete, NULL);
tiny_hook(SecItemCopyMatching, hk_SecItemCopyMatching, NULL);

// FIXME: 有些 app tiny_hook 第三个参数不能传 null, 否则奔溃, 不知道为什么;
// VM Region Info: 0 is not in any region. Bytes before following region: 4438192128
// REGION TYPE START - END [ VSIZE] PRT/MAX SHRMOD REGION DETAIL
// UNUSED SPACE AT START
// --->
// __TEXT 108897000-10a4f2000 [ 28.4M] r-x/r-x SM=COW /Applications/Navicat Premium.app/Contents/MacOS/Navicat Premium
//
// Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
// 0 Security 0x7ff814322df9 SecItemCopyMatching + 0

tiny_hook(SecItemAdd, hk_SecItemAdd, (void *)&SecItemAdd_ori);
tiny_hook(SecItemUpdate, hk_SecItemUpdate, (void *)&SecItemUpdate_ori);
tiny_hook(SecItemDelete, hk_SecItemDelete, (void *)&SecItemDelete_ori);
tiny_hook(SecItemCopyMatching, hk_SecItemCopyMatching,(void *)&SecItemCopyMatching_ori);
}

- (void)hook_AllSecCode:teamIdentifier{
Expand Down
8 changes: 8 additions & 0 deletions dylib_dobby_hook/utils/common_ret.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,17 @@ extern SecCodeCopySigningInformation_ptr_t SecCodeCopySigningInformation_ori;
* - hk_SecItemDelete: Deletes an item.
* - hk_SecItemCopyMatching: Retrieves an item.
*/
typedef OSStatus (*SecItemAdd_ptr_t)(CFDictionaryRef attributes, CFTypeRef *result);
extern SecItemAdd_ptr_t SecItemAdd_ori;
OSStatus hk_SecItemAdd(CFDictionaryRef attributes, CFTypeRef *result);
typedef OSStatus (*SecItemUpdate_ptr_t)(CFDictionaryRef query, CFDictionaryRef attributesToUpdate);
extern SecItemUpdate_ptr_t SecItemUpdate_ori;
OSStatus hk_SecItemUpdate(CFDictionaryRef query, CFDictionaryRef attributesToUpdate);
typedef OSStatus (*SecItemDelete_ptr_t)(CFDictionaryRef query);
extern SecItemDelete_ptr_t SecItemDelete_ori;
OSStatus hk_SecItemDelete(CFDictionaryRef query);
typedef OSStatus (*SecItemCopyMatching_ptr_t)(CFDictionaryRef query, CFTypeRef *result);
extern SecItemCopyMatching_ptr_t SecItemCopyMatching_ori;
OSStatus hk_SecItemCopyMatching(CFDictionaryRef query, CFTypeRef *result);

NSString *love69(NSString *input);
Expand Down
4 changes: 4 additions & 0 deletions dylib_dobby_hook/utils/common_ret.m
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ OSStatus hk_SecCodeCopySigningInformation(SecCodeRef codeRef, SecCSFlags flags,

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
SecItemAdd_ptr_t SecItemAdd_ori = NULL;
OSStatus hk_SecItemAdd(CFDictionaryRef attributes, CFTypeRef *result) {
NSLogger(@"hk_SecItemAdd");
CFStringRef service = (CFStringRef)CFDictionaryGetValue(attributes, kSecAttrService);
Expand Down Expand Up @@ -257,6 +258,7 @@ OSStatus hk_SecItemAdd(CFDictionaryRef attributes, CFTypeRef *result) {
return status;
}

SecItemUpdate_ptr_t SecItemUpdate_ori = NULL;
OSStatus hk_SecItemUpdate(CFDictionaryRef query, CFDictionaryRef attributesToUpdate) {
NSLogger(@"hk_SecItemUpdate");
CFStringRef service = (CFStringRef)CFDictionaryGetValue(query, kSecAttrService);
Expand Down Expand Up @@ -293,6 +295,7 @@ OSStatus hk_SecItemUpdate(CFDictionaryRef query, CFDictionaryRef attributesToUpd
return status;
}

SecItemDelete_ptr_t SecItemDelete_ori = NULL;
OSStatus hk_SecItemDelete(CFDictionaryRef query) {
NSLogger(@"hk_SecItemDelete");
CFStringRef service = (CFStringRef)CFDictionaryGetValue(query, kSecAttrService);
Expand All @@ -319,6 +322,7 @@ OSStatus hk_SecItemDelete(CFDictionaryRef query) {
return status;
}

SecItemCopyMatching_ptr_t SecItemCopyMatching_ori = NULL;
OSStatus hk_SecItemCopyMatching(CFDictionaryRef query, CFTypeRef *result) {
NSLogger(@"hk_SecItemCopyMatching");
// 从查询字典中提取 service 和 account
Expand Down

0 comments on commit 11762bd

Please sign in to comment.