在今年三月份的时候,我参加了腾讯游戏安全技术竞赛,到现在差不多快过去半年了,当时做这道安卓初赛题目时,也是卡在开头就毫无头绪了,而后看到看雪上的三位大佬|_|sher师傅,juice4fun师傅和fallw1nd师傅都分享了他们做这道题目时的解题过程,也是让我重拾了做出这道安卓初赛题的信心,因为需要分心在学习和其他事情上,所以从三月份到七月份也是陆陆续续复现了五个月,一路上走走停停
终于在八月份,我难能可贵的获得了整整一个月的充裕时间,这也让我可以好好去钻研这道对我来说难度极大的安卓题目了,解题的过程中基本上把我能想到的安卓逆向工具用了个遍,每当我在解题的过程中遇到瓶颈时,我总会把这三位大佬的writeup打开来反复观摩研究思考为什么要这样做,怎么做效果会更好
直到注册机写完之后纵观整个解题过程,真的是学到了很多
il2CppDumper是分析unity游戏的基础,能有好的开头全靠站在巨人的肩膀上
运行时解密so文件,让我首次尝试去手工修复dump下来的so
libsec2023.so中的反调试让我学会使用在安卓手机中断下硬件断点的工具rwProcMem33,也开始第一次编译安卓内核,经历了两三个不眠之夜
第一眼见到CSEL-BR和CSET-BR结构的花指令让我毫无头绪,也让我开始思考frida-stalker与unicorn的区别所在,最终我选择使用frida-stalker辅助分析,IDApython批量去花的方法,效果很好
BlackObfuscator混淆让我想起了被ollvm的控制流平坦化支配的恐惧,一筹莫展之际,这个月最新的工具Jeb5.1竟然能完美去除BlackObfuscator混淆,着实让我惊喜不已
在探索vm的过程,我也慢慢的摸索出了vm题型的解题方法,或许未来遇到vm我也能游刃有余了
前言写的有点长了,也算是我在这半年对于这道安卓题的感悟吧哈哈,虽然是安卓方向初赛题,但是对我整个安卓逆向的学习过程意义非凡,这篇文章我也写的尽可能的详细,前后的思维也尽量避免跳跃,每一步的操作基本上都是有据可依的,为之后也同样想要复现这道题目的朋友尽一点绵薄之力
题目可以在腾讯游戏安全竞赛官网下载 下载链接
看雪这里也上传了一份到附件里了
我在github里面也存了一份上去 下载链接
首先我们通过jadx反编译mouse_pre.aligned.signed.apk
,通过查看AndroidManifest.xml
可以知道下列关键信息
解压该apk,通过查看lib
文件夹内的内容,我们发现了libil2cpp.so
我们使用Il2CppDumper尝试解密global-metadata.dat
,但是却失败了
看了一下global-metadata.dat
是没有加密的
接下来我们用ida反编译libil2cpp.so
,发现被加密了
接下来我准备用frida来把解密后的libil2cpp.so
从内存中dump下来
但是当我用frida将代码注入进去后,apk提示hack detect
,然后就退出了
之后我不用frida注入这个apk,但是后台依旧运行着frida-server,apk依然弹出hack detect
后退出
通过这一点我大致可以判断它的检测方式有这两种可能
我们一个一个去验证一下
首先我们把后台运行的frida-server名称改成fs
试试
修改完后依旧弹出hack detect
那我们再去试一试修改frida-server的端口
端口修改之后用frida注入也不弹窗了
现在我们可以用frida把解密后的libil2cpp.so
dump下来,脚本如下
在使用frida运行脚本之前需要注意去做一下端口转发
随后进行frida注入
直接把dump下来的libil2cpp.so
放到Il2CppDumper中,成功获取符号
对于dump下来的so文件,所有的段(segment)和节(section)的偏移都是在虚拟空间中的偏移(即映射到进程空间的虚拟地址偏移),但静态分析工具分析so时所使用的偏移仍然为在实际文件中的偏移(即相对于文件开头的字节偏移量),错误的偏移导致静态分析工具如IDA等无法分析dump下来的so
所以我们需要将segment
和section
在实际文件中的偏移替换为在虚拟空间中的偏移,这些偏移由program header table
和secion header table
内的成员指出
我们将libil2cpp.so
和libil2cpp.so_0x712a997000_0x13cc000.so
一并拖入010 editor
中,两个文件相互对比进行修复
在010editor
中复制一个成员的值到另一个成员中,只需要在软件界面的Template Results
中单击想要复制的值按下Ctrl
+Shift
+C
,然后单击需要替换的值,按下Ctrl
+Shift
+V
即可完成替换
段(segment) 的位置和大小由程序头表(Program Header Table)中的这四个成员决定
在libil2cpp.so_0x712a997000_0x13cc000.so
中我们将program_header_table
中每一个element
的p_vaddr_VIRTUAL_ADDRESS
的值复制到p_offset_FROM_FILE_BEGIN
,p_memsz_SEGMENT_RAM_LENGTH
的值复制到p_filesz_SEGMENT_FILE_LENGTH
节头表(secion header table)的位置在最后一个段(segment)之后,我们可以从ELF文件的Execution View直观看出
由下图所示,libil2cpp.so_0x712a997000_0x13cc000.so
中section_header_table
在实际文件中的偏移为0x11AB778
,我们需要将其修改为在虚拟空间中的偏移,这个值为0x13CB778
,计算过程如下,此处所涉及计算的成员的值是在program_header_table
的最后一个element
,即program_table_entry64_program_table_element[10]
Section Header Table和Program Header Table并不是一定要位于文件开头和结尾的,其位置由ELF Header
指出
决定section_header_table
起始地址的成员为elf_header->e_shoff_SECTION_HEADER_OFFSET_IN_FILE
,位置如下图所示,在修改完成后,按下F5
重新运行模板ELF.bt
在我们修正 节头表(secion header table) 的偏移后,节头表所在的区域是没有内容的,如下图所示,所以需要从libil2cpp.so
中复制节(section)的内容到dump下来的so中
我们在libil2cpp.so
点击struct section_header_table
并按下Ctrl
+Shift
+C
,然后回到libil2cpp.so_0x712a997000_0x13cc000.so
中,选中section_header_table
然后按下Ctrl
+Shift
+V
,按下F5
重新运行模板ELF.bt
可以发现修补了节(section)的内容之后,section的名称依旧是乱码
这是什么原因呢?
ELF
文件中的每个section
都是有名字的,比如.data
、.text
、.rodata
,每个名字都是一个字符串,既然是字符串就需要一个字符串池来保存,而这个字符串池也是一个section
,或者说准备一个section
用来维护一个字符串池,这个字符串池保存了其他section以及它自己的名字。这个特殊的section叫做.shstrtab
,所有section
的头部是连续存放在一起的,类似一个数组,e_shstrndx
变量是.shstrtab
在这个数组中的下标。
首先我们要明白section的名称是如何通过索引找到的,在libil2cpp.so_0x712a997000_0x13cc000.so
中,找到elf_header->e_shtrndx_STRING_TABLE_INDEX
,这个的值为26(0x1A),说明了section_header_table->section_table_element[26]
存储了所有section的名称
section_header_table->section_table_element[26]
中s_offset
的值决定了section的名称将从1199370h
去索引
我们可以在dump前后的libil2cpp.so
都跳转到这个地址去看看,在010editor
中进行地址跳转只需右键该值选择Goto Address
即可
section的所有名称都在这个地方
之后我们要将section
的符号名称从原来的so复制到dump下来的so里面,位置就是我们之前分析出来的section_table_element[26]
中s_offset
所指向的物理内存地址,即选中libil2cpp.so
从0x1199370h
到0x1199470h
按下Ctrl
+Shift
+C
,然后将光标移动到libil2cpp.so_0x712a997000_0x13cc000.so
的119A370h
处,按下Ctrl
+Shift
+V
节(section) 的位置和大小由节头表(secion_header_table)中这两个成员决定
修正 节(section) 的偏移有两条规则
修正完成后,按下F5
重新运行模板ELF.bt
,可以发现section的名称已经恢复,同时也有了dynamic_symbol_table
然后,我们将libil2cpp.so_0x712a997000_0x13cc000.so
拖入IDA
中进行分析,待分析完成后,点击如图所示的选项重新定位基址为0x712a997000
,这样可以分析出更多的符号
之后,我们点击File->Script file...
运行il2cppdumper
中的ida_with_struct_py3.py
,需要注意的这个脚本需要运行两次,第一次选择script.json
,第二次选择il2cpp.h
处理之后的效果如下
接下来需要知道这个OK
按钮调用的函数
我们可以使用这个工具frida-il2cppDumper,用法就直接用frida注入_agent.js
就可以了
当我们进入该apk之后,下列函数被调用
我们去看一下最后调用的这个函数oO0oOo0
,进入IDA
去进行分析,很明显是生成TOKEN的地方
当我们点击小键盘上的OK按钮后,下列函数被调用,由于调用的函数太多,我这里仅仅从首次调用的函数开始,截取了部分输出作为示例
SmallKeyboard
类被调用了很多次,我们可以去dump.cs
里面搜索一下,此处定义了KeyType
不同的值对应的含义,那么这个EnterKey
就是OK
按钮了
回到IDA
,我们再去搜索一下SmallKeyboard
,找到SmallKeyboard__iI1Ii(SmallKeyboard_o *this, SmallKeyboard_iII1i_o *info, const MethodInfo *method)
这个函数,这是与KeyType
有关的函数,显而易见,我们需要重点分析的是KeyType == 2
的情况
对于这行代码,我的猜测是v13
存储了我输入的值,我们可以使用frida
去hookSystem_Convert__ToUInt64_486054767044
的返回值来验证我们的猜想
当我输入123456
,并点击OK
按钮后,frida的回显如下,可以印证我们的猜测是正确的,v13是我们输入的数字
v13
作为参数传入了SmallKeyboard__iI1Ii_486050613936
内,那么这应该就是我们要寻找的加密逻辑
经过两个B跳转后,我们来到了这里
这段汇编很有意思,我们去分析一下,off_712BD51FF0
存储的是导入函数g_sec2023_p_array
的地址,而g_sec2023_p_array
的函数定义在libsec2023.so
中,BR
指令是无条件寄存器跳转,那么这四行arm汇编的意义就是调用g_sec2023_p_array
偏移0x48
处的函数
来到libsec2023.so
我们即可找到相对应的导出函数sub_31164
那么显而易见,关键的逻辑就在libsec2023.so
中的sub_31164
了
对libsec2023.so
的sub_31164
hook一下
但是当我注入将这段frida代码注入到libsec2023.so
后,程序在短暂的延迟后显示hack detect后退出了
我们可以使用frida Stalker
来查看这个so
调用函数的过程
为了使用上的方便,我写了一个IDA插件来实现下面的过程,插件地址:https://github.com/oacia/stalker_trace_so,这应该算是我第一次造轮子吧:)
首先使用如下idaPython
脚本打印出libsec2023.so
的所有函数的地址和名称
将上面IDApython所打印出的内容填入下面frida
代码的变量func_addr
和func_name
中
打开apk后frida输出如下
这里需要用到的工具是rwprocmem33
,具体的编译和使用可以在我写的另一篇文章进行阅读,这里不在过多赘述
运行下面的frida代码获取libsec2023.so
的基址
利用下面的命令获取进程的PID
将得到的参数填入rwprocmem33
中
首先对我们最感兴趣的libil2cpp.so
调用的libsec2023.so
的导出函数sub_35404
下硬件断点看看,毕竟之前我们用frida去hook这个函数失败了嘛,硬件断点下的位置可以通过基址(base)+偏移(func offset)得到
结果如下
仅仅下了五秒的硬件断点,相同地址的命中次数进入达到了百万次
我们再对不同的地址打下硬件断点看看,发现均只有一个命中地址,并且命中次数都达到百万次
与基址相减得到偏移为0x37704
进入ida查看sub_37704
函数,代码很短,按下交叉引用也没有输出
这该怎么办呢?
还记得上面我们曾用frida-stalker
打印出了libsec2023.so
函数的调用链嘛,我们从sub_37704
向上回溯看看
sub_37704
是被sub_376CC
调用的,sub_376CC
中的这个BR
跳转应该是调用了sub_37704
再看调用sub_376CC
的函数sub_371AC
,在这个函数中,我们发现了一条有趣的指令,CSEL
熟悉arm指令集的朋友肯定知道,CSEL
是arm中的分支结构指令,而BR
跳转的位置由X8
决定,所以这段汇编便可以改变便程序控制流
CSEL X8, X8, X9, EQ
中,EQ
表示Equal
,即相等条件,其值由最近的CMP的比较后得出的值决定,例如此处判断的条件就是CMP W0, W8
用c语言来表示就是
而X8
和X9
相差0x10
,X8
的修改便导致了控制流的改变
为了不让控制流转向错误的分支导致frida注入后强制退出,我们可以对此处的汇编进行patch,将CSEL X8, X8, X9, EQ
改为CSEL X8, X8, X8, EQ
,即将汇编08 01 89 9A
修改为08 01 88 9A
但是要怎么让apk运行我们patch过后的libsec2023.so
呢?
有以下的三种思路可以参考
前两种方法经过尝试均以失败告终,那么现在只剩下最后一种方法了,就是在libsec2023.so
加载之后动态patch,而这利用frida可以说简直就是轻而易举,利用Memory.writeByteArray
就可以做到
运行rpc.exports.anti_sec2023()
的时机是在打开apk之后
之后再次尝试对sub_31164
附加钩子
这一次,钩子成功附加上去了!
sub_31164
首先调用了sub_3B8CC
,那我们就就去分析一下sub_3B8CC
往下看最后一行汇编是是BR X8
,我们看看BR
表示的意思是什么
BR: 跳转到某寄存器(的值)指向的地址(无返回), 不会改变 lr (x30) 寄存器的值。
寄存器跳转的存在严重的阻碍了我们的逆向分析,那我们试试能不能稍稍修改一下
我们可以使用frida-stalker
来追踪寄存器的值(绝对不是因为我用不来unicorn
才用frida
的(真的)
起初我是直接准备patch内存中的指令的,代码也写的差不多了(现在被注释了),没想到这寄存器跳转会有两种情况,没办法改成B
跳转,不然进程会崩溃掉,所以就打印出跳转的地址手工分析咯
运行代码后,程序输出如下
我们不妨以地址0x3ba70
作为分析的示例,这里我们发现0x3ba70
会跳转的地址有两种情况,分别是0x3ba34
和0x3ba74
等等,0x3ba74
??这不就是0x3ba70
之后要执行的指令吗?
那结果显而易见了,这BR
寄存器跳转的前身肯定就是条件跳转,BGE
,BLE
这类的指令
接下来就是在IDA里面修复控制流咯,我们修复一下0x3ba00
这个第一个BR
跳转的地方,别的地方的思想都是一样的
进入到off_72C40
,加上W11
得到正确的跳转,写了个简单的python脚本输出hex方便直接复制进去
这个地方修复完是这样的,可以看到*(off_72C40+0)
和*(off_72C40+0x28)
的地方值已经被我加上去了
接下来就是改是汇编了,ADD指令我们肯定是不需要了,因为已经被我们加上去了,所以接下来继续往下走看的是这条CSEL X10, XZR, X9, CC
指令
各个条件码的含义如下
那么这里BR
分支跳转的意思就可以表示为
所以这里改成BGE
,然后把不需要的指令NOP
掉,一处地方就修复好啦
还要注意的是,除了CSEL-BR
结构之外,还有CSET-BR
结构
CSET: 比较指令,满足条件,则并置 1,否则置 0 ,如:
和CSEL-BR
结构的修复思路是相似的,对于上图(0x3B95C
处)的CSET-BR
结构,我们仅需关注这几行指令
其中的LDR X8, [X21,W23,UXTW#3]
的含义可以用C语言这样表示X8 = *(X21 + (W23 << 3))
,UXTW#3
即将操作数左移三位的意思
这样一个一个修复过去,未免也太麻烦了,那索性就写个idapython脚本一键去除CSEL-BR
和CSET-BR
结构来解放双手吧哈哈
第一个加密函数sub_3B9D4
取出数据的每一位进行加密,其中出现的HIBYTE
, BYTE2
, BYTE1
,LOBYTE
含义如下,假设有数据a1=0x12345678
,则
我们可以使用frida去hooksub_3B9D4
传入的值以及返回值,观察加密前后的变化,假设我此处在小键盘输入的数字是999999999999
,hex(999999999999)=0xe8d4a50fff
于是第一个算法如下
在对输入的值进行首轮加密之后,又再次对输入值经过bswap32
函数加密
这个函数对应的arm汇编为
那我们去arm手册看看REV
指令的定义好了
REV
Byte-Reverse Word reverses the byte order in a 32-bit register.
Operation
看Operation
很清楚的知道这就是反转字节,比如
所以此处bswap32(v6)
,是对v6
进行字节翻转,而v6 = HIDWORD(a1)
,故在进行第一个加密函数sub_3B9D4
之后,将首先对输入的高32位进行加密处理,这在我们后续hook第二个加密函数sub_3A924
之后,也可以体现出来这一点
我们首先hook一下sub_3A924
让前后分析的逻辑连贯起来
在经过第一轮加密后,我们得到了密文cc ca 94 6d e3 d5 39 39
,而在此处,第一次调用sub_3A924
的输入为6d 94 ca cc
,第二次调用sub_3A924
的输入为39 39 d5 e3
,正好对应了上文提到的翻转字节处理
我们进入该函数后,发现如v11+1408LL
,v11 + 1664LL
等等的fastcall
函数调用,一般这种形式的函数调用在安卓逆向中遇到的话,那大概率就是JNIEnv *
在此题中,我们只需要对v11
按下Y
切换类型,然后输入JNIEnv *
,就会转换成JNIEnv *
的结构体函数指针如图
在这里出现了jni
函数GetStaticMethodID
,我们hook一下这个函数观察调用了什么方法
在输出中,我们发现GetStaticMethodID
调用了名为encrypt
的方法
但是我们在apk中却并未发现该方法
那么由此就可以推断出这个方法是由dex动态加载的
我们可以使用frida-dexdump来把内存中的dex给dump下来,要注意frida的端口已经被我们修改为了1234
,所以这里也要加上-H
参数
将所有dex dump下来之后,接下来的步骤就是把这些dex一个一个拖进jadx里面反编译,去看看哪一个dex包含encrypt
方法
这个控制流一眼看上去就是加了混淆的,据FallW1nd师傅说是BlackObfuscator
混淆,本来准备去手工分析的,但是想起前几天刚下载了Jeb5.1,就想看看新工具的效果怎样
当我用Jeb5.1反编译这个dex之后,这BlackObfuscator
混淆怎么就直接去除了????
好家伙这Jeb5.1竟然能自动去除控制流平坦化,crazy!
那么这第二个加密的逻辑相当的清晰,算法如下
我们可以hook一下第二次加密前后输入的变化
我们在sub_31164
中去hook最后的br x2
跳转来观察之后跳转到了哪一个函数中
可见在libsec2023.so
中经过两次加密之后,apk回到了libil2cpp.so
中
偏移0x138d64
加上原来so的基址后,定位到了这个地方
B跳转过去发现并不是一个函数,而是FUNCTION CHUNK
那先修改一下.init_proc
的End address
然后回到之前chunk function
的位置,按下P
让IDA分析出函数,就可以看伪代码继续分析了
这个类的名称被o
,O
,0
给混淆了,导致难以分辨类和变量,所以需要为这些类和变量进行重命名
在看看其他函数,这最后的v6 + v8 + (v6 | ~v8) + (v8 ^ v6) - (v6 & ~v8) + 1
看起来是MBA表达式
在github找个工具GAMBA简化一下,有些表达式要分开简化效果才好,这里4294967296=0x100000000
已经溢出32位了,所以4294967296+v8=v8
重命名函数之后,很明显发现这个加密算法应该和VM指令相关
我们回到类的初始化函数ctor
完成之后,下一个要调用的函数OO0OoOOo_Oo0__oOOoO0o0
进入该函数,又是经典的while(1)
循环,那么在这个循环里面,必定会出现eip
和opcode
,这两个分别对应着this->fields.oOOO0Oo0
和U16_arr
,我们重命名之
之后,我们以add
函数为例分析其他全局变量的含义,这里对应的vm指令应该为add uS_arr[bbb], uS_arr[bbb], uS_arr[bbb+1]
到这里可能会有人纠结uS_arr
究竟代表寄存器还是代表栈呢?我们回到初始化函数中,发现变量bbb
所赋的初值为-1
,那么由此可以确定,uS_arr
代表的是栈,而bbb
则表示esp
至此为止,vm所需的关键变量我们均已经分析清楚了
接下来就可以分析vm虚拟机了,对于vm类题型,我们只需要找到vm指令中的加减乘除位运算的位置和输入输出是多少就够了,别的指令比如push
,pop
,mov
,opcode是多少,opcode是如何被vm读取等等这些问题都不需要考虑,因为在vm中,所有的vm指令的最终目的都是为了对输入的值进行操作,我们知道了这些加密运算,那么逆运算自然是信手拈来
所以在这里,我们可以用frida去hook一下运算相关的指令
输出以及分析如下
由此可见,这个vm其实相当的简单
这个算法一看就知道是xtea,那么需要知道的就只有v24
这个密钥了
用frida把密钥hook下来
再把xtea加密之后的值也顺便hook下来
那么这部分的算法如下
至此为止,所有加密算法分析完毕
在所有的加密完成后,这里的result
就是我们的token
,加密的低32位和token
比较,高32位和0
比较
ELF文件格式的详解
[原创]2023腾讯游戏安全竞赛初赛题解(安卓)
[原创]2023腾讯游戏安全大赛-安卓赛道初赛wp
[原创] 腾讯游戏安全技术竞赛2023 安卓客户端初赛WriteUp
ARMv8(aarch64)指令集特性
blueline:
/data/local/tmp
blueline:
/data/local/tmp
function
dump_so(so_name) {
Java.perform(
function
() {
var
currentApplication = Java.use(
"android.app.ActivityThread"
).currentApplication();
var
dir = currentApplication.getApplicationContext().getFilesDir().getPath();
var
libso = Process.getModuleByName(so_name);
console.log(
"[name]:"
, libso.name);
console.log(
"[base]:"
, libso.base);
console.log(
"[size]:"
, ptr(libso.size));
console.log(
"[path]:"
, libso.path);
var
file_path = dir +
"/"
+ libso.name +
"_"
+ libso.base +
"_"
+ ptr(libso.size) +
".so"
;
var
file_handle =
new
File(file_path,
"wb"
);
if
(file_handle && file_handle !=
null
) {
Memory.protect(ptr(libso.base), libso.size,
'rwx'
);
var
libso_buffer = ptr(libso.base).readByteArray(libso.size);
file_handle.write(libso_buffer);
file_handle.flush();
file_handle.close();
console.log(
"[dump]:"
, file_path);
}
});
}
rpc.exports = {
dump_so: dump_so
};
function
dump_so(so_name) {
Java.perform(
function
() {
var
currentApplication = Java.use(
"android.app.ActivityThread"
).currentApplication();
var
dir = currentApplication.getApplicationContext().getFilesDir().getPath();
var
libso = Process.getModuleByName(so_name);
console.log(
"[name]:"
, libso.name);
console.log(
"[base]:"
, libso.base);
console.log(
"[size]:"
, ptr(libso.size));
console.log(
"[path]:"
, libso.path);
var
file_path = dir +
"/"
+ libso.name +
"_"
+ libso.base +
"_"
+ ptr(libso.size) +
".so"
;
var
file_handle =
new
File(file_path,
"wb"
);
if
(file_handle && file_handle !=
null
) {
Memory.protect(ptr(libso.base), libso.size,
'rwx'
);
var
libso_buffer = ptr(libso.base).readByteArray(libso.size);
file_handle.write(libso_buffer);
file_handle.flush();
file_handle.close();
console.log(
"[dump]:"
, file_path);
}
});
}
rpc.exports = {
dump_so: dump_so
};
adb forward tcp:1234 tcp:1234
adb forward tcp:1234 tcp:1234
frida -H 127.0.0.1:1234 -l
"D:\frida\sec2023\global-metadata_dump.js"
-f
"com.com.sec2023.rocketmouse.mouse"
frida -H 127.0.0.1:1234 -l
"D:\frida\sec2023\global-metadata_dump.js"
-f
"com.com.sec2023.rocketmouse.mouse"
成员名称 |
含义 |
p_offset_FROM_FILE_BEGIN |
在实际文件中的偏移 |
p_vaddr_VIRTUAL_ADDRESS |
在虚拟空间中的偏移 |
p_filesz_SEGMENT_FILE_LENGTH |
在实际文件中的大小 |
p_memsz_SEGMENT_RAM_LENGTH |
在虚拟空间中的大小 |
成员名称 |
含义 |
s_addr |
如果此 section 需要映射到进程空间,此成员指定映射的起始地址;如不需映射,此值为 0 |
s_offset |
此 section 相对于文件开头的字节偏移量.如果 section 类型为 SHT_NOBITS ,表明该 section 在文件中不占空间,这时 sh_offset 没什么用 |
frida
-H
127.0.0.1:1234
-l
"D:\frida\frida-il2cppDumper-main\_agent.js"
-f
"com.com.sec2023.rocketmouse.mouse"
frida
-H
127.0.0.1:1234
-l
"D:\frida\frida-il2cppDumper-main\_agent.js"
-f
"com.com.sec2023.rocketmouse.mouse"
method call
nameSpaze: class:SmallKeyboard
methodPointer offset
in
IDA:466300
public Void .ctor(){ }
method
end
-----------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------
method call
nameSpaze: class:iII1i
methodPointer offset
in
IDA:4663A8
public Void .ctor(){ }
method
end
-----------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------
method call
nameSpaze: class:iII1i
methodPointer offset
in
IDA:4663A8
public Void .ctor(){ }
method
end
-----------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------
method call
nameSpaze: class:iII1i
methodPointer offset
in
IDA:4663A8
public Void .ctor(){ }
method
end
-----------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------
method call
nameSpaze: class:iII1i
methodPointer offset
in
IDA:4663A8
public Void .ctor(){ }
method
end
-----------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------
method call
nameSpaze: class:iII1i
methodPointer offset
in
IDA:4663A8
public Void .ctor(){ }
method
end
-----------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------
method call
nameSpaze: class:iII1i
methodPointer offset
in
IDA:4663A8
public Void .ctor(){ }
method
end
-----------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------
method call
nameSpaze: class:iII1i
methodPointer offset
in
IDA:4663A8
public Void .ctor(){ }
method
end
-----------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------
method call
nameSpaze: class:iII1i
methodPointer offset
in
IDA:4663A8
public Void .ctor(){ }
method
end
-----------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------
method call
nameSpaze: class:iII1i
methodPointer offset
in
IDA:4663A8
public Void .ctor(){ }
method
end
-----------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------
method call
nameSpaze: class:iII1i
methodPointer offset
in
IDA:4663A8
public Void .ctor(){ }
method
end
-----------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------
method call
nameSpaze: class:iII1i
methodPointer offset
in
IDA:4663A8
public Void .ctor(){ }
method
end
-----------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------
method call
nameSpaze: class:iII1i
methodPointer offset
in
IDA:4663A8
public Void .ctor(){ }
method
end
-----------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------
method call
nameSpaze: class:SmallKeyboard
methodPointer offset
in
IDA:46618C
private Void Start(){ }
method
end
-----------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------
method call
nameSpaze: class:SmallKeyboard
methodPointer offset
in
IDA:465E90
private Void oO0oOo0(){ }
method
end
method call
nameSpaze: class:SmallKeyboard
methodPointer offset
in
IDA:466300
public Void .ctor(){ }
method
end
-----------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------
method call
nameSpaze: class:iII1i
methodPointer offset
in
IDA:4663A8
public Void .ctor(){ }
method
end
-----------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------
method call
nameSpaze: class:iII1i
methodPointer offset
in
IDA:4663A8
public Void .ctor(){ }
method
end
-----------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------
method call
nameSpaze: class:iII1i
methodPointer offset
in
IDA:4663A8
public Void .ctor(){ }
method
end
-----------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------
method call
nameSpaze: class:iII1i
methodPointer offset
in
IDA:4663A8
public Void .ctor(){ }
method
end
-----------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------
method call
nameSpaze: class:iII1i
methodPointer offset
in
IDA:4663A8
public Void .ctor(){ }
method
end
-----------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------
method call
nameSpaze: class:iII1i
methodPointer offset
in
IDA:4663A8
public Void .ctor(){ }
method
end
-----------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------
method call
nameSpaze: class:iII1i
methodPointer offset
in
IDA:4663A8
public Void .ctor(){ }
method
end
-----------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------
method call
nameSpaze: class:iII1i
methodPointer offset
in
IDA:4663A8
public Void .ctor(){ }
method
end
-----------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------
method call
nameSpaze: class:iII1i
methodPointer offset
in
IDA:4663A8
public Void .ctor(){ }
method
end
-----------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------
method call
nameSpaze: class:iII1i
methodPointer offset
in
IDA:4663A8
public Void .ctor(){ }
method
end
-----------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------
method call
nameSpaze: class:iII1i
methodPointer offset
in
IDA:4663A8
public Void .ctor(){ }
method
end
-----------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------
method call
nameSpaze: class:iII1i
methodPointer offset
in
IDA:4663A8
public Void .ctor(){ }
method
end
-----------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------
method call
nameSpaze: class:SmallKeyboard
methodPointer offset
in
IDA:46618C
private Void Start(){ }
method
end
-----------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------
method call
nameSpaze: class:SmallKeyboard
methodPointer offset
in
IDA:465E90
private Void oO0oOo0(){ }
method
end
method call
nameSpaze: class:<>c__DisplayClass14_0
methodPointer offset
in
IDA:4663B0
internal Void <Start>b__0(){ }
method
end
-----------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------
method call
nameSpaze: class:SmallKeyboard
methodPointer offset
in
IDA:465FDC
private Void iI1Ii(GameObject go) { }
method
end
-----------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------
method call
nameSpaze: class:SmallKeyboard
methodPointer offset
in
IDA:465880
private Void iI1Ii(iII1i _info) { }
method
end
-----------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------
method call
nameSpaze: class:SmallKeyboard
methodPointer offset
in
IDA:465AB0
private Void iI1Ii(UInt64 i1I) { }
method
end
-----------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------
method call
nameSpaze:OO0OoOOo class:Oo0
methodPointer offset
in
IDA:4660E8
public Void .ctor(UInt16[] OoOOO00, Int32 oOOO0O0O, UInt32[] OOoOO0) { }
method
end
-----------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------
method call
nameSpaze:OO0OoOOo class:Oo0
methodPointer offset
in
IDA:46A55C
private Void O000O000000o(){ }
method
end
-----------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------
method call
nameSpaze:OO0OoOOo class:oO0OoOOo
methodPointer offset
in
IDA:46A4D8
private Void .cctor(){ }
method
end
-----------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------
method call
nameSpaze:OO0OoOOo class:Oo0
methodPointer offset
in
IDA:46AD44
private Void oOOoO0o0(){ }
method
end
-----------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------
method call
nameSpaze:OO0OoOOo class:Oo0
methodPointer offset
in
IDA:46B578
private Void O00O00000o(){ }
method
end
method call
nameSpaze: class:<>c__DisplayClass14_0
methodPointer offset
in
IDA:4663B0
internal Void <Start>b__0(){ }
method
end
-----------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------
method call
nameSpaze: class:SmallKeyboard
methodPointer offset
in
IDA:465FDC
private Void iI1Ii(GameObject go) { }
method
end
-----------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------
method call
nameSpaze: class:SmallKeyboard
methodPointer offset
in
IDA:465880
private Void iI1Ii(iII1i _info) { }
method
end
-----------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------
method call
nameSpaze: class:SmallKeyboard
methodPointer offset
in
IDA:465AB0
private Void iI1Ii(UInt64 i1I) { }
method
end
-----------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------
method call
nameSpaze:OO0OoOOo class:Oo0
methodPointer offset
in
IDA:4660E8
public Void .ctor(UInt16[] OoOOO00, Int32 oOOO0O0O, UInt32[] OOoOO0) { }
method
end
-----------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------
method call
nameSpaze:OO0OoOOo class:Oo0
methodPointer offset
in
IDA:46A55C
private Void O000O000000o(){ }
method
end
-----------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------
method call
nameSpaze:OO0OoOOo class:oO0OoOOo
methodPointer offset
in
IDA:46A4D8
private Void .cctor(){ }
method
end
-----------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------
method call
nameSpaze:OO0OoOOo class:Oo0
methodPointer offset
in
IDA:46AD44
private Void oOOoO0o0(){ }
method
end
-----------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------
method call
nameSpaze:OO0OoOOo class:Oo0
methodPointer offset
in
IDA:46B578
private Void O00O00000o(){ }
method
end
function
hook_native(){
Java.perform(
function
()
{
var
module = Process.getModuleByName(
"libil2cpp.so"
)
var
addr=module.base.add(
"0x85b9c4"
);
var
func =
new
NativePointer(addr.toString());
console.log(
'[+] hook '
+func.toString())
Interceptor.attach(func, {
onEnter:
function
(args) {
console.log(
'hook success'
);
console.log(args[0]);
console.log(args[1]);
},
onLeave:
function
(retval) {
console.log(
"retvalue is :"
, retval.toInt32());
console.log(
'method onleave'
);
}
});
});
}
setImmediate(
function
(){
setTimeout(hook_native, 1000);
},0);
function
hook_native(){
Java.perform(
function
()
{
var
module = Process.getModuleByName(
"libil2cpp.so"
)
var
addr=module.base.add(
"0x85b9c4"
);
var
func =
new
NativePointer(addr.toString());
console.log(
'[+] hook '
+func.toString())
Interceptor.attach(func, {
onEnter:
function
(args) {
console.log(
'hook success'
);
console.log(args[0]);
console.log(args[1]);
},
onLeave:
function
(retval) {
console.log(
"retvalue is :"
, retval.toInt32());
console.log(
'method onleave'
);
}
});
});
}
setImmediate(
function
(){
setTimeout(hook_native, 1000);
},0);
function
hook_sub_31164(){
Java.perform(
function
()
{
var
module = Process.getModuleByName(
"libsec2023.so"
)
var
addr=module.base.add(
"0x31164"
);
var
func =
new
NativePointer(addr.toString());
console.log(
'[+] hook '
+func.toString())
Interceptor.attach(func, {
onEnter:
function
(args) {
console.log(
'hook success'
);
console.log(args[0]);
console.log(args[1]);
console.log(args[2]);
},
onLeave:
function
(retval) {
console.log(
"retvalue is :"
, retval.toInt32());
console.log(
'method onleave'
);
}
});
});
}
rpc.exports = {
hook_sub_35404: hook_sub_35404
}
function
hook_sub_31164(){
Java.perform(
function
()
{
var
module = Process.getModuleByName(
"libsec2023.so"
)
var
addr=module.base.add(
"0x31164"
);
var
func =
new
NativePointer(addr.toString());
console.log(
'[+] hook '
+func.toString())
Interceptor.attach(func, {
onEnter:
function
(args) {
console.log(
'hook success'
);
console.log(args[0]);
console.log(args[1]);
console.log(args[2]);
},
onLeave:
function
(retval) {
console.log(
"retvalue is :"
, retval.toInt32());
console.log(
'method onleave'
);
}
});
});
}
rpc.exports = {
hook_sub_35404: hook_sub_35404
}
import
idautils
import
idc
func_addr
=
[]
func_name
=
[]
for
i
in
idautils.Functions():
func_addr.append(i)
func_name.append(idc.get_func_name(i))
for
i
in
func_addr:
print
(f
"{hex(i)}, "
,end
=
'')
print
('')
for
i
in
func_name:
print
(f
"\"{i}\", "
,end
=
'')
import
idautils
import
idc
func_addr
=
[]
func_name
=
[]
for
i
in
idautils.Functions():
func_addr.append(i)
func_name.append(idc.get_func_name(i))
for
i
in
func_addr:
print
(f
"{hex(i)}, "
,end
=
'')
print
('')
for
i
in
func_name:
print
(f
"\"{i}\", "
,end
=
'')
var
func_addr = [...]
var
func_name = [...]
function
hook_dlopen(soName =
''
) {
Interceptor.attach(Module.findExportByName(
null
,
"android_dlopen_ext"
),
{
onEnter:
function
(args) {
var
pathptr = args[0];
if
(pathptr !== undefined && pathptr !=
null
) {
var
path = ptr(pathptr).readCString();
if
(path.indexOf(soName) >= 0) {
this
.is_can_hook =
true
;
}
}
},
onLeave:
function
(retval) {
if
(
this
.is_can_hook) {
var
times = 1;
var
module = Process.getModuleByName(
"libsec2023.so"
);
this
.pid = Process.getCurrentThreadId();
console.log(
"start Stalker!"
);
Stalker.follow(
this
.pid,{
events:{
call:
false
,
ret:
false
,
exec:
false
,
block:
false
,
compile:
false
},
onReceive:
function
(events){
},
transform:
function
(iterator) {
var
instruction = iterator.next();
do
{
if
(func_addr.indexOf(instruction.address - module.base) != -1){
console.log(
"call"
+ times+
":"
+ func_name[func_addr.indexOf(instruction.address - module.base)])
times=times+1
}
iterator.keep();
}
while
((instruction = iterator.next()) !==
null
);
},
onCallSummary:
function
(summary){
}
});
console.log(
"Stalker end!"
);
}
}
}
);
}
setImmediate(hook_dlopen,
"libsec2023.so"
)
var
func_addr = [...]
var
func_name = [...]
function
hook_dlopen(soName =
''
) {
Interceptor.attach(Module.findExportByName(
null
,
"android_dlopen_ext"
),
{
onEnter:
function
(args) {
var
pathptr = args[0];
if
(pathptr !== undefined && pathptr !=
null
) {
var
path = ptr(pathptr).readCString();
if
(path.indexOf(soName) >= 0) {
this
.is_can_hook =
true
;
}
}
},
onLeave:
function
(retval) {
if
(
this
.is_can_hook) {
var
times = 1;
var
module = Process.getModuleByName(
"libsec2023.so"
);
this
.pid = Process.getCurrentThreadId();
console.log(
"start Stalker!"
);
Stalker.follow(
this
.pid,{
events:{
call:
false
,
ret:
false
,
exec:
false
,
block:
false
,
compile:
false
},
onReceive:
function
(events){
},
transform:
function
(iterator) {
var
instruction = iterator.next();
do
{
if
(func_addr.indexOf(instruction.address - module.base) != -1){
console.log(
"call"
+ times+
":"
+ func_name[func_addr.indexOf(instruction.address - module.base)])
times=times+1
}
iterator.keep();
}
while
((instruction = iterator.next()) !==
null
);
},
onCallSummary:
function
(summary){
}
});
console.log(
"Stalker end!"
);
}
}
}
);
}
setImmediate(hook_dlopen,
"libsec2023.so"
)
call1:JNI_OnLoad
call2:sub_FF14
call3:.memset
call4:.vsnprintf
call5:.
time
call6:.localtime
call7:.__android_log_print
call8:sub_10070
call9:.fopen
call10:sub_21000
call11:.pthread_once
call12:sub_21054
call13:sub_412CC
call14:.malloc
call15:sub_21098
call16:sub_FABC
call17:sub_1010C
call18:sub_10194
call19:sub_11C4C
call20:.pthread_mutex_init
call21:sub_103D0
call22:sub_2BCA8
call23:sub_125E4
call24:sub_12660
call25:sub_1CE70
call26:sub_1CE34
call27:sub_1C664
call28:.pthread_mutex_lock
call29:.pthread_mutex_unlock
call30:.strlen
call31:sub_125F0
call32:sub_1D998
call33:sub_2C67C
call34:sub_2C40C
call35:.__strlcpy_chk
call36:.__strlen_chk
call37:sub_11BC4
call38:sub_2CCC0
call39:sub_355F0
call40:sub_35630
call41:sub_356C4
call42:sub_35700
call43:sub_11DF0
call44:sub_35870
call45:sub_36940
call46:sub_36B34
call47:sub_36B9C
call48:sub_36BC8
call49:sub_36BF0
call50:sub_36E00
call51:sub_36E70
call52:sub_36ED0
call53:sub_36F00
call54:sub_36F3C
call55:nullsub_17
call56:sub_36C8C
call57:sub_36CB8
call58:sub_2E318
call59:sub_2E288
call60:sub_2D590
call61:sub_1F450
call62:sub_20FD0
call63:.fstat
call64:sub_2DB5C
call65:sub_1FE3C
call66:sub_1FB70
call67:.sscanf
call68:sub_200C0
call69:.memcpy
call70:sub_1F6C0
call71:sub_1F8A4
call72:.
free
call73:sub_36D38
call74:sub_36D70
call75:sub_36DA4
call76:sub_37060
call77:sub_41368
call78:sub_36A20
call79:sub_36D10
call80:sub_3C6A4
call81:sub_369B0
call82:sub_3DF74
call83:sub_3A054
call84:sub_3A090
call85:sub_3A0FC
call86:sub_3A138
call87:sub_24364
call88:sub_3852C
call89:sub_38D9C
call90:sub_36A90
call91:sub_3F2B0
call92:sub_36120
call93:sub_36144
call94:sub_370AC
call95:sub_36558
call96:sub_21BAC
call97:sub_21C20
call98:sub_21F50
call99:sub_21DB4
call100:j_.pthread_mutex_lock
call101:j_.pthread_mutex_unlock
call102:sub_11E30
call103:sub_11C60
call104:.pthread_attr_init
call105:.pthread_attr_setstacksize
call106:.pthread_attr_setdetachstate
call107:.pthread_create
call108:.pthread_attr_destroy
call109:sub_11C6C
call110:j_j_.free_2
call111:j_.
free
call112:sub_37254
call113:sub_37740
call114:sub_377A8
call115:sub_377D8
call116:sub_37804
call117:sub_37A64
call118:sub_37AD4
call119:sub_37B34
call120:sub_37B64
call121:sub_37BA0
call122:nullsub_18
call123:sub_3789C
call124:sub_378C4
call125:sub_20DD0
call126:sub_20580
call127:sub_20CB0
call128:sub_20EBC
call129:j_.stat
call130:.stat
call131:sub_373B4
call132:sub_1240C
call133:sub_1F74C
call134:.lseek
call135:sub_1F9EC
call136:sub_1FA34
call137:sub_37940
call138:sub_37974
call139:sub_379A8
call140:sub_1235C
call141:sub_37134
call142:sub_37184
call143:sub_371AC
call144:sub_376CC
call145:sub_37704
call146:sub_37738
call147:sub_3715C
call148:sub_36580
call149:sub_36538
call150:sub_36178
...
call1:JNI_OnLoad
call2:sub_FF14
call3:.memset
call4:.vsnprintf
call5:.
time
call6:.localtime
call7:.__android_log_print
call8:sub_10070
call9:.fopen
call10:sub_21000
call11:.pthread_once
call12:sub_21054
call13:sub_412CC
call14:.malloc
call15:sub_21098
call16:sub_FABC
call17:sub_1010C
call18:sub_10194
call19:sub_11C4C
call20:.pthread_mutex_init
call21:sub_103D0
call22:sub_2BCA8
call23:sub_125E4
call24:sub_12660
call25:sub_1CE70
call26:sub_1CE34
call27:sub_1C664
call28:.pthread_mutex_lock
call29:.pthread_mutex_unlock
call30:.strlen
call31:sub_125F0
call32:sub_1D998
call33:sub_2C67C
call34:sub_2C40C
call35:.__strlcpy_chk
call36:.__strlen_chk
call37:sub_11BC4
call38:sub_2CCC0
call39:sub_355F0
call40:sub_35630
call41:sub_356C4
call42:sub_35700
call43:sub_11DF0
call44:sub_35870
call45:sub_36940
call46:sub_36B34
call47:sub_36B9C
call48:sub_36BC8
call49:sub_36BF0
call50:sub_36E00
call51:sub_36E70
call52:sub_36ED0
call53:sub_36F00
call54:sub_36F3C
call55:nullsub_17
call56:sub_36C8C
call57:sub_36CB8
call58:sub_2E318
call59:sub_2E288
call60:sub_2D590
call61:sub_1F450
call62:sub_20FD0
call63:.fstat
call64:sub_2DB5C
call65:sub_1FE3C
call66:sub_1FB70
call67:.sscanf
call68:sub_200C0
call69:.memcpy
call70:sub_1F6C0
call71:sub_1F8A4
call72:.
free
call73:sub_36D38
call74:sub_36D70
call75:sub_36DA4
call76:sub_37060
call77:sub_41368
call78:sub_36A20
call79:sub_36D10
call80:sub_3C6A4
call81:sub_369B0
call82:sub_3DF74
call83:sub_3A054
call84:sub_3A090
call85:sub_3A0FC
call86:sub_3A138
call87:sub_24364
call88:sub_3852C
call89:sub_38D9C
call90:sub_36A90
call91:sub_3F2B0
call92:sub_36120
call93:sub_36144
call94:sub_370AC
call95:sub_36558
call96:sub_21BAC
call97:sub_21C20
call98:sub_21F50
call99:sub_21DB4
call100:j_.pthread_mutex_lock
call101:j_.pthread_mutex_unlock
call102:sub_11E30
call103:sub_11C60
call104:.pthread_attr_init
call105:.pthread_attr_setstacksize
call106:.pthread_attr_setdetachstate
call107:.pthread_create
call108:.pthread_attr_destroy
call109:sub_11C6C
call110:j_j_.free_2
call111:j_.
free
call112:sub_37254
call113:sub_37740
call114:sub_377A8
call115:sub_377D8
call116:sub_37804
call117:sub_37A64
call118:sub_37AD4
call119:sub_37B34
call120:sub_37B64
call121:sub_37BA0
call122:nullsub_18
call123:sub_3789C
call124:sub_378C4
call125:sub_20DD0
call126:sub_20580
call127:sub_20CB0
call128:sub_20EBC
call129:j_.stat
call130:.stat
call131:sub_373B4
call132:sub_1240C
call133:sub_1F74C
call134:.lseek
call135:sub_1F9EC
call136:sub_1FA34
call137:sub_37940
call138:sub_37974
call139:sub_379A8
call140:sub_1235C
call141:sub_37134
call142:sub_37184
call143:sub_371AC
call144:sub_376CC
call145:sub_37704
call146:sub_37738
call147:sub_3715C
call148:sub_36580
call149:sub_36538
call150:sub_36178
...
function
dump_so(so_name) {
Java.perform(
function
() {
var
currentApplication = Java.use(
"android.app.ActivityThread"
).currentApplication();
var
dir = currentApplication.getApplicationContext().getFilesDir().getPath();
var
libso = Process.getModuleByName(so_name);
console.log(
"[name]:"
, libso.name);
console.log(
"[base]:"
, libso.base);
console.log(
"[size]:"
, ptr(libso.size));
console.log(
"[path]:"
, libso.path);
});
}
rpc.exports = {
dump_so: dump_so
};
function
dump_so(so_name) {
Java.perform(
function
() {
var
currentApplication = Java.use(
"android.app.ActivityThread"
).currentApplication();
var
dir = currentApplication.getApplicationContext().getFilesDir().getPath();
var
libso = Process.getModuleByName(so_name);
console.log(
"[name]:"
, libso.name);
console.log(
"[base]:"
, libso.base);
console.log(
"[size]:"
, ptr(libso.size));
console.log(
"[path]:"
, libso.path);
});
}
rpc.exports = {
dump_so: dump_so
};
frida -H 127.0.0.1:1234 -l
"D:\frida\sec2023\get_so_base.js"
-f
"com.com.sec2023.rocketmouse.mouse"
frida -H 127.0.0.1:1234 -l
"D:\frida\sec2023\get_so_base.js"
-f
"com.com.sec2023.rocketmouse.mouse"
ps
-A |
grep
mouse
call135:sub_1F9EC
call136:sub_1FA34
call137:sub_37940
call138:sub_37974
call139:sub_379A8
call140:sub_1235C
call141:sub_37134
call142:sub_37184
call143:sub_371AC
call144:sub_376CC
call145:sub_37704
call135:sub_1F9EC
call136:sub_1FA34
call137:sub_37940
call138:sub_37974
call139:sub_379A8
call140:sub_1235C
call141:sub_37134
call142:sub_37184
call143:sub_371AC
call144:sub_376CC
call145:sub_37704
if
(W0 == W8){
X8 = X8
}
else
{
X8 = X9
}
if
(W0 == W8){
X8 = X8
}
else
{
X8 = X9
}
function
anti_sec2023() {
Java.perform(
function
() {
var
currentApplication = Java.use(
"android.app.ActivityThread"
).currentApplication();
var
libso = Process.getModuleByName(
"libsec2023.so"
);
console.log(
"[name]:"
, libso.name);
console.log(
"[base]:"
, libso.base);
console.log(
"[size]:"
, ptr(libso.size));
console.log(
"[path]:"
, libso.path);
Memory.protect(ptr(libso.base), libso.size,
'rwx'
);
Memory.writeByteArray(ptr(libso.base).add(0x371DC),[0x08,0x01,0x88,0x9A]);
});
}
rpc.exports = {
anti_sec2023: anti_sec2023
};
function
anti_sec2023() {
Java.perform(
function
() {
var
currentApplication = Java.use(
"android.app.ActivityThread"
).currentApplication();
var
libso = Process.getModuleByName(
"libsec2023.so"
);
console.log(
"[name]:"
, libso.name);
console.log(
"[base]:"
, libso.base);
console.log(
"[size]:"
, ptr(libso.size));
console.log(
"[path]:"
, libso.path);
Memory.protect(ptr(libso.base), libso.size,
'rwx'
);
Memory.writeByteArray(ptr(libso.base).add(0x371DC),[0x08,0x01,0x88,0x9A]);
});
}
rpc.exports = {
anti_sec2023: anti_sec2023
};
function
hook_31164(){
Java.perform(
function
()
{
var
module = Process.getModuleByName(
"libsec2023.so"
)
var
addr=module.base.add(
"0x31164"
);
var
func =
new
NativePointer(addr.toString());
console.log(
'[+] hook '
+func.toString())
Interceptor.attach(func, {
onEnter:
function
(args) {
console.log(
'hook success'
);
console.log(args[0]);
console.log(args[1]);
console.log(args[2]);
},
onLeave:
function
(retval) {
console.log(
"retvalue is :"
, retval.toInt32());
console.log(
'method onleave'
);
}
});
});
}
function
hook_31164(){
Java.perform(
function
()
{
var
module = Process.getModuleByName(
"libsec2023.so"
)
var
addr=module.base.add(
"0x31164"
);
var
func =
new
NativePointer(addr.toString());
console.log(
'[+] hook '
+func.toString())
Interceptor.attach(func, {
onEnter:
function
(args) {
console.log(
'hook success'
);
console.log(args[0]);
console.log(args[1]);
console.log(args[2]);
},
onLeave:
function
(retval) {
console.log(
"retvalue is :"
, retval.toInt32());
console.log(
'method onleave'
);
}
});
});
}
function
addr_locate_so(addr){
var
process_Obj_Module_Arr = Process.enumerateModules();
for
(
var
i = 0; i < process_Obj_Module_Arr.length; i++) {
if
(addr>process_Obj_Module_Arr[i].base && addr<process_Obj_Module_Arr[i].base.add(process_Obj_Module_Arr[i].size)){
return
process_Obj_Module_Arr[i].name+
":0x"
+(addr-process_Obj_Module_Arr[i].base).toString(16)
}
}
}
function
anti_BR(){
var
libso = Process.getModuleByName(
"libsec2023.so"
)
var
hook_addr =
new
NativePointer(libso.base.add(0x31164).toString());
this
.tid = Process.getCurrentThreadId();
console.log(
'[+] hook '
+hook_addr.toString())
var
reg_name;
var
inst_addr;
Interceptor.attach(hook_addr, {
onEnter:
function
(args) {
console.log(
"start Stalker!"
);
Stalker.exclude({
"base"
: Process.getModuleByName(
"libc.so"
).base,
"size"
: Process.getModuleByName(
"libc.so"
).size
})
Stalker.follow(
this
.tid, {
events: {
call:
true
,
ret:
false
,
exec:
false
,
block:
false
,
compile:
false
},
transform: (iterator) => {
let instruction = iterator.next();
const startAddress = instruction.address;
const isAppCode = startAddress.compare(libso.base) >= 0 &&startAddress.compare(libso.base.add(libso.size)) === -1;
do
{
if
(isAppCode) {
if
(instruction.mnemonic ===
"br"
) {
reg_name = instruction.opStr;
inst_addr =
new
NativePointer(instruction.address);
iterator.putCallout((context) => {
var
addr_before = addr_locate_so(inst_addr);
var
addr_after = addr_locate_so(parseInt(context[reg_name],16));
if
(addr_after==undefined){
addr_after =
"unknown:"
+context[reg_name];
}
console.log(addr_before,
"jump to"
,addr_after,
" "
,reg_name);
});
}
}
iterator.keep();
}
while
((instruction = iterator.next()) !==
null
);
}
})
console.log(
"stalker end!"
);
},
onLeave:
function
(retval) {
Stalker.unfollow(
this
.tid);
Stalker.garbageCollect();
}
});
}
function
addr_locate_so(addr){
var
process_Obj_Module_Arr = Process.enumerateModules();
for
(
var
i = 0; i < process_Obj_Module_Arr.length; i++) {
if
(addr>process_Obj_Module_Arr[i].base && addr<process_Obj_Module_Arr[i].base.add(process_Obj_Module_Arr[i].size)){
return
process_Obj_Module_Arr[i].name+
":0x"
+(addr-process_Obj_Module_Arr[i].base).toString(16)
}
}
}
function
anti_BR(){
var
libso = Process.getModuleByName(
"libsec2023.so"
)
var
hook_addr =
new
NativePointer(libso.base.add(0x31164).toString());
this
.tid = Process.getCurrentThreadId();
console.log(
'[+] hook '
+hook_addr.toString())
var
reg_name;
var
inst_addr;
Interceptor.attach(hook_addr, {
onEnter:
function
(args) {
console.log(
"start Stalker!"
);
Stalker.exclude({
"base"
: Process.getModuleByName(
"libc.so"
).base,
"size"
: Process.getModuleByName(
"libc.so"
).size
})
Stalker.follow(
this
.tid, {
events: {
call:
true
,
ret:
false
,
exec:
false
,
block:
false
,
compile:
false
},
transform: (iterator) => {
let instruction = iterator.next();
const startAddress = instruction.address;
const isAppCode = startAddress.compare(libso.base) >= 0 &&startAddress.compare(libso.base.add(libso.size)) === -1;
do
{
if
(isAppCode) {
if
(instruction.mnemonic ===
"br"
) {
reg_name = instruction.opStr;
inst_addr =
new
NativePointer(instruction.address);
iterator.putCallout((context) => {
var
addr_before = addr_locate_so(inst_addr);
var
addr_after = addr_locate_so(parseInt(context[reg_name],16));
if
(addr_after==undefined){
addr_after =
"unknown:"
+context[reg_name];
}
console.log(addr_before,
"jump to"
,addr_after,
" "
,reg_name);
});
}
}
iterator.keep();
}
while
((instruction = iterator.next()) !==
null
);
}
})
console.log(
"stalker end!"
);
},
onLeave:
function
(retval) {
Stalker.unfollow(
this
.tid);
Stalker.garbageCollect();
}
});
}
[Remote::com.com.sec2023.rocketmouse.mouse ]-> rpc.exports.anti_BR()
[+] hook 0x76cd136164
[Remote::com.com.sec2023.rocketmouse.mouse ]-> start Stalker!
stalker end!
libsec2023.so:0x3ba00 jump to libsec2023.so:0x3ba04 x10
libsec2023.so:0x3ba30 jump to libsec2023.so:0x3ba34 x12
libsec2023.so:0x3ba70 jump to libsec2023.so:0x3ba34 x12
libsec2023.so:0x3ba70 jump to libsec2023.so:0x3ba34 x12
libsec2023.so:0x3ba70 jump to libsec2023.so:0x3ba34 x12
libsec2023.so:0x3ba70 jump to libsec2023.so:0x3ba74 x12
libsec2023.so:0x3badc jump to libsec2023.so:0x3bae0 x13
libsec2023.so:0x3bb28 jump to libsec2023.so:0x3bae0 x13
libsec2023.so:0x3bb28 jump to libsec2023.so:0x3bae0 x13
libsec2023.so:0x3bb28 jump to libsec2023.so:0x3bae0 x13
libsec2023.so:0x3bb28 jump to libsec2023.so:0x3bb2c x13
libsec2023.so:0x3bb4c jump to libsec2023.so:0x3ba04 x10
libsec2023.so:0x3bb4c jump to unknown:0x3 x10
libsec2023.so:0x3bb4c jump to unknown:0x2 x10
libsec2023.so:0x3bb4c jump to unknown:0x1 x10
libsec2023.so:0x3bb4c jump to unknown:0x0 x10
libsec2023.so:0x3bb4c jump to unknown:0xffffffffffffffff x10
libsec2023.so:0x3bb4c jump to unknown:0x0 x10
libsec2023.so:0x3bb4c jump to unknown:0x6d000000 x10
libsec2023.so:0x3bb4c jump to unknown:0x6d940000 x10
libsec2023.so:0x3bb4c jump to unknown:0x6d94ca00 x10
libsec2023.so:0x3bb4c jump to unknown:0x6d94cae5 x10
libsec2023.so:0x3bb4c jump to libsec2023.so:0x3bb50 x10
libsec2023.so:0x3a08c jump to libsec2023.so:0x3a0f0 x8
libsec2023.so:0x3b508 jump to libsec2023.so:0x3b50c x11
libsec2023.so:0x3b54c jump to libsec2023.so:0x3b50c x11
libsec2023.so:0x3b54c jump to libsec2023.so:0x3b50c x11
libsec2023.so:0x3b54c jump to libsec2023.so:0x3b50c x11
libsec2023.so:0x3b54c jump to libsec2023.so:0x3b50c x11
libsec2023.so:0x3b54c jump to libsec2023.so:0x3b50c x11
libsec2023.so:0x3b54c jump to libsec2023.so:0x3b50c x11
libsec2023.so:0x3b54c jump to libsec2023.so:0x3b50c x11
libsec2023.so:0x3b54c jump to libsec2023.so:0x3b50c x11
libsec2023.so:0x3b54c jump to libsec2023.so:0x3b50c x11
libsec2023.so:0x3b54c jump to libsec2023.so:0x3b50c x11
libsec2023.so:0x3b54c jump to libsec2023.so:0x3b50c x11
libsec2023.so:0x3b54c jump to libsec2023.so:0x3b50c x11
libsec2023.so:0x3b54c jump to libsec2023.so:0x3b50c x11
libsec2023.so:0x3b54c jump to libsec2023.so:0x3b50c x11
libsec2023.so:0x3b54c jump to libsec2023.so:0x3b50c x11
libsec2023.so:0x3b54c jump to libsec2023.so:0x3b50c x11
libsec2023.so:0x3b54c jump to libsec2023.so:0x3b50c x11
libsec2023.so:0x3b54c jump to libsec2023.so:0x3b550 x11
libsec2023.so:0x3b5c0 jump to libsec2023.so:0x3b5c4 x11
libsec2023.so:0x3b604 jump to libsec2023.so:0x3b5c4 x11
libsec2023.so:0x3b604 jump to libsec2023.so:0x3b5c4 x11
libsec2023.so:0x3b604 jump to libsec2023.so:0x3b5c4 x11
libsec2023.so:0x3b604 jump to libsec2023.so:0x3b5c4 x11
libsec2023.so:0x3b604 jump to libsec2023.so:0x3b5c4 x11
libsec2023.so:0x3b604 jump to libsec2023.so:0x3b5c4 x11
libsec2023.so:0x3b604 jump to libsec2023.so:0x3b5c4 x11
libsec2023.so:0x3b604 jump to libsec2023.so:0x3b5c4 x11
libsec2023.so:0x3b604 jump to libsec2023.so:0x3b5c4 x11
libsec2023.so:0x3b604 jump to libsec2023.so:0x3b5c4 x11
libsec2023.so:0x3b604 jump to libsec2023.so:0x3b5c4 x11
libsec2023.so:0x3b604 jump to libsec2023.so:0x3b5c4 x11
libsec2023.so:0x3b604 jump to libsec2023.so:0x3b5c4 x11
libsec2023.so:0x3b604 jump to libsec2023.so:0x3b5c4 x11
libsec2023.so:0x3b604 jump to libsec2023.so:0x3b5c4 x11
libsec2023.so:0x3b604 jump to libsec2023.so:0x3b5c4 x11
libsec2023.so:0x3b604 jump to libsec2023.so:0x3b5c4 x11
libsec2023.so:0x3b604 jump to libsec2023.so:0x3b608 x11
libsec2023.so:0x3aa70 jump to libsec2023.so:0x3aa74 x8
libsec2023.so:0x3aaa0 jump to libsec2023.so:0x3aaa4 x8
libsec2023.so:0x3aad4 jump to libsec2023.so:0x3aad8 x8
libsec2023.so:0x3ab04 jump to libsec2023.so:0x3ab70 x8
libsec2023.so:0xf28c jump to libc.so:0xb2688 x17
libsec2023.so:0xf4ac jump to libc.so:0xb2bd8 x17
libsec2023.so:0x3ac90 jump to libsec2023.so:0x3acc0 x11
libsec2023.so:0xf40c jump to libc.so:0x4bc20 x17
libsec2023.so:0xf40c jump to libc.so:0xb2688 x17
libsec2023.so:0xf40c jump to libc.so:0xb2bd8 x17
libsec2023.so:0x3b950 jump to libsec2023.so:0x3b95c x8
libsec2023.so:0x3b950 jump to libsec2023.so:0x3a0f0 x8
libsec2023.so:0x3b950 jump to unknown:0x76ccc36000 x8
libsec2023.so:0x3b950 jump to unknown:0x76ccc36000 x8
libsec2023.so:0x3b950 jump to unknown:0x76ccc36000 x8
libsec2023.so:0x3b950 jump to unknown:0x76ccc36000 x8
libsec2023.so:0x3b950 jump to unknown:0x76ccc36000 x8
libsec2023.so:0x3b950 jump to unknown:0x76ccc36000 x8
libsec2023.so:0x3b950 jump to unknown:0x76ccc36000 x8
libsec2023.so:0x3b950 jump to unknown:0x76ccc36000 x8
libsec2023.so:0x3b950 jump to unknown:0x76ccc36000 x8
libsec2023.so:0x3b950 jump to unknown:0x76ccc36000 x8
libsec2023.so:0x3b950 jump to unknown:0x76ccc36000 x8
libsec2023.so:0x3b950 jump to unknown:0x76ccc36000 x8
libsec2023.so:0x3b950 jump to unknown:0x76ccc36000 x8
libsec2023.so:0x3b950 jump to unknown:0x76ccc36000 x8
libsec2023.so:0x3b950 jump to unknown:0x76ccc36000 x8
libsec2023.so:0x3b950 jump to unknown:0x76ccc36000 x8
libsec2023.so:0x3b950 jump to unknown:0x76ccc36000 x8
libsec2023.so:0x3b950 jump to unknown:0x76ccc36000 x8
libsec2023.so:0x3b950 jump to unknown:0x76ccc36000 x8
libsec2023.so:0x3b950 jump to unknown:0x76ccc36000 x8
libsec2023.so:0x3b950 jump to unknown:0x76ccc36000 x8
libsec2023.so:0x3b950 jump to unknown:0x76ccc36000 x8
libsec2023.so:0x3b950 jump to unknown:0x76ccc36000 x8
libsec2023.so:0x3b950 jump to unknown:0x76ccc36000 x8
libsec2023.so:0x3b950 jump to unknown:0x76ccc36000 x8
libsec2023.so:0x3b950 jump to unknown:0x76ccc36000 x8
libsec2023.so:0x3b950 jump to unknown:0x76ccc36000 x8
libsec2023.so:0x3b950 jump to unknown:0x76ccc36000 x8
libsec2023.so:0x3b950 jump to unknown:0x76ccc36000 x8
libsec2023.so:0x3b950 jump to unknown:0x76ccc36000 x8
libsec2023.so:0x3b950 jump to unknown:0x76ccc36000 x8
libsec2023.so:0x3b950 jump to unknown:0x76ccc36000 x8
libsec2023.so:0x3b950 jump to unknown:0x76ccc36000 x8
libsec2023.so:0x3b950 jump to unknown:0x76ccc36000 x8
libsec2023.so:0x3b950 jump to unknown:0x76ccc36000 x8
libsec2023.so:0x3b950 jump to unknown:0x76ccc36000 x8
libsec2023.so:0x3b950 jump to unknown:0x76ccc36000 x8
libsec2023.so:0x3b950 jump to unknown:0x76ccc36000 x8
libsec2023.so:0x3b950 jump to libsec2023.so:0x3aa74 x8
libsec2023.so:0x3b950 jump to libsec2023.so:0x3aaa4 x8
libsec2023.so:0x3b950 jump to libsec2023.so:0x3aad8 x8
libsec2023.so:0x3b950 jump to libsec2023.so:0x3ab70 x8
libsec2023.so:0x3b950 jump to libsec2023.so:0x3ab70 x8
libsec2023.so:0x3b950 jump to unknown:0x77ea7ac3a0 x8
libsec2023.so:0x3b950 jump to unknown:0x1c01f8026ad23c58 x8
libsec2023.so:0x3b950 jump to unknown:0x1c01f8026ad23c58 x8
libsec2023.so:0x3b950 jump to unknown:0x1c01f8026ad23c58 x8
libsec2023.so:0x3b950 jump to unknown:0xe x8
libsec2023.so:0x3b990 jump to libsec2023.so:0x3b99c x8
libsec2023.so:0x311a0 jump to libil2cpp.so:0x13b8d64 x2
[Remote::com.com.sec2023.rocketmouse.mouse ]-> rpc.exports.anti_BR()
[+] hook 0x76cd136164
[Remote::com.com.sec2023.rocketmouse.mouse ]-> start Stalker!
stalker end!
libsec2023.so:0x3ba00 jump to libsec2023.so:0x3ba04 x10
libsec2023.so:0x3ba30 jump to libsec2023.so:0x3ba34 x12
libsec2023.so:0x3ba70 jump to libsec2023.so:0x3ba34 x12
libsec2023.so:0x3ba70 jump to libsec2023.so:0x3ba34 x12
libsec2023.so:0x3ba70 jump to libsec2023.so:0x3ba34 x12
libsec2023.so:0x3ba70 jump to libsec2023.so:0x3ba74 x12
libsec2023.so:0x3badc jump to libsec2023.so:0x3bae0 x13
libsec2023.so:0x3bb28 jump to libsec2023.so:0x3bae0 x13
libsec2023.so:0x3bb28 jump to libsec2023.so:0x3bae0 x13
libsec2023.so:0x3bb28 jump to libsec2023.so:0x3bae0 x13
libsec2023.so:0x3bb28 jump to libsec2023.so:0x3bb2c x13
libsec2023.so:0x3bb4c jump to libsec2023.so:0x3ba04 x10
libsec2023.so:0x3bb4c jump to unknown:0x3 x10
libsec2023.so:0x3bb4c jump to unknown:0x2 x10
libsec2023.so:0x3bb4c jump to unknown:0x1 x10
libsec2023.so:0x3bb4c jump to unknown:0x0 x10
libsec2023.so:0x3bb4c jump to unknown:0xffffffffffffffff x10
libsec2023.so:0x3bb4c jump to unknown:0x0 x10
libsec2023.so:0x3bb4c jump to unknown:0x6d000000 x10
libsec2023.so:0x3bb4c jump to unknown:0x6d940000 x10
libsec2023.so:0x3bb4c jump to unknown:0x6d94ca00 x10
libsec2023.so:0x3bb4c jump to unknown:0x6d94cae5 x10
libsec2023.so:0x3bb4c jump to libsec2023.so:0x3bb50 x10
libsec2023.so:0x3a08c jump to libsec2023.so:0x3a0f0 x8
libsec2023.so:0x3b508 jump to libsec2023.so:0x3b50c x11
libsec2023.so:0x3b54c jump to libsec2023.so:0x3b50c x11
libsec2023.so:0x3b54c jump to libsec2023.so:0x3b50c x11
libsec2023.so:0x3b54c jump to libsec2023.so:0x3b50c x11
libsec2023.so:0x3b54c jump to libsec2023.so:0x3b50c x11
libsec2023.so:0x3b54c jump to libsec2023.so:0x3b50c x11
libsec2023.so:0x3b54c jump to libsec2023.so:0x3b50c x11
libsec2023.so:0x3b54c jump to libsec2023.so:0x3b50c x11
libsec2023.so:0x3b54c jump to libsec2023.so:0x3b50c x11
libsec2023.so:0x3b54c jump to libsec2023.so:0x3b50c x11
libsec2023.so:0x3b54c jump to libsec2023.so:0x3b50c x11
libsec2023.so:0x3b54c jump to libsec2023.so:0x3b50c x11
libsec2023.so:0x3b54c jump to libsec2023.so:0x3b50c x11
libsec2023.so:0x3b54c jump to libsec2023.so:0x3b50c x11
libsec2023.so:0x3b54c jump to libsec2023.so:0x3b50c x11
libsec2023.so:0x3b54c jump to libsec2023.so:0x3b50c x11
libsec2023.so:0x3b54c jump to libsec2023.so:0x3b50c x11
libsec2023.so:0x3b54c jump to libsec2023.so:0x3b50c x11
libsec2023.so:0x3b54c jump to libsec2023.so:0x3b550 x11
libsec2023.so:0x3b5c0 jump to libsec2023.so:0x3b5c4 x11
libsec2023.so:0x3b604 jump to libsec2023.so:0x3b5c4 x11
libsec2023.so:0x3b604 jump to libsec2023.so:0x3b5c4 x11
libsec2023.so:0x3b604 jump to libsec2023.so:0x3b5c4 x11
libsec2023.so:0x3b604 jump to libsec2023.so:0x3b5c4 x11
libsec2023.so:0x3b604 jump to libsec2023.so:0x3b5c4 x11
libsec2023.so:0x3b604 jump to libsec2023.so:0x3b5c4 x11
libsec2023.so:0x3b604 jump to libsec2023.so:0x3b5c4 x11
libsec2023.so:0x3b604 jump to libsec2023.so:0x3b5c4 x11
libsec2023.so:0x3b604 jump to libsec2023.so:0x3b5c4 x11
libsec2023.so:0x3b604 jump to libsec2023.so:0x3b5c4 x11
libsec2023.so:0x3b604 jump to libsec2023.so:0x3b5c4 x11
libsec2023.so:0x3b604 jump to libsec2023.so:0x3b5c4 x11
libsec2023.so:0x3b604 jump to libsec2023.so:0x3b5c4 x11
libsec2023.so:0x3b604 jump to libsec2023.so:0x3b5c4 x11
libsec2023.so:0x3b604 jump to libsec2023.so:0x3b5c4 x11
libsec2023.so:0x3b604 jump to libsec2023.so:0x3b5c4 x11
libsec2023.so:0x3b604 jump to libsec2023.so:0x3b5c4 x11
libsec2023.so:0x3b604 jump to libsec2023.so:0x3b608 x11
libsec2023.so:0x3aa70 jump to libsec2023.so:0x3aa74 x8
libsec2023.so:0x3aaa0 jump to libsec2023.so:0x3aaa4 x8
libsec2023.so:0x3aad4 jump to libsec2023.so:0x3aad8 x8
libsec2023.so:0x3ab04 jump to libsec2023.so:0x3ab70 x8
libsec2023.so:0xf28c jump to libc.so:0xb2688 x17
libsec2023.so:0xf4ac jump to libc.so:0xb2bd8 x17
libsec2023.so:0x3ac90 jump to libsec2023.so:0x3acc0 x11
libsec2023.so:0xf40c jump to libc.so:0x4bc20 x17
libsec2023.so:0xf40c jump to libc.so:0xb2688 x17
libsec2023.so:0xf40c jump to libc.so:0xb2bd8 x17
libsec2023.so:0x3b950 jump to libsec2023.so:0x3b95c x8
libsec2023.so:0x3b950 jump to libsec2023.so:0x3a0f0 x8
libsec2023.so:0x3b950 jump to unknown:0x76ccc36000 x8
libsec2023.so:0x3b950 jump to unknown:0x76ccc36000 x8
libsec2023.so:0x3b950 jump to unknown:0x76ccc36000 x8
libsec2023.so:0x3b950 jump to unknown:0x76ccc36000 x8
libsec2023.so:0x3b950 jump to unknown:0x76ccc36000 x8
libsec2023.so:0x3b950 jump to unknown:0x76ccc36000 x8
libsec2023.so:0x3b950 jump to unknown:0x76ccc36000 x8
libsec2023.so:0x3b950 jump to unknown:0x76ccc36000 x8
libsec2023.so:0x3b950 jump to unknown:0x76ccc36000 x8
libsec2023.so:0x3b950 jump to unknown:0x76ccc36000 x8
libsec2023.so:0x3b950 jump to unknown:0x76ccc36000 x8
libsec2023.so:0x3b950 jump to unknown:0x76ccc36000 x8
libsec2023.so:0x3b950 jump to unknown:0x76ccc36000 x8
libsec2023.so:0x3b950 jump to unknown:0x76ccc36000 x8
libsec2023.so:0x3b950 jump to unknown:0x76ccc36000 x8
libsec2023.so:0x3b950 jump to unknown:0x76ccc36000 x8
libsec2023.so:0x3b950 jump to unknown:0x76ccc36000 x8
libsec2023.so:0x3b950 jump to unknown:0x76ccc36000 x8
libsec2023.so:0x3b950 jump to unknown:0x76ccc36000 x8
libsec2023.so:0x3b950 jump to unknown:0x76ccc36000 x8
libsec2023.so:0x3b950 jump to unknown:0x76ccc36000 x8
libsec2023.so:0x3b950 jump to unknown:0x76ccc36000 x8
libsec2023.so:0x3b950 jump to unknown:0x76ccc36000 x8
libsec2023.so:0x3b950 jump to unknown:0x76ccc36000 x8
libsec2023.so:0x3b950 jump to unknown:0x76ccc36000 x8
libsec2023.so:0x3b950 jump to unknown:0x76ccc36000 x8
libsec2023.so:0x3b950 jump to unknown:0x76ccc36000 x8
libsec2023.so:0x3b950 jump to unknown:0x76ccc36000 x8
libsec2023.so:0x3b950 jump to unknown:0x76ccc36000 x8
libsec2023.so:0x3b950 jump to unknown:0x76ccc36000 x8
libsec2023.so:0x3b950 jump to unknown:0x76ccc36000 x8
libsec2023.so:0x3b950 jump to unknown:0x76ccc36000 x8
libsec2023.so:0x3b950 jump to unknown:0x76ccc36000 x8
libsec2023.so:0x3b950 jump to unknown:0x76ccc36000 x8
libsec2023.so:0x3b950 jump to unknown:0x76ccc36000 x8
libsec2023.so:0x3b950 jump to unknown:0x76ccc36000 x8
libsec2023.so:0x3b950 jump to unknown:0x76ccc36000 x8
libsec2023.so:0x3b950 jump to unknown:0x76ccc36000 x8
libsec2023.so:0x3b950 jump to libsec2023.so:0x3aa74 x8
libsec2023.so:0x3b950 jump to libsec2023.so:0x3aaa4 x8
libsec2023.so:0x3b950 jump to libsec2023.so:0x3aad8 x8
libsec2023.so:0x3b950 jump to libsec2023.so:0x3ab70 x8
libsec2023.so:0x3b950 jump to libsec2023.so:0x3ab70 x8
libsec2023.so:0x3b950 jump to unknown:0x77ea7ac3a0 x8
libsec2023.so:0x3b950 jump to unknown:0x1c01f8026ad23c58 x8
libsec2023.so:0x3b950 jump to unknown:0x1c01f8026ad23c58 x8
libsec2023.so:0x3b950 jump to unknown:0x1c01f8026ad23c58 x8
libsec2023.so:0x3b950 jump to unknown:0xe x8
libsec2023.so:0x3b990 jump to libsec2023.so:0x3b99c x8
libsec2023.so:0x311a0 jump to libil2cpp.so:0x13b8d64 x2
libsec2023.so:0x3ba70 jump to libsec2023.so:0x3ba34 x12
libsec2023.so:0x3ba70 jump to libsec2023.so:0x3ba34 x12
libsec2023.so:0x3ba70 jump to libsec2023.so:0x3ba34 x12
libsec2023.so:0x3ba70 jump to libsec2023.so:0x3ba74 x12
libsec2023.so:0x3ba70 jump to libsec2023.so:0x3ba34 x12
libsec2023.so:0x3ba70 jump to libsec2023.so:0x3ba34 x12
libsec2023.so:0x3ba70 jump to libsec2023.so:0x3ba34 x12
libsec2023.so:0x3ba70 jump to libsec2023.so:0x3ba74 x12
libsec2023.so:0x3ba00 jump to libsec2023.so:0x3ba04 x10
libsec2023.so:0x3ba00 jump to libsec2023.so:0x3ba04 x10
red_num
=
0xFFFFFFFF8C034254
add_num
=
0x740078FC
num
=
(red_num
+
add_num)&
0xffffffff
my_byte
=
list
(num.to_bytes(
8
,
'little'
))
my_byte
=
[
hex
(x)[
2
::].zfill(
2
)
for
x
in
my_byte]
print
(
' '
.join(
list
(my_byte)))
red_num
=
0xFFFFFFFF8C034254
add_num
=
0x740078FC
num
=
(red_num
+
add_num)&
0xffffffff
my_byte
=
list
(num.to_bytes(
8
,
'little'
))
my_byte
=
[
hex
(x)[
2
::].zfill(
2
)
for
x
in
my_byte]
print
(
' '
.join(
list
(my_byte)))
条件码 |
含义 |
EQ |
Z置位 ;结果相等才执行 |
NE |
Z清零,结果不相等才执行 |
CS |
C置位,结果无符号>= 才执行 |
CC |
C清零,结果无符号< 才执行 |
MI |
N置位,结果为负数才执行 |
PL |
N清零,结果为正数或0才执行 |
VS |
V置位,结果溢出才执行 |
VC |
V清零,结果无溢出才执行 |
HI |
C置位Z清零,结果为无符号数大于才执行 |
LS |
C清零Z置位,结果为无符号数小于或等于才执行 |
GE |
N等于V,结果为有符号数大于或等于才执行 |
LT |
N不等于V,结果为有符号数小于才执行 |
GT |
Z清零且N等于V ,结果为有符号大于才执行 |
LE |
Z置位或N不等于V ,结果为有符号数小于或等于 |
AL |
无条件执行。省略。 |
if
(X8 < 2){
B 0x3BA04
}
else
if
(X8 >= 2){
B 0x3BB50
}
if
(X8 < 2){
B 0x3BA04
}
else
if
(X8 >= 2){
B 0x3BB50
}
cmp w8, #2 ; 将寄存器 w8 的值和常量 2 进行比较
cset w8, gt ; 如果是大于(grater than),则将寄存器 w8 的值设置为 1,否则设置为 0
cmp w8, #2 ; 将寄存器 w8 的值和常量 2 进行比较
cset w8, gt ; 如果是大于(grater than),则将寄存器 w8 的值设置为 1,否则设置为 0
CSET W23, NE
LDR X8, [X21,W23,UXTW#3]
ADD X8, X8, X22
BR X8
CSET W23, NE
LDR X8, [X21,W23,UXTW#3]
ADD X8, X8, X22
BR X8
import
ida_segment
import
idautils
import
idc
import
ida_bytes
from
keystone
import
*
def
patch_nop(begin, end):
while
end > begin:
ida_bytes.patch_bytes(begin, b
'\x1F\x20\x03\xD5'
)
begin
=
begin
+
4
text_seg
=
ida_segment.get_segm_by_name(
".text"
)
start, end
=
text_seg.start_ea, text_seg.end_ea
current_addr
=
start
nop_addr_array_after_finish
=
[]
while
current_addr < end:
if
idc.print_insn_mnem(current_addr)
=
=
"CSEL"
:
CSEL_addr
=
current_addr
nop_addr_array_temp
=
[]
nop_addr_array_temp.append(CSEL_addr)
BR_addr
=
0
BR_reg
=
""
temp_addr
=
idc.next_head(current_addr)
for
_
in
range
(
9
):
if
idc.print_insn_mnem(temp_addr)
=
=
"BR"
:
BR_addr
=
temp_addr
BR_reg
=
idc.print_operand(temp_addr,
0
)
break
if
idc.print_insn_mnem(temp_addr)
=
=
"CSEL"
:
break
temp_addr
=
idc.next_head(temp_addr)
if
BR_addr !
=
0
:
CSEL_op1
=
idc.print_operand(CSEL_addr,
0
)
CSEL_op2
=
idc.print_operand(CSEL_addr,
1
)
CSEL_op2_val
=
-
1
CSEL_op3
=
idc.print_operand(CSEL_addr,
2
)
CSEL_op3_val
=
-
1
CSEL_cond
=
idc.print_operand(CSEL_addr,
3
)
temp_addr
=
idc.prev_head(CSEL_addr)
while
(CSEL_op2_val
=
=
-
1
or
CSEL_op3_val
=
=
-
1
)
and
temp_addr > text_seg.start_ea:
if
CSEL_op2
=
=
"XZR"
:
CSEL_op2_val
=
0
if
CSEL_op3
=
=
"XZR"
:
CSEL_op3_val
=
0
if
idc.print_insn_mnem(temp_addr)
=
=
"MOV"
:
if
idc.print_operand(temp_addr,
0
)[
1
::]
=
=
CSEL_op2[
1
::]
and
CSEL_op2_val
=
=
-
1
:
CSEL_op2_val
=
idc.get_operand_value(temp_addr,
1
)
nop_addr_array_temp.append(temp_addr)
elif
idc.print_operand(temp_addr,
0
)[
1
::]
=
=
CSEL_op3[
1
::]
and
CSEL_op3_val
=
=
-
1
:
CSEL_op3_val
=
idc.get_operand_value(temp_addr,
1
)
nop_addr_array_temp.append(temp_addr)
temp_addr
=
idc.prev_head(temp_addr)
assert
CSEL_op2_val !
=
-
1
and
CSEL_op3_val !
=
-
1
temp_addr
=
BR_addr
jump_array_reg
=
""
jump_array_addr
=
-
1
add_reg
=
[]
add_val
=
-
1
while
temp_addr > CSEL_addr:
if
idc.print_insn_mnem(temp_addr)
=
=
"ADD"
and
idc.print_operand(temp_addr,
0
)
=
=
BR_reg:
add_reg.append(idc.print_operand(temp_addr,
1
)[
1
::])
add_reg.append(idc.print_operand(temp_addr,
2
)[
1
::])
nop_addr_array_temp.append(temp_addr)
elif
idc.print_insn_mnem(temp_addr)
=
=
"MOV"
:
if
idc.print_operand(temp_addr,
0
)[
1
::]
in
add_reg:
add_val
=
idc.get_operand_value(temp_addr,
1
)
nop_addr_array_temp.append(temp_addr)
elif
idc.print_insn_mnem(temp_addr)
=
=
"LDR"
:
jump_array_reg
=
idc.print_operand(temp_addr,
1
)[
1
:
-
1
].split(
','
)[
0
]
nop_addr_array_temp.append(temp_addr)
elif
idc.print_insn_mnem(temp_addr)
=
=
"ADRL"
:
jump_array_reg
=
idc.print_operand(temp_addr,
0
)
jump_array_addr
=
idc.get_operand_value(temp_addr,
1
)
nop_addr_array_temp.append(temp_addr)
temp_addr
=
idc.prev_head(temp_addr)
if
jump_array_addr
=
=
-
1
:
temp_addr
=
CSEL_addr
while
temp_addr > text_seg.start_ea:
if
idc.print_insn_mnem(temp_addr)
=
=
"ADRL"
:
if
idc.print_operand(temp_addr,
0
)
=
=
jump_array_reg:
jump_array_addr
=
idc.get_operand_value(temp_addr,
1
)
nop_addr_array_temp.append(temp_addr)
break
elif
idc.print_insn_mnem(temp_addr)
=
=
"ADRP"
:
if
idc.print_operand(temp_addr,
0
)
=
=
jump_array_reg:
jump_array_addr
=
idc.get_operand_value(temp_addr,
1
)
nop_addr_array_temp.append(temp_addr)
while
temp_addr < text_seg.end_ea:
if
idc.print_insn_mnem(temp_addr)
=
=
"ADD"
:
if
idc.print_operand(temp_addr,
0
)
=
=
jump_array_reg:
jump_array_addr
+
=
idc.get_operand_value(temp_addr,
2
)
nop_addr_array_temp.append(temp_addr)
break
temp_addr
=
idc.next_head(temp_addr)
break
temp_addr
=
idc.prev_head(temp_addr)
if
add_val
=
=
-
1
:
temp_addr
=
CSEL_addr
while
temp_addr > text_seg.start_ea:
if
idc.print_insn_mnem(temp_addr)
=
=
"MOV"
:
if
idc.print_operand(temp_addr,
0
)[
1
::]
in
add_reg
and
idc.print_operand(temp_addr,
0
)[
0
]
=
=
'X'
:
add_val
=
idc.get_operand_value(temp_addr,
1
)
nop_addr_array_temp.append(temp_addr)
break
temp_addr
=
idc.prev_head(temp_addr)
branch_a
=
(ida_bytes.get_qword(jump_array_addr
+
CSEL_op2_val)
+
add_val) &
0xffffffffffffffff
branch_b
=
(ida_bytes.get_qword(jump_array_addr
+
CSEL_op3_val)
+
add_val) &
0xffffffffffffffff
logic_rev
=
{
"GE"
:
"LT"
,
"LT"
:
"GE"
,
"EQ"
:
"NE"
,
"NE"
:
"EQ"
,
"CC"
:
"CS"
,
"CS"
:
"CC"
,
"HI"
:
"LS"
,
"LS"
:
"HI"
}
ks
=
Ks(KS_ARCH_ARM64, KS_MODE_LITTLE_ENDIAN)
code
=
""
if
branch_b
=
=
idc.next_head(BR_addr):
code
=
f
"B.{CSEL_cond} #{hex(branch_a)}"
elif
branch_a
=
=
idc.next_head(BR_addr):
code
=
f
"B.{logic_rev[CSEL_cond]} #{hex(branch_b)}"
if
code !
=
"":
patch_br_byte, count
=
ks.asm(code, addr
=
BR_addr)
ida_bytes.patch_bytes(BR_addr, bytes(patch_br_byte))
print
(f
"fix CSEL-BR at {hex(BR_addr)}"
)
nop_addr_array_after_finish.extend(nop_addr_array_temp)
current_addr
=
idc.next_head(BR_addr)
continue
else
:
print
(f
"error! unable to fix CSEL-BR at {hex(current_addr)},branch:{hex(branch_a)}, {hex(branch_b)}"
)
elif
idc.print_insn_mnem(current_addr)
=
=
"CSET"
:
CSET_addr
=
current_addr
nop_addr_array_temp
=
[]
nop_addr_array_temp.append(CSET_addr)
BR_addr
=
0
BR_reg
=
""
temp_addr
=
idc.next_head(current_addr)
for
_
in
range
(
15
):
if
idc.print_insn_mnem(temp_addr)
=
=
"BR"
:
BR_addr
=
temp_addr
BR_reg
=
idc.print_operand(temp_addr,
0
)
break
elif
idc.print_insn_mnem(temp_addr)
=
=
"CSEL"
:
break
elif
idc.print_insn_mnem(temp_addr)
=
=
"RET"
:
break
temp_addr
=
idc.next_head(temp_addr)
if
BR_addr !
=
0
:
CSET_op1
=
idc.print_operand(CSET_addr,
0
)
CSET_op1_val
=
-
1
CSET_cond
=
idc.print_operand(CSET_addr,
1
)
temp_addr
=
BR_addr
jump_array_reg
=
""
jump_array_addr
=
0
add_reg
=
[]
add_val
=
0
Lshift_val
=
-
1
while
temp_addr > CSET_addr:
if
idc.print_insn_mnem(temp_addr)
=
=
"ADD"
and
idc.print_operand(temp_addr,
0
)
=
=
BR_reg:
add_reg.append(idc.print_operand(temp_addr,
1
)[
1
::])
add_reg.append(idc.print_operand(temp_addr,
2
)[
1
::])
nop_addr_array_temp.append(temp_addr)
elif
idc.print_insn_mnem(temp_addr)
=
=
"MOVK"
:
if
idc.print_operand(temp_addr,
0
)[
1
::]
in
add_reg:
add_val
+
=
(idc.get_operand_value(temp_addr,
1
) <<
16
)
elif
idc.print_insn_mnem(temp_addr)
=
=
"MOV"
:
if
idc.print_operand(temp_addr,
0
)[
1
::]
in
add_reg:
add_val
+
=
idc.get_operand_value(temp_addr,
1
)
nop_addr_array_temp.append(temp_addr)
elif
idc.print_insn_mnem(temp_addr)
=
=
"LDR"
:
LDR_temp
=
idc.print_operand(temp_addr,
1
)[
1
:
-
1
].split(
','
)
jump_array_reg
=
LDR_temp[
0
]
if
len
(LDR_temp)
=
=
3
:
Lshift_val
=
int
(LDR_temp[
2
][
-
1
:])
nop_addr_array_temp.append(temp_addr)
elif
idc.print_insn_mnem(temp_addr)
=
=
"ADRL"
:
jump_array_reg
=
idc.print_operand(temp_addr,
0
)
jump_array_addr
=
idc.get_operand_value(temp_addr,
1
)
nop_addr_array_temp.append(temp_addr)
elif
idc.print_insn_mnem(temp_addr)
=
=
"LSL"
:
if
idc.print_operand(temp_addr,
0
)[
1
::]
=
=
CSET_op1[
1
::]:
Lshift_val
=
idc.get_operand_value(temp_addr,
2
)
temp_addr
=
idc.prev_head(temp_addr)
if
jump_array_addr
=
=
0
:
temp_addr
=
CSET_addr
while
temp_addr > text_seg.start_ea:
if
idc.print_insn_mnem(temp_addr)
=
=
"ADRL"
:
if
idc.print_operand(temp_addr,
0
)
=
=
jump_array_reg:
jump_array_addr
=
idc.get_operand_value(temp_addr,
1
)
nop_addr_array_temp.append(temp_addr)
break
elif
idc.print_insn_mnem(temp_addr)
=
=
"ADRP"
:
if
idc.print_operand(temp_addr,
0
)
=
=
jump_array_reg:
jump_array_addr
=
idc.get_operand_value(temp_addr,
1
)
nop_addr_array_temp.append(temp_addr)
while
temp_addr < text_seg.end_ea:
if
idc.print_insn_mnem(temp_addr)
=
=
"ADD"
:
if
idc.print_operand(temp_addr,
0
)
=
=
jump_array_reg:
jump_array_addr
+
=
idc.get_operand_value(temp_addr,
2
)
nop_addr_array_temp.append(temp_addr)
break
temp_addr
=
idc.next_head(temp_addr)
break
temp_addr
=
idc.prev_head(temp_addr)
if
add_val
=
=
0
:
temp_addr
=
CSET_addr
while
temp_addr > text_seg.start_ea:
if
idc.print_insn_mnem(temp_addr)
=
=
"MOV"
:
if
idc.print_operand(temp_addr,
0
)[
1
::]
in
add_reg:
add_val
=
idc.get_operand_value(temp_addr,
1
)
nop_addr_array_temp.append(temp_addr)
break
elif
idc.print_insn_mnem(temp_addr)
=
=
"MOVK"
:
if
idc.print_operand(temp_addr,
0
)[
1
::]
in
add_reg:
add_val
=
(idc.get_operand_value(temp_addr,
1
) <<
16
)
while
temp_addr > text_seg.start_ea:
if
idc.print_insn_mnem(temp_addr)
=
=
"MOV"
:
if
idc.print_operand(temp_addr,
0
)[
1
::]
in
add_reg:
add_val
+
=
idc.get_operand_value(temp_addr,
1
)
break
temp_addr
=
idc.prev_head(temp_addr)
break
temp_addr
=
idc.prev_head(temp_addr)
branch_a
=
(ida_bytes.get_qword(jump_array_addr
+
(
1
<< Lshift_val))
+
add_val) &
0xffffffffffffffff
branch_b
=
(ida_bytes.get_qword(jump_array_addr
+
(
0
<< Lshift_val))
+
add_val) &
0xffffffffffffffff
logic_rev
=
{
"GE"
:
"LT"
,
"LT"
:
"GE"
,
"EQ"
:
"NE"
,
"NE"
:
"EQ"
,
"CC"
:
"CS"
,
"CS"
:
"CC"
,
"HI"
:
"LS"
,
"LS"
:
"HI"
}
ks
=
Ks(KS_ARCH_ARM64, KS_MODE_LITTLE_ENDIAN)
code
=
""
if
branch_b
=
=
idc.next_head(BR_addr):
code
=
f
"B.{CSET_cond} #{hex(branch_a)}"
elif
branch_a
=
=
idc.next_head(BR_addr):
code
=
f
"B.{logic_rev[CSET_cond]} #{hex(branch_b)}"
if
code !
=
"":
patch_br_byte, count
=
ks.asm(code, addr
=
BR_addr)
ida_bytes.patch_bytes(BR_addr, bytes(patch_br_byte))
print
(f
"fix CSET-BR at {hex(BR_addr)}"
)
nop_addr_array_after_finish.extend(nop_addr_array_temp)
current_addr
=
idc.next_head(BR_addr)
continue
else
:
print
(f
"error! unable to fix CSET-BR at {hex(current_addr)},branch:{hex(branch_a)}, {hex(branch_b)}"
)
current_addr
=
idc.next_head(current_addr)
for
addr
in
nop_addr_array_after_finish:
patch_nop(addr, addr
+
idc.get_item_size(addr))
import
ida_segment
import
idautils
import
idc
import
ida_bytes
from
keystone
import
*
def
patch_nop(begin, end):
while
end > begin:
ida_bytes.patch_bytes(begin, b
'\x1F\x20\x03\xD5'
)
begin
=
begin
+
4
text_seg
=
ida_segment.get_segm_by_name(
".text"
)
start, end
=
text_seg.start_ea, text_seg.end_ea
current_addr
=
start
nop_addr_array_after_finish
=
[]
while
current_addr < end:
if
idc.print_insn_mnem(current_addr)
=
=
"CSEL"
:
CSEL_addr
=
current_addr
nop_addr_array_temp
=
[]
[招生]科锐逆向工程师培训(2024年11月15日实地,远程教学同时开班, 第51期)
最后于 2023-11-17 18:48
被oacia编辑
,原因: 写了一个IDA插件实现trace so