不用反汇编!LLDB对Objective-C函数下断点的黑科技

流弊流弊~

你把其他断点先禁用了试试?

没有其他断点。

我attach的是一个系统的后台进程。 akd

so cool

逆向AppStore为啥输入的是微信的指令

报同样的错,只是顺手把他那个copy下来了。

那就解释通了。akd没有加载UIKit。 这个方法是uikit的category。解决方案就是自己加载一遍uikit

谢谢啦, 明天早上就试一哈

还是同样的错。

__attribute__((constructor)) static void init(int argc, const char **argv) {
    NSLog([UIViewController _shortMethodDescription]);
}

上面的代码,在log中看起来是正常


<UIViewController: 0x3b18e40c>: in UIViewController:
		Class Methods:
			+ (id) _currentWhitePointAdaptivityStyleViewController; (0x29223919)
			+ (id) _currentStatusBarStyleViewController; (0x290125a5)
			+ (id) _currentStatusBarHiddenViewController; (0x29012979)
			+ (void) _performWithoutDeferringTransitions:(^block)arg1; (0x29217779)
			+ (void) _traverseViewControllerHierarchyWithDelayedRelease:(^block)arg1; (0x29214231)
			+ (id) viewControllerForView:(id)arg1; (0x28ec3805)
			+ (void) initialize; (0x28f189c9)
....

看日志的确是没有找到这个方法


09:48:36 akd➜(null): unrecognized selector sent to class 0x3b18e40c

尝试用张总的py脚本来下断点也不行


(lldb) bom UIViewController doesOverridePreferredInterfaceOrientationForPresentation
error: libarclite_iphoneos.a(arclite.o) failed to load objfile for /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/arc/libarclite_iphoneos.a
warning: failed to set breakpoint site at 0x0 for breakpoint 1.1: error: 0 sending the breakpoint request
Breakpoint 1: address = 0x00000000

另外脚本有几个地方张总可能有点手误

1. 方法签名

可能和lldb的版本有关系,我的版本是 lldb-902.0.79.2 所以我把方法签名改成了下面这样
def breakonmethod(debugger, command, result, internal_dict):
去掉了一个参数

2. script add

debugger.HandleCommand(
        'command script add -f BreakMessage.breakonmethod bom')

这个 -f 后面应该是文件名吧?我也没查反正改成文件名就work了

debugger.HandleCommand(
        'command script add -f BreakOnMethod.breakonmethod bom')

akd应该是个守护进程,本身没有加载UIKit。可以尝试用这种方法加载一下

感谢回复

还是会报错

然后设备的日志
14:30:01 akd➜(null): unrecognized selector sent to class 0x3b18e6f0

那估计是daemon无法使用UIKit吧,只能另请高明了;为啥不直接class-dump一下呢,非要纠结使用这个函数?

已经class-dump 过了, 只是看到这个东西,想学习一下:star_struck:

哥们这个解决了吗 我lldb进断点之后 :po [[$r2 object] copyAllMessages] 也爆这个错‘Execution was interrupted, reason: internal ObjC exception …’。

没解决, 我放弃了

标记一下.方便多了

可以使用,就是不知道为什么我放开进程,点击程序的时候就闪退了Process 1005 exited with status = 0 (0x00000000)

大佬,搞ios的 学习这个要怎么学啊 ,有书或者视频推荐吗

image 不知道为啥

这个我写着玩的有问题,你用它们做的版本就行了。上面也有其他人给我提的bug