CTF003


分析函数逻辑
打开入口函数后,可以发现把校验函数写在so库里了

IDA分析so库文件
那接下来用ida打开_native-lib.so_进行分析,文件打开之后可以直接搜索到这个函数,可以看到如果没有动态加载的话,java层映射到native层的本地函数命名特点Java+包名+函数名

修复参数
这个函数解析的看起来比较乱,我们可以修复一下参数类型看会不会好点
- 在jadx里面看到只传递了一个参数,这里可以看到又三个参数,实际只有第三个参数_a3_才是我们传递的字符串参数,_a1_是JNIEnv* ,_a2_是JavaObject(表示Java层调用该JNI函数的对象的引用(即Java对象的指针))
修复完成之后我们来看一下这个函数

根据图中可知返回值来自于strcmp的比较结果,只有返回值为true也就是两个参数相等的情况下,验证才能通过。_strcmp_的两个参数都来自于_convertUnCharToStr_方法。这样的话可以尝试一下看能不能用_frida-trace_跟踪一下调用函数来查看这两个参数的值分别是什么
使用frida-trace来hook函数的传参

这里我们可以看到成功的跟踪到了这两个函数,但是_strcmp()_触发的有点多,可能代码里面有很多比较的地方,
_convertUnCharToStr()_触发较少方便我们查看参数。
来查看一下跟踪到的函数:发现这里没有识别出来函数的参数可能是因为识别不准确造成的

根据函数原型编写hook脚本
void convertUnCharToStr(char* str, unsigned char* UnChar, int ucLen)
根据函数原型修改一下代码读取一下参数的值:获取so库函数的参数需要从内存中读取

修改完成之后保存,再点击验证按钮执行的时候看脚本打印结果

可以看到一串能读懂的字符串我们来试一下这个是不是就是flag

输入之后点击验证按钮我们就能看到这个信封解封了
over~
- 标题: CTF003
- 作者: xiaoeryu
- 创建于 : 2023-07-09 14:43:10
- 更新于 : 2023-07-09 14:48:13
- 链接: https://github.com/xiaoeryu/2023/07/09/CTF003/
- 版权声明: 本文章采用 CC BY-NC-SA 4.0 进行许可。
评论