吾爱破解 - LCG - LSG |安卓破解|病毒分析|www.52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 14816|回复: 34
收起左侧

[Android 原创] android调试:敲牛逼的frida弥补arm架构下无法设置硬件读写断点的缺陷

  [复制链接]
salala159 发表于 2019-1-13 22:09
本帖最后由 salala159 于 2019-1-13 22:50 编辑

废话不多说,开门见山,上干货,原理请自行百度:
function set_read_write_break(addr, size, pattern)
{
        //设置异常
    Process.setExceptionHandler(function(details){
                //打印信息,e.g. 打印堆栈,打印发生异常的地址,打印引发异常的地址
                /*
                        type: string specifying one of:
                                abort
                                access-violation
                                guard-page
                                illegal-instruction
                                stack-overflow
                                arithmetic
                                breakpoint
                                single-step
                                system
                        address: address where the exception occurred, as a NativePointer
                        memory: if present, is an object containing:
                                operation: the kind of operation that triggered the exception, as a string specifying either read,  write, or execute
                                address: address that was accessed when the exception occurred, as a NativePointer
                        context: object with the keys pc and sp, which are NativePointer objects specifying EIP/RIP/PC and ESP/RSP/SP, respectively, for ia32/x64/arm. Other processor-specific keys are also available, e.g. eax, rax, r0, x0, etc. You may also update register values by assigning to these keys.
                        nativeContext: address of the OS and architecture-specific CPU context struct, as a NativePointer. This is only exposed as a last resort for edge-cases where context isn’t providing enough details. We would however discourage using this and rather submit a pull-request to add the missing bits needed for your use-case.               
                                       
                */
                console.log(details.address)
               
                //处理异常
                Memory.protect(address, size, 'rwx')
                return true;
        })
        //制造异常 <--> 设置读写断点
        Memory.protect(address, size, pattern)
}

//举例
set_read_write_break(ptr(0x0E001250, 4 'rx')) //0x0E001250地址位于数据区,在0x0E001250设置一个4字节的写断点
set_read_write_break(ptr(0x0E001250, 4 'wx')) //0x0E001250地址位于数据区,在0x0E001250设置一个4字节的读断点
set_read_write_break(ptr(0x00c0452c, 4 'rw')) //0x00c0452c地址位于代码区,在0x00c0452c设置一个4字节的执行断点,可以代替F2软断点,可以过断点crc校验

另外,也可以开frIDA CLI,再开IDA调试so文件,仅使用Memory.protect(address, size, pattern)来下断点,不使用frida捕获,IDA自己捕获异常,看个人喜好了。这里要注意一定要先开frida CLI挂载到进程,然后在使用IDA挂载,顺序反了,可能挂载不上。
最后,请叫我frida小王子,下次高兴了放出利用frida制作一个类似CE内存搜索的工具的实例代码,效率绝对高。

免费评分

参与人数 5吾爱币 +13 热心值 +5 收起 理由
arking + 1 + 1 谢谢@Thanks!
qtfreet00 + 9 + 1 感谢发布原创作品,吾爱破解论坛因你更精彩!
幻象 + 1 + 1 感谢发布原创作品,吾爱破解论坛因你更精彩!
朮小凯 + 1 + 1 谢谢@Thanks!
笙若 + 1 + 1 谢谢@Thanks!

查看全部评分

本帖被以下淘专辑推荐:

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

笙若 发表于 2019-1-13 22:18
虽然没看懂,但是感觉就很厉害
havenow 发表于 2021-3-14 15:33
代码的注释应该是有问题的
set_read_write_break(ptr(0x0E001250, 4 'rx')) //0x0E001250地址位于数据区,在0x0E001250设置一个4字节的写断点

看看mprotect函数,改变的是PAGE_SIZE大小的内存,而不是4字节
楼主的代码实用性其实没什么实用性
朮小凯 发表于 2019-1-13 22:41
lucky_fish 发表于 2019-1-13 22:48
等待大侠的arm CE 内存搜索存储或显示工具!
gooool 发表于 2019-1-14 00:06
谢谢楼主.学习了.
罗茂松 发表于 2019-1-14 00:17
这个可以有
幻象 发表于 2019-1-14 08:12 来自手机
小王子小王子,开花开花
voodoo2 发表于 2019-1-14 08:29
谢谢楼主分享,学习了.
chenyuning2010 发表于 2019-1-14 08:48
感谢楼主热心分享教程
ruphay 发表于 2019-1-14 09:00
看到function,我就感觉迷了。。。自行百度去了。
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则 警告:本版块禁止灌水或回复与主题无关内容,违者重罚!

快速回复 收藏帖子 返回列表 搜索

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-4-26 04:50

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表