美文网首页
iOS-逆向17-LLDB

iOS-逆向17-LLDB

作者: 一亩三分甜 | 来源:发表于2021-06-23 01:12 被阅读0次

    《iOS底层原理文章汇总》
    上一篇文章《iOS-逆向16-Inlinehook》介绍了InlineHook,本文介绍LLDB。

    image

    1.LLDB

    I.breakpoint set -n test1相当于下了符号断点

    c表示continue,下一步继续执行


    图片.png
    图片.png
    image

    II.点击暂停键进入调试状态

    点击Debug View Hierarchy也能进入调试状态


    图片.png

    1.同时操作一组断点

    设置一组断点

    breakpoint set -n "-[ViewController save:]" -n "-[ViewController pause:]" -n "-[ViewController continueGame:]"
    
    image
    image

    禁用一组断点,是禁用状态但并不是删除状态

    breakpoint disable 1
    
    image

    2.操作一组断点中的某一个断点

    无法直接删除一组断点中的某一个断点,只能删除指定组不能删除组里面的某一个

    image
    增加两个断点后,分别是新增两组,若之前有添加和删除操作,则组号往上递增
    breakpoint delete 1
    image
    若在Xcode中打断点后,再通过指令设置断点,断点并不会重复,只会执行一次,同理删除也是

    3.查看帮助文档help breakpoint

    help breakpoint

    image

    设置所有包含touchesBegan:withEvent:方法断点

    breakpoint set -r touchesBegan:withEvent:
    
    image
    设置所有是touchesBegan:withEvent:方法断点
    图片.png
    删除全部断点breakpoint delete
    image
    指定文件设置断点
    breakpoint set --file ViewController.m --selector touchesBegan:withEvent:
    image
    缩写形式breakpoint set -r缩写为b -r
    b -r cloudTest
    图片.png
    b list设置了包含list函数断点,并不是breakpoint的简写
    image
    禁用断点
    break dis 1.2
    打开断点
    break en 1.2
    删除一组断点
    break delete 2

    III.代码执行

    expression指令等价于p


    image

    po是调用对象的description方法


    image
    断点动态添加数据
    p [self.models addObject:[[Person alloc]init]]

    po self.models


    图片.png
    获取动态添加的数据,p指令可以执行OC代码
    p (Person *)self.models.lastObject
    po $4.name
    image

    IV.指令控制堆栈

    up,down向上向下,select选择
    frame select 12


    图片.png

    查看变量frame variable,当前方法里面的变量


    image

    改变当前方法中变量的值
    p str = @"222",影响最后的输出的值


    image
    image
    在最近的输出方法中改变值cloudTest4后,跳入之前的方法cloudTest2中改变值并不会最后输出了,不会对最终的值有影响了
    image

    thread return直接返回,不执行后面的代码,提前返回,执行c指令,程序结束,不会再回去执行已经thread return的代码。调试绕过检测,将InlineHook和fishhook的代码直接绕过return;


    图片.png

    V.对象的属性下内存断点

    n表示单步往下走

    1.通过符号下内存断点,修改对象的属性时,触发内存断点,观察新值和旧值的变化

    watchpoint set variable p1->_name

    image
    图片.png

    2.通过地址下内存断点

    watchpoint set expression 0x00000001c402c330

    image
    image
    通过watchpoint delete 1
    image

    3.给某组设置表达式

    break command add 3
    (lldb) break command add 3
    Enter your debugger command(s). Type 'DONE' to end.

    frame variable
    DONE

    image
    image

    4.在断点时设置表达式

    target stop-hook add -o "frame variable"
    进入断点时会触发

    image
    查看所有的stop-hook
    target stop-hook list
    删除stop-hook
    target stop-hook delete 2或undisplay 1
    image
    配置所有工程的断点变量
    在根目录中新建.lldbinit文件
    增加指令target stop-hook add -o "frame variable"
    实际运行工程中遇到断点会打印
    image
    image

    相关文章

      网友评论

          本文标题:iOS-逆向17-LLDB

          本文链接:https://www.haomeiwen.com/subject/upyvyltx.html