【Android 逆向】ARM while 逆向
#include <stdio.h>
int dowhile(int n){
int i = 1;
int s = 0;
do{
s += i;
}while(i++ < n);
return s;
}
int whiledo(int n){
int i = 1;
int s = 0;
while(i <= n){
s += i++;
}
return s;
}
int main(int argc, char* argv[]){
printf("dowhile:%d\n", dowhile(100));
printf("while:%d\n", whiledo(100));
return 0;
}
.text:00008570 ; =============== S U B R O U T I N E =======================================
.text:00008570
.text:00008570
.text:00008570 doWhile ; CODE XREF: main+8↓p
.text:00008570 ; __unwind {
.text:00008570 MOV R2, #0
.text:00008574 MOV R3, #1 ; i = 1 s=0
.text:00008578
.text:00008578 loc_8578 ; CODE XREF: doWhile+18↓j
.text:00008578 ADD R2, R2, R3 ; s = s + i
.text:0000857C ADD R3, R3, #1 ; i++
.text:00008580 SUB R1, R3, #1 ; tmp = i -1
.text:00008584 CMP R0, R1
.text:00008588 BGT loc_8578 ; if arg0(n) > tmp continue继续循环
.text:0000858C MOV R0, R2 ; r0 为return值 r0 = s
.text:00008590 BX LR ; 使用LR的值跳转出函数
.text:00008590 ; } // starts at 8570
.text:00008590 ; End of function doWhile
.text:00008590
.text:00008594
.text:00008594 ; =============== S U B R O U T I N E =======================================
.text:00008594
.text:00008594
.text:00008594 whileDo ; CODE XREF: main+20↓p
.text:00008594 ; __unwind {
.text:00008594 SUBS R2, R0, #0
.text:00008598 MOVLE R0, #0
.text:0000859C BXLE LR ; if n <= 0 跳出函数
.text:000085A0 MOV R0, #0 ; s = 0
.text:000085A4 MOV R3, #1 ; i = 1
.text:000085A8
.text:000085A8 loc_85A8 ; CODE XREF: whileDo+20↓j
.text:000085A8 ADD R0, R0, R3 ; s += i
.text:000085AC ADD R3, R3, #1 ; i++
.text:000085B0 CMP R2, R3
.text:000085B4 BGE loc_85A8 ; if n >= i contiue
.text:000085B8 BX LR
.text:000085B8 ; } // starts at 8594
.text:000085B8 ; End of function whileDo
.text:000085B8
.text:000085BC
.text:000085BC ; =============== S U B R O U T I N E =======================================
.text:000085BC
.text:000085BC
.text:000085BC ;
.text:000085BC
.text:000085BC ; int __cdecl main(int argc, const char **argv, const char **envp)
.text:000085BC main ; CODE XREF: j_main↑j
.text:000085BC ; __unwind {
.text:000085BC PUSH {R4,LR} ; 栈上保存R4 和 LR 的值
.text:000085C0 MOV R0, #0x64 ; 'd' ; 为RO 赋值100
.text:000085C4 BL doWhile ; 跳转到doWhile。同时给LR赋值为0x85C8
.text:000085C8 MOV R1, R0
.text:000085CC LDR R0, =(aDowhileD - 0x85D8) ; 获取字符串在GOT的偏移
.text:000085D0 ADD R0, PC, R0 ; 获取字符串实际首地址
.text:000085D4 BL printf
.text:000085D8 MOV R0, #0x64 ; 'd' ; 为R0 赋值100
.text:000085DC BL whileDo ; 跳转到doWhile。同时给LR赋值为0x85E0
.text:000085E0 MOV R1, R0
.text:000085E4 LDR R0, =(aWhileD - 0x85F0) ; "while:%d\n"
.text:000085E8 ADD R0, PC, R0 ; "while:%d\n"
.text:000085EC BL printf
.text:000085F0 MOV R0, #0
.text:000085F4 POP {R4,PC}
.text:000085F4 ; End of function main
.text:000085F4
.text:000085F4 ; -----
【Android 逆向】ARM while 逆向的更多相关文章
- 使用IDA pro逆向ARM M系核心的Bin固件
使用IDA pro逆向ARM M系核心的Bin固件 物联网和智能设备这两年还是比较火的,我们的手中或多或少都有了几个智能设备,比如手环,智能手表,或者门锁什么之类的东西,但是同学们在做逆向的时候, ...
- 【基于Android的ARM汇编语言系列】之五:ARM指令集与Thumb指令集
作者:郭嘉 邮箱:allenwells@163.com 博客:http://blog.csdn.net/allenwells github:https://github.com/AllenWell [ ...
- 【基于Android的ARM汇编语言系列】之三:ARM汇编语言程序结构
作者:郭嘉 邮箱:allenwells@163.com 博客:http://blog.csdn.net/allenwells github:https://github.com/AllenWell [ ...
- 20145219《网络对抗技术》PC平台逆向破解之逆向与Bof基础
20145219<网络对抗技术>PC平台逆向破解之逆向与Bof基础 实践目标 实践对象:一个名为pwn1的linux可执行文件. pwn1正常执行流程:main调用foo函数,foo函数会 ...
- 【android逆向】 ARM for 逆向
C源码 #include <stdio.h> int nums[5] = {1, 2, 3, 4, 5}; int for1(int n){ //普通for循环 int i = 0; in ...
- 【Android 逆向】ARM switch 逆向
#include <stdio.h> int switch1(int a, int b, int i){ switch (i){ case 1: return a + b; break; ...
- 一些Android程序的反逆向方法
1.检测调试器 在代码中检测调试器的动态调试 首先在AndroidMainfest.xml文件中设置android:debuggable="false",让程序不可调试.这样别人想 ...
- [Android Security] Smali和逆向分析
copy : https://blog.csdn.net/u012573920/article/details/44034397 1.Smali简介 Smali是Dalvik的寄存器语言,它与Java ...
- 【逆向工具】逆向工具101editor使用-游戏快速通关
[渡者游戏简介] 船夫小江将运送客人的,羊.狐狸.草等物品过河,如果留下动物被其它种类吃掉任务就失败了.你需要帮助他做出正确的顺序选择.Ferryman是一款根据经典谜题改编的解谜游戏. 一.查看文件 ...
随机推荐
- 所有人都说Python 简单易学,为何我觉得难?
来谈谈心 记得刚学Python的时候,几乎所有人都说Python 简单易学,而对于编程零基础,只掌握Word和Excel的人来说,感觉真的好难. 学习之前网上的教材看了,Python的书也看了,包括& ...
- FDFS上传文件报错 tracker_query_storage fail, error no: 2, error info: No such file or directo
原因: 1.tracker服务没有启动 2.Storage服务没有启动 解决方案: 输入命令查看这两个服务是否启动,如果没有则表明没有启动.启动即可. netstat -tulnp tracker服务 ...
- HiEngine:可媲美本地的云原生内存数据库引擎
摘要:HiEngine与华为GaussDB (for MySQL)集成,将内存数据库引擎的优势带到云端,并与基于磁盘的引擎共存.HiEngine的性能比传统的以存储为中心的解决方案高出7.5倍. 本文 ...
- MISC 2022/4/21 刷题记录-千字文
1.千字文 得到名为png的无类型文件,010 Editor查看,png,改后缀,得到二维码 QR扫描,得到一句话"这里只有二维码" 思路不对,binwalk一下,发现有错误信息 ...
- elastic-job和spring cloud版本冲突2
***************************APPLICATION FAILED TO START*************************** Description: An at ...
- Note -「Dijkstra 求解 MCMF」
食用前请先了解 SPFA + Dinic/EK 求解 MCMF. Sol. 总所周知,SPFA 牺牲了.于是我们寻求一些更稳定的算法求解 MCMF. 网络流算法的时间属于玄学,暂且判定为混乱中的稳定. ...
- 从工程师到技术leader思维升级
身处职场之中,太多话题相围绕,"个人成长"."管理"或许是讨论的最多的了. 但"个人成长"和"管理"却是大不相同的两件事 ...
- shell中各种括号的用法
一.单小括号()1.将某个命令的返回值作为某个变量的值进行传递 #!/bin/bash USER=$(whoami) echo $USER [root@jump ~]# for i in $(seq ...
- ExpressionChangedAfterItHasBeenCheckedError详细解释
一个angular组件,他的生命周期是这样的 update bound properties for all child components/directives call ngOnInit, On ...
- javascript相邻节点元素获取
<script> window.onload = function () { var myLinkItem = document.getElementById('linkItem'); v ...