Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

使用 HookZz 替换 mach_msg 方法程序崩溃 #63

Closed
zhshijie opened this issue Sep 18, 2019 · 2 comments
Closed

使用 HookZz 替换 mach_msg 方法程序崩溃 #63

zhshijie opened this issue Sep 18, 2019 · 2 comments

Comments

@zhshijie
Copy link

问题描述:
使用 hookZz 来 hook mach_msg 方法时,会导致程序奔溃。复现步骤如下:

  1. 使用 hookZz hook mach_msg 方法
  2. 调试运行应用
  3. 关闭正在调试运行的应用,直接在手机上点击 app 打开应用
  4. 程序运行到 ZzReplace 方法时崩溃。

查看系统日志后,崩溃记录如下:

Incident Identifier: 19692A36-D9F0-4F6A-9208-1FBD99916D6F
CrashReporter Key:   c07a42931a4c65ba1ff9ff0c099f299fe8440a22
Hardware Model:      iPhone10,1
Process:             TestHook [3374]
Path:                /private/var/containers/Bundle/Application/75CD7B07-0D3F-4C16-BE29-1D858D9A42C1/TestHook.app/TestHook
Identifier:          com.zsj.TestHook
Version:             1 (1.0)
Code Type:           ARM-64 (Native)
Role:                Non UI
Parent Process:      launchd [1]
Coalition:           com.zsj.TestHook [2958]


Date/Time:           2019-09-18 11:19:50.9424 +0800
Launch Time:         2019-09-18 11:19:46.7515 +0800
OS Version:          iPhone OS 12.4.1 (16G102)
Baseband Version:    3.70.01
Report Version:      104

Exception Type:  EXC_CRASH (SIGKILL - CODESIGNING)
Exception Codes: 0x0000000000000001, 0x0000000000000000
Exception Note:  EXC_CORPSE_NOTIFY
Termination Reason: Namespace CODESIGNING, Code 0x2
Triggered by Thread:  0

Thread 0 name:  Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0   libsystem_kernel.dylib        	0x00000001919140f4 mach_msg_trap + 8
1   libsystem_kernel.dylib        	0x00000001919135a0 mach_msg + 72
2   libsystem_kernel.dylib        	0x0000000191911c38 vm_copy + 100
3   hookzz                        	0x0000000102d4275c 0x102d38000 + 42844
4   hookzz                        	0x0000000102d407a4 0x102d38000 + 34724
5   hookzz                        	0x0000000102d40738 0x102d38000 + 34616
6   hookzz                        	0x0000000102d417e4 0x102d38000 + 38884
7   hookzz                        	0x0000000102d421bc 0x102d38000 + 41404
8   hookzz                        	0x0000000102d42378 0x102d38000 + 41848
9   hookzz                        	0x0000000102d424f0 0x102d38000 + 42224
10  TestHook                      	0x0000000102d12704 0x102d0c000 + 26372
11  libdispatch.dylib             	0x00000001917c17d4 _dispatch_client_callout + 16
12  libdispatch.dylib             	0x0000000191798c34 

后续只要不是关闭 debug 模式,采用 hookZz 进行 hook 时,都会导致程序崩溃。
以 "Namespace CODESIGNING" 作为关键字进行搜索时,找到了如下文章:
http://iosre.com/t/topic/8628
文章说可能是 非越狱设备上substrate会触发内核校验 导致了崩溃。

想问下是否有什么解决方法。

PS:
之所以不使用 fishhook 去 hook mach_msg,是因为发现采用 fishhook 并不能 hook 系统库(如 WebKit )中的 mach_msg。猜测是由于 iOS 使用了动态库共享缓存,导致系统库中符号的外部地址已经全部被确定了,不需要在通过动态链接去取值,所以使用 fishhook 去修改动态符号库里面的地址也起到 hook 的作用。

@zhshijie
Copy link
Author

找到了作者以前写的文章 HookFramework 架构设计,里面最后一段写了崩溃原因。
想问下作者这个问题现在有解决方法吗?
谢谢。

@jmpews
Copy link
Owner

jmpews commented Sep 18, 2019

inlinehook 无法在非越狱上运行

@jmpews jmpews closed this as completed Sep 18, 2019
@Lamfi Lamfi mentioned this issue Dec 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants