使用IDA逆向Android的.so动态库文件

http://blog.csdn.net/prsniper/article/details/50495926

最近将一个反复刷机闲置的山寨机用作游戏机,安装一个叫Townsmen的游戏,蹦出一个占了1/3屏幕的广告

跟阿里YunOS系统无法Root一样,我原以为只有中国妓造才那么无耻,没想到……

屏幕是我的,商家无权抢占消费者的任何合法资产,所以,切你没商量

1.反编译townsmen7_36.apk文件

命令为(目录因具体情况而异):

[plain] view plain copy

  1. java -Xmx512m -jar "platform-tools\apktool_2.0.3.jar" d -o "project/townsmen7_36" "input/townsmen7_36.apk"  


如图:

2.用IDA打开.so文件

目录为project\townsmen7_36\lib下对应指令集文件夹,选择ARM指令集处理器(以armeabi为例)

点击搜索菜单,搜索文本

输入"hasADs",勾选"查找全部出现处",点"ok"

搜索结果出现很多,唯一的iniNewProfile应该就是创建新存档时的接口(如果有Root权限也可以直接修改存档)

双击定位

再双击iniNewProfile定位到该函数的指令处

注意指令0x3EA114处,就是这里默认给新建档案写入hasAds=1(true)

切换到Hex-View,显示01 32,如图

右键"Edit"直接按数字键改为0,再右键"Apply Changes"保存,如图

修改处变色如图

切换回IDA View发现指令已经变成

[plain] view plain copy

  1. .text:003EA114                 ADDS    R2, #0  


注意:这里并不会直接修改文件本身,只是确定我们的修改是正确的

然后打开WinHex或者UE(UltraEdit),定位到003EA114,用相同的方法修改二进制数据

同样方法修改armeabi-v7a和x86的.so动态库,x86就更简单了,大家都熟悉的,下面是我的笔记

[plain] view plain copy

  1. [x86]  
  2. //.text:00628E33                                         ; game::UserProfile::hasAds(void)+362j ...  
  3. //.text:00628E33                 movzx   eax, byte ptr [esp+13Ch+var_11C]       ; 返回值  
  4. //>>0F B6 44 24 20  
  5. //1000100A      0FB64424 20               movzx   eax, byte ptr [esp+20]           ; /ProcNameOrOrdinal  
  6. //1000100A      B8 00000000               mov     eax, 0  
  7. .text:0062E5E0 ; game::UserProfile::initNewProfile(void)  
  8. .text:0062E5E0                 public _ZN4game11UserProfile14initNewProfileEv  
  9. .text:0062E5E0 _ZN4game11UserProfile14initNewProfileEv proc near  
  10. .text:0062E5E0                                         ; CODE XREF: game::UserProfile::getInstance(void)  
  11.   
  12. .text:0062E622                 lea     eax, (unk_8981F2 - 0A39A08h)[ebx]    ; db 1  
  13. .rodata:008981F2 unk_8981F2      db    0                 ; DATA XREF: game::UserProfile::initNewProfile(void)+42o  
  14. >> 00  
  15.   
  16. [ARM]  
  17. //.text:003E94BE                 MOVS    R0, R5                 ; 返回值  
  18. //.text:003E94C0                 POP     {R1-R5,PC}  
  19. //.text:003E94C0 ; End of function game::UserProfile::hasAds(void)  
  20. //>> 28 1C  
  21. //.text:003E94BE                 MOVS    R0, #0  
  22. //>> 00 20  
  23. .text:003EA0F4 ; game::UserProfile::initNewProfile(void)  
  24. .text:003EA0F4                 EXPORT _ZN4game11UserProfile14initNewProfileEv  
  25. .text:003EA0F4 _ZN4game11UserProfile14initNewProfileEv ; CODE XREF: game::UserProfile::getInstance(void)  
  26.   
  27. .text:003EA114                 ADDS    R2, #1  
  28. >> 01 32  
  29. .text:003EA114                 ADDS    R2, #0  
  30. >> 00 32  
  31.   
  32. [ARMv7a]  
  33. .text:003DFE04 ; game::UserProfile::initNewProfile(void)  
  34. .text:003DFE04                 EXPORT _ZN4game11UserProfile14initNewProfileEv  
  35. .text:003DFE04 _ZN4game11UserProfile14initNewProfileEv ; CODE XREF: game::UserProfile::getInstance(void)  
  36.   
  37. .text:003DFE26                 ADDS            R2, #1  
  38. >> 01 32  
  39. .text:003DFE26                 ADDS            R2, #0  
  40. >> 00 32  


3.可选的配置文件修改

在project\townsmen7_36\assets\data下有很多XML文件,都是任务设置,需要的资源,奖励的资源等等

如tutorial.xml是新手教程的人物配置,资源代码如下(也是笔记,未完全测试,另外不建议修改游戏平衡)

[plain] view plain copy

  1. [/assets/data]  
  2. //   
  3. // prestige=声望, coins=金币  
  4. // wood=木材  fish=鱼      [lupulus=啤酒花]   gold=金矿 pig=猪       fabric=布料  
  5. // planks=木板    bread=面包    corn=谷物     iron=铁块 [fur=皮毛]    cloths=衣物  
  6. // stone=石料 meat=肉      flour=面粉        nuggets=金块  [leather=皮革]    jewelry=首饰  
  7. // tools=工具 herbs=草药    coal=煤          weapons=武器  sausage=香肠  juice=果汁  
  8. // [water=水]    grapes=葡萄   ore=铁矿      armor=装甲    wool=羊毛 brew=酿酒  
  9. //   
  10. // 其它: bandits是强盗, FROZENPLAIN为冰原, <xp value="50000" />是经验值, tribute是贡品, deco=装饰品  


以沙盒模式通用任务quests_sandbox.xml为例,下面是以2500金币换取5点声望的任务设置

4.回编译apk文件

命令如下

[plain] view plain copy

  1. java -Xmx512m -jar "platform-tools\apktool_2.0.3.jar" b -o "output/townsmen7_36.apk" "project/townsmen7_36"  


注意关闭有关打开的文件,如图

5.签名apk文件

命令为

[plain] view plain copy

  1. java -Xmx512m -jar "tools\signapk.jar" -w "tools\testkey.x509.pem" "tools\testkey.pk8" "output/townsmen7_36.apk" "release/townsmen7_36.apk"  


在Release文件夹下就有了破解后的apk了,如图

放到你的手枪机上,任意的奸淫吧

阿弥陀佛,罪过,罪过!

猜你喜欢

转载自blog.csdn.net/qq_27173485/article/details/77206628