注意:以下内容仅仅是我的一次逆向学习过程,本人逆向经验也不丰富;开这个帖子更多的的是向各位学习逆向技术以及记录自己的学习过程。如果我的做法有不准确的地方,希望各位高手给与指正,如果文章中有任何不当或是侵犯你利益之处也请直接告之。我将立即删除掉。
今天接到一个朋友的请求,让我定位下一个应用中的被隐藏的函数getURLFromLinkShell。
应用名称:xxx家,视频应用。
首先看看这个应用中有哪些本地库:
libbspatch.so 是百度push库,不管。
liblinkShe**.so看这个库的名字像是应用保护的。
libut***.so看名字像是一个网络应用库,不管。
首先安装应用跑起来看看,这个应用是个视频直播软件。
既然正常,那就先上jadx,搜索native或getURLFromLinkSh**。
很容易就找到了这个函数,顺便再看看其它native函数。
public void onCreate(Bundle savedInstanceState) {
m_mainActivity = this;
getWindow().setFormat(1);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Log.d("linkshell", initLinkSh**() + BuildConfig.VERSION_NAME);
...........................
}
public native int initLinkShe**();这个函数应该是初始化,定位下调用看看猜测。
看样子明显是初始化接口。
既然这么明显,看样子朋友的这个要求很快就能完成了。
,先高兴下。
既然这样,那就直接上IDA。
从上面图中看到了大量的curl函数,我有点担心目标函数getURLFromLinkShe**可能使用了网络通信。
接下来就是定位这个导出函数,从下面这个图中可以看出,这个导出函数被隐藏了。我预感不太妙。
既然被隐藏了,按照惯例就只有分析JNI_OnLoad了:
.text:00013DD0 EXPORT JNI_OnLoad
.text:00013DD0 JNI_OnLoad
.text:00013DD0
.text:00013DD0 var_AC = -0xAC
.text:00013DD0 var_A8 = -0xA8
.text:00013DD0 var_A4 = -0xA4
.text:00013DD0 var_A0 = -0xA0
.text:00013DD0 var_9C = -0x9C
.text:00013DD0 var_94 = -0x94
.text:00013DD0 var_7C = -0x7C
.text:00013DD0 var_74 = -0x74
.text:00013DD0 var_70 = -0x70
.text:00013DD0 var_64 = -0x64
.text:00013DD0 var_5C = -0x5C
.text:00013DD0 var_58 = -0x58
.text:00013DD0 var_4C = -0x4C
.text:00013DD0 var_40 = -0x40
.text:00013DD0 var_34 = -0x34
.text:00013DD0 var_28 = -0x28
.text:00013DD0 var_1C = -0x1C
.text:00013DD0
.text:00013DD0 F0 B5 PUSH {R4-R7,LR}
.text:00013DD2 84 4B LDR R3, =(_GLOBAL_OFFSET_TABLE_ - 0x13DDC)
.text:00013DD4 84 4A LDR R2, =(__stack_chk_guard_ptr - 0x91DB0)
.text:00013DD6 A7 B0 SUB SP, SP, #0x9C
.text:00013DD8 7B 44 ADD R3, PC ; _GLOBAL_OFFSET_TABLE_
.text:00013DDA 9C 58 LDR R4, [R3,R2] ; __stack_chk_guard
.text:00013DDC 04 A9 ADD R1, SP, #0xB0+var_A0
.text:00013DDE 83 4A LDR R2, =0x10006
.text:00013DE0 23 68 LDR R3, [R4]
.text:00013DE2 25 93 STR R3, [SP,#0xB0+var_1C]
.text:00013DE4 03 68 LDR R3, [R0]
.text:00013DE6 9B 69 LDR R3, [R3,#0x18]
.text:00013DE8 98 47 BLX R3 ; _GLOBAL_OFFSET_TABLE_
.text:00013DEA 03 94 STR R4, [SP,#0xB0+var_A4]
.text:00013DEC 00 28 CMP R0, #0
.text:00013DEE 00 D0 BEQ loc_13DF2
.text:00013DF0 CC E0 B loc_13F8C
.text:00013DF2 ; ---------------------------------------------------------------------------
.text:00013DF2
.text:00013DF2 loc_13DF2 ; CODE XREF: JNI_OnLoad+1Ej
.text:00013DF2 7F 4A LDR R2, =(unk_7E9A1 - 0x13E00)
.text:00013DF4 22 AC ADD R4, SP, #0xB0+var_28
.text:00013DF6 5F 21 MOVS R1, #0x5F
.text:00013DF8 20 23 MOVS R3, #0x20
.text:00013DFA 20 1C MOVS R0, R4
.text:00013DFC 7A 44 ADD R2, PC
.text:00013DFE 04 9D LDR R5, [SP,#0xB0+var_A0]
.text:00013E00 FF F7 C0 FF BL sub_13D84
.text:00013E04 23 78 LDRB R3, [R4]
.text:00013E06 69 46 MOV R1, SP
.text:00013E08 89 31 ADDS R1, #0x89
.text:00013E0A D8 07 LSLS R0, R3, #0x1F
.text:00013E0C 00 D5 BPL loc_13E10
.text:00013E0E A1 68 LDR R1, [R4,#8]
.text:00013E10
.text:00013E10 loc_13E10 ; CODE XREF: JNI_OnLoad+3Cj
.text:00013E10 2B 68 LDR R3, [R5]
.text:00013E12 28 1C MOVS R0, R5
.text:00013E14 9B 69 LDR R3, [R3,#0x18]
.text:00013E16 98 47 BLX R3 ; _GLOBAL_OFFSET_TABLE_
.text:00013E18 02 90 STR R0, [SP,#0xB0+var_A8]
.text:00013E1A 20 1C MOVS R0, R4
.text:00013E1C FE F7 78 FB BL _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEED2Ev ; std::__1::basic_string<char,std::__1::char_traits<char>,std::__1::allocator<char>>::~basic_string()
.text:00013E20 04 99 LDR R1, [SP,#0xB0+var_A0]
.text:00013E22 02 9A LDR R2, [SP,#0xB0+var_A8]
.text:00013E24 05 AF ADD R7, SP, #0xB0+var_9C
.text:00013E26 05 91 STR R1, [SP,#0xB0+var_9C]
.text:00013E28 7A 60 STR R2, [R7,#4]
.text:00013E2A 00 2A CMP R2, #0
.text:00013E2C 00 D1 BNE loc_13E30
.text:00013E2E A7 E0 B loc_13F80
.text:00013E30 ; ---------------------------------------------------------------------------
.text:00013E30
.text:00013E30 loc_13E30 ; CODE XREF: JNI_OnLoad+5Cj
.text:00013E30 70 4A LDR R2, =(unk_7E993 - 0x13E3C)
.text:00013E32 10 AD ADD R5, SP, #0xB0+var_70
.text:00013E34 28 1C MOVS R0, R5
.text:00013E36 16 21 MOVS R1, #0x16
.text:00013E38 7A 44 ADD R2, PC
.text:00013E3A 0D 23 MOVS R3, #0xD
.text:00013E3C FF F7 A2 FF BL sub_13D84
.text:00013E40 2B 78 LDRB R3, [R5]
.text:00013E42 6E 46 MOV R6, SP
.text:00013E44 41 36 ADDS R6, #0x41
.text:00013E46 D8 07 LSLS R0, R3, #0x1F
.text:00013E48 00 D5 BPL loc_13E4C
.text:00013E4A AE 68 LDR R6, [R5,#8]
.text:00013E4C
.text:00013E4C loc_13E4C ; CODE XREF: JNI_OnLoad+78j
.text:00013E4C 30 1C MOVS R0, R6
.text:00013E4E 64 F0 DF FD BL sub_78A10
.text:00013E52 ; ---------------------------------------------------------------------------
.text:00013E52 31 1C MOVS R1, R6
.text:00013E54 02 1C MOVS R2, R0
.text:00013E56 0D A8 ADD R0, SP, #0xB0+var_7C
.text:00013E58 FF F7 1E FD BL _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6__initEPKcj ; std::__1::basic_string<char,std::__1::char_traits<char>,std::__1::allocator<char>>::__init(char const*,uint)
.text:00013E5C ; ---------------------------------------------------------------------------
.text:00013E5C 28 1C MOVS R0, R5
.text:00013E5E FE F7 57 FB BL _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEED2Ev ; std::__1::basic_string<char,std::__1::char_traits<char>,std::__1::allocator<char>>::~basic_string()
.text:00013E62 65 4A LDR R2, =(unk_7E98F - 0x13E6E)
.text:00013E64 16 AD ADD R5, SP, #0xB0+var_58
.text:00013E66 28 1C MOVS R0, R5
.text:00013E68 4C 21 MOVS R1, #0x4C
.text:00013E6A 7A 44 ADD R2, PC
.text:00013E6C 03 23 MOVS R3, #3
.text:00013E6E FF F7 89 FF BL sub_13D84
.text:00013E72 2B 78 LDRB R3, [R5]
.text:00013E74 6E 46 MOV R6, SP
.text:00013E76 59 36 ADDS R6, #0x59
.text:00013E78 D9 07 LSLS R1, R3, #0x1F
.text:00013E7A 00 D5 BPL loc_13E7E
.text:00013E7C AE 68 LDR R6, [R5,#8]
.text:00013E7E
.text:00013E7E loc_13E7E ; CODE XREF: JNI_OnLoad+AAj
.text:00013E7E 30 1C MOVS R0, R6
.text:00013E80 64 F0 C6 FD BL sub_78A10
.text:00013E84 ; ---------------------------------------------------------------------------
.text:00013E84 31 1C MOVS R1, R6
.text:00013E86 02 1C MOVS R2, R0
.text:00013E88 13 A8 ADD R0, SP, #0xB0+var_64
.text:00013E8A FF F7 05 FD BL _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6__initEPKcj ; std::__1::basic_string<char,std::__1::char_traits<char>,std::__1::allocator<char>>::__init(char const*,uint)
.text:00013E8E ; ---------------------------------------------------------------------------
.text:00013E8E 28 1C MOVS R0, R5
.text:00013E90 FE F7 3E FB BL _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEED2Ev ; std::__1::basic_string<char,std::__1::char_traits<char>,std::__1::allocator<char>>::~basic_string()
.text:00013E94 59 4A LDR R2, =(unk_7E97B - 0x13EA0)
.text:00013E96 1C AD ADD R5, SP, #0xB0+var_40
.text:00013E98 28 1C MOVS R0, R5
.text:00013E9A 4F 21 MOVS R1, #0x4F
.text:00013E9C 7A 44 ADD R2, PC
.text:00013E9E 13 23 MOVS R3, #0x13
.text:00013EA0 FF F7 70 FF BL sub_13D84
.text:00013EA4 2B 78 LDRB R3, [R5]
.text:00013EA6 6A 46 MOV R2, SP
.text:00013EA8 71 32 ADDS R2, #0x71
.text:00013EAA 01 92 STR R2, [SP,#0xB0+var_AC]
.text:00013EAC D8 07 LSLS R0, R3, #0x1F
.text:00013EAE 01 D5 BPL loc_13EB4
.text:00013EB0 A9 68 LDR R1, [R5,#8]
.text:00013EB2 01 91 STR R1, [SP,#0xB0+var_AC]
.text:00013EB4
.text:00013EB4 loc_13EB4 ; CODE XREF: JNI_OnLoad+DEj
.text:00013EB4 01 98 LDR R0, [SP,#0xB0+var_AC]
.text:00013EB6 64 F0 AB FD BL sub_78A10
.text:00013EBA ; ---------------------------------------------------------------------------
.text:00013EBA 19 AE ADD R6, SP, #0xB0+var_4C
.text:00013EBC 02 1C MOVS R2, R0
.text:00013EBE 01 99 LDR R1, [SP,#0xB0+var_AC]
.text:00013EC0 30 1C MOVS R0, R6
.text:00013EC2 FF F7 E9 FC BL _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6__initEPKcj ; std::__1::basic_string<char,std::__1::char_traits<char>,std::__1::allocator<char>>::__init(char const*,uint)
.text:00013EC6 ; ---------------------------------------------------------------------------
.text:00013EC6 28 1C MOVS R0, R5
.text:00013EC8 FE F7 22 FB BL _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEED2Ev ; std::__1::basic_string<char,std::__1::char_traits<char>,std::__1::allocator<char>>::~basic_string()
.text:00013ECC 4C 4A LDR R2, =(unk_7E954 - 0x13ED6)
.text:00013ECE 20 1C MOVS R0, R4
.text:00013ED0 03 21 MOVS R1, #3
.text:00013ED2 7A 44 ADD R2, PC ; unk_7E954
.text:00013ED4 26 23 MOVS R3, #0x26
.text:00013ED6 FF F7 55 FF BL sub_13D84
.text:00013EDA 23 78 LDRB R3, [R4]
.text:00013EDC 6A 46 MOV R2, SP
.text:00013EDE 89 32 ADDS R2, #0x89
.text:00013EE0 01 92 STR R2, [SP,#0xB0+var_AC]
.text:00013EE2 D8 07 LSLS R0, R3, #0x1F
.text:00013EE4 01 D5 BPL loc_13EEA
.text:00013EE6 A1 68 LDR R1, [R4,#8]
.text:00013EE8 01 91 STR R1, [SP,#0xB0+var_AC]
.text:00013EEA
.text:00013EEA loc_13EEA ; CODE XREF: JNI_OnLoad+114j
.text:00013EEA 01 98 LDR R0, [SP,#0xB0+var_AC]
.text:00013EEC 64 F0 90 FD BL sub_78A10
.text:00013EF0 ; ---------------------------------------------------------------------------
.text:00013EF0 1F AD ADD R5, SP, #0xB0+var_34
.text:00013EF2 02 1C MOVS R2, R0
.text:00013EF4 01 99 LDR R1, [SP,#0xB0+var_AC]
.text:00013EF6 28 1C MOVS R0, R5
.text:00013EF8 FF F7 CE FC BL _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6__initEPKcj ; std::__1::basic_string<char,std::__1::char_traits<char>,std::__1::allocator<char>>::__init(char const*,uint)
.text:00013EFC ; ---------------------------------------------------------------------------
.text:00013EFC 20 1C MOVS R0, R4
.text:00013EFE FE F7 07 FB BL _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEED2Ev ; std::__1::basic_string<char,std::__1::char_traits<char>,std::__1::allocator<char>>::~basic_string()
.text:00013F02 0D AA ADD R2, SP, #0xB0+var_7C
.text:00013F04 11 78 LDRB R1, [R2]
.text:00013F06 6B 46 MOV R3, SP
.text:00013F08 35 33 ADDS R3, #0x35
.text:00013F0A C8 07 LSLS R0, R1, #0x1F
.text:00013F0C 00 D5 BPL loc_13F10
.text:00013F0E 0F 9B LDR R3, [SP,#0xB0+var_74]
.text:00013F10
.text:00013F10 loc_13F10 ; CODE XREF: JNI_OnLoad+13Cj
.text:00013F10 07 93 STR R3, [SP,#0xB0+var_94]
.text:00013F12 13 AB ADD R3, SP, #0xB0+var_64
.text:00013F14 19 78 LDRB R1, [R3]
.text:00013F16 6A 46 MOV R2, SP
.text:00013F18 4D 32 ADDS R2, #0x4D
.text:00013F1A C8 07 LSLS R0, R1, #0x1F
.text:00013F1C 00 D5 BPL loc_13F20
.text:00013F1E 15 9A LDR R2, [SP,#0xB0+var_5C]
.text:00013F20
.text:00013F20 loc_13F20 ; CODE XREF: JNI_OnLoad+14Cj
.text:00013F20 07 AB ADD R3, SP, #0xB0+var_94
.text:00013F22 5A 60 STR R2, [R3,#4]
.text:00013F24 37 4A LDR R2, =(sub_1AABC+1 - 0x13F2C)
.text:00013F26 31 78 LDRB R1, [R6]
.text:00013F28 7A 44 ADD R2, PC ; sub_1AABC
.text:00013F2A 9A 60 STR R2, [R3,#8]
.text:00013F2C 6A 46 MOV R2, SP
.text:00013F2E 65 32 ADDS R2, #0x65
.text:00013F30 C8 07 LSLS R0, R1, #0x1F
.text:00013F32 00 D5 BPL loc_13F36
.text:00013F34 B2 68 LDR R2, [R6,#8]
.text:00013F36
.text:00013F36 loc_13F36 ; CODE XREF: JNI_OnLoad+162j
.text:00013F36 DA 60 STR R2, [R3,#0xC]
.text:00013F38 2A 78 LDRB R2, [R5]
.text:00013F3A 6B 46 MOV R3, SP
.text:00013F3C 7D 33 ADDS R3, #0x7D
.text:00013F3E D1 07 LSLS R1, R2, #0x1F
.text:00013F40 00 D5 BPL loc_13F44
.text:00013F42 AB 68 LDR R3, [R5,#8]
.text:00013F44
.text:00013F44 loc_13F44 ; CODE XREF: JNI_OnLoad+170j
.text:00013F44 07 AA ADD R2, SP, #0xB0+var_94
.text:00013F46 13 61 STR R3, [R2,#0x10]
.text:00013F48 2F 4B LDR R3, =(sub_1A864+1 - 0x13F52)
.text:00013F4A 04 98 LDR R0, [SP,#0xB0+var_A0]
.text:00013F4C 1F AC ADD R4, SP, #0xB0+var_34
.text:00013F4E 7B 44 ADD R3, PC ; sub_1A864
.text:00013F50 53 61 STR R3, [R2,#0x14]
.text:00013F52 01 68 LDR R1, [R0]
.text:00013F54 D7 23 9B 00 MOVS R3, #0x35C
.text:00013F58 CD 58 LDR R5, [R1,R3]
.text:00013F5A 02 99 LDR R1, [SP,#0xB0+var_A8]
.text:00013F5C 02 23 MOVS R3, #2
.text:00013F5E A8 47 BLX R5
.text:00013F60 22 4B LDR R3, =0x10006
.text:00013F62 C5 17 ASRS R5, R0, #0x1F
.text:00013F64 20 1C MOVS R0, R4
.text:00013F66 1D 43 ORRS R5, R3
.text:00013F68 FE F7 D2 FA BL _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEED2Ev ; std::__1::basic_string<char,std::__1::char_traits<char>,std::__1::allocator<char>>::~basic_string()
.text:00013F6C 30 1C MOVS R0, R6
.text:00013F6E FE F7 CF FA BL _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEED2Ev ; std::__1::basic_string<char,std::__1::char_traits<char>,std::__1::allocator<char>>::~basic_string()
.text:00013F72 13 A8 ADD R0, SP, #0xB0+var_64
.text:00013F74 FE F7 CC FA BL _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEED2Ev ; std::__1::basic_string<char,std::__1::char_traits<char>,std::__1::allocator<char>>::~basic_string()
.text:00013F78 0D A8 ADD R0, SP, #0xB0+var_7C
.text:00013F7A FE F7 C9 FA BL _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEED2Ev ; std::__1::basic_string<char,std::__1::char_traits<char>,std::__1::allocator<char>>::~basic_string()
.text:00013F7E 01 E0 B loc_13F84
.text:00013F80 ; ---------------------------------------------------------------------------
.text:00013F80
.text:00013F80 loc_13F80 ; CODE XREF: JNI_OnLoad+5Ej
.text:00013F80 01 25 MOVS R5, #1
.text:00013F82 6D 42 NEGS R5, R5
.text:00013F84
.text:00013F84 loc_13F84 ; CODE XREF: JNI_OnLoad+1AEj
.text:00013F84 38 1C MOVS R0, R7
.text:00013F86 FD F7 3D FD BL sub_11A04
.text:00013F8A 01 E0 B loc_13F90
.text:00013F8C ; ---------------------------------------------------------------------------
.text:00013F8C
.text:00013F8C loc_13F8C ; CODE XREF: JNI_OnLoad+20j
.text:00013F8C 01 25 MOVS R5, #1
.text:00013F8E 6D 42 NEGS R5, R5
.text:00013F90
.text:00013F90 loc_13F90 ; CODE XREF: JNI_OnLoad+1BAj
.text:00013F90 03 99 LDR R1, [SP,#0xB0+var_A4]
.text:00013F92 25 9A LDR R2, [SP,#0xB0+var_1C]
.text:00013F94 28 1C MOVS R0, R5
.text:00013F96 0B 68 LDR R3, [R1]
.text:00013F98 9A 42 CMP R2, R3
.text:00013F9A 21 D0 BEQ loc_13FE0
.text:00013F9C 64 F0 40 FD BL sub_78A20
.text:00013FA0 ; ---------------------------------------------------------------------------
.text:00013FA0 20 1C MOVS R0, R4
.text:00013FA2 FE F7 B5 FA BL _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEED2Ev ; std::__1::basic_string<char,std::__1::char_traits<char>,std::__1::allocator<char>>::~basic_string()
.text:00013FA6 19 E0 B loc_13FDC
.text:00013FA8 ; ---------------------------------------------------------------------------
.text:00013FA8 28 1C MOVS R0, R5
.text:00013FAA 11 E0 B loc_13FD0
.text:00013FAC ; ---------------------------------------------------------------------------
.text:00013FAC 28 1C MOVS R0, R5
.text:00013FAE 0B E0 B loc_13FC8
.text:00013FB0 ; ---------------------------------------------------------------------------
.text:00013FB0 28 1C MOVS R0, R5
.text:00013FB2 05 E0 B loc_13FC0
.text:00013FB4 ; ---------------------------------------------------------------------------
.text:00013FB4 FF E7 B loc_13FB6
.text:00013FB6 ; ---------------------------------------------------------------------------
.text:00013FB6
.text:00013FB6 loc_13FB6 ; CODE XREF: JNI_OnLoad+1E4j
.text:00013FB6 20 1C MOVS R0, R4
.text:00013FB8 FE F7 AA FA BL _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEED2Ev ; std::__1::basic_string<char,std::__1::char_traits<char>,std::__1::allocator<char>>::~basic_string()
.text:00013FBC FF E7 B loc_13FBE
.text:00013FBE ; ---------------------------------------------------------------------------
.text:00013FBE
.text:00013FBE loc_13FBE ; CODE XREF: JNI_OnLoad+1ECj
.text:00013FBE 19 A8 ADD R0, SP, #0xB0+var_4C
.text:00013FC0
.text:00013FC0 loc_13FC0 ; CODE XREF: JNI_OnLoad+1E2j
.text:00013FC0 FE F7 A6 FA BL _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEED2Ev ; std::__1::basic_string<char,std::__1::char_traits<char>,std::__1::allocator<char>>::~basic_string()
.text:00013FC4 FF E7 B loc_13FC6
.text:00013FC6 ; ---------------------------------------------------------------------------
.text:00013FC6
.text:00013FC6 loc_13FC6 ; CODE XREF: JNI_OnLoad+1F4j
.text:00013FC6 13 A8 ADD R0, SP, #0xB0+var_64
.text:00013FC8
.text:00013FC8 loc_13FC8 ; CODE XREF: JNI_OnLoad+1DEj
.text:00013FC8 FE F7 A2 FA BL _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEED2Ev ; std::__1::basic_string<char,std::__1::char_traits<char>,std::__1::allocator<char>>::~basic_string()
.text:00013FCC FF E7 B loc_13FCE
.text:00013FCE ; ---------------------------------------------------------------------------
.text:00013FCE
.text:00013FCE loc_13FCE ; CODE XREF: JNI_OnLoad+1FCj
.text:00013FCE 0D A8 ADD R0, SP, #0xB0+var_7C
.text:00013FD0
.text:00013FD0 loc_13FD0 ; CODE XREF: JNI_OnLoad+1DAj
.text:00013FD0 FE F7 9E FA BL _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEED2Ev ; std::__1::basic_string<char,std::__1::char_traits<char>,std::__1::allocator<char>>::~basic_string()
.text:00013FD4 FF E7 B loc_13FD6
.text:00013FD6 ; ---------------------------------------------------------------------------
.text:00013FD6
.text:00013FD6 loc_13FD6 ; CODE XREF: JNI_OnLoad+204j
.text:00013FD6 38 1C MOVS R0, R7
.text:00013FD8 FD F7 14 FD BL sub_11A04
.text:00013FDC
.text:00013FDC loc_13FDC ; CODE XREF: JNI_OnLoad+1D6j
.text:00013FDC 64 F0 D0 FC BL sub_78980
.text:00013FE0 ; ---------------------------------------------------------------------------
.text:00013FE0
.text:00013FE0 loc_13FE0 ; CODE XREF: JNI_OnLoad+1CAj
.text:00013FE0 27 B0 ADD SP, SP, #0x9C
.text:00013FE2 F0 BD POP {R4-R7,PC}
.text:00013FE2 ; End of function JNI_OnLoad
.text:00013FE2
.text:00013FE2 ; -----------------------------------
伪代码如下:
signed int __fastcall JNI_OnLoad(int a1)
{
int v1; // ST08_4@2
const char *v2; // r6@4
signed int result; // r0@7
int v4; // [sp+10h] [bp-A0h]@0
int v5; // [sp+14h] [bp-9Ch]@2
int v6; // [sp+18h] [bp-98h]@2
char v7; // [sp+40h] [bp-70h]@4
_BYTE v8[3]; // [sp+41h] [bp-6Fh]@4
const char *v9; // [sp+48h] [bp-68h]@5
char v10; // [sp+88h] [bp-28h]@2
int v11; // [sp+94h] [bp-1Ch]@1
v11 = _stack_chk_guard;
if ( !(*(int (__fastcall **)(int))(*(_DWORD *)a1 + 24))(a1) )
{
sub_13D84((int)&v10, 95, (int)&unk_7E9A1, 0x20u);
v1 = (*(int (__fastcall **)())(*(_DWORD *)v4 + 24))();
std::__1::basic_string<char,std::__1::char_traits<char>,std::__1::allocator<char>>::~basic_string((int)&v10);
v5 = v4;
v6 = v1;
if ( v1 )
{
sub_13D84((int)&v7, 22, (int)&unk_7E993, 0xDu);
v2 = v8;
if ( v7 & 1 )
v2 = v9;
sub_78A10(v2);
}
sub_11A04((int)&v5);
}
result = -1;
if ( v11 != _stack_chk_guard )
sub_78A20();
return result;
}
不知道什么原因,F5生成的伪代码明显不对,谁能告诉我下原因???
待会有事,明天接着分析。
----------------------------接着昨天的分析----------------
我晚上回去仔细梳理了下,使用jniRegisterNativeMethods注册jni,肯定会有相关关键字。
今天一早动手分析,通过IDA的搜索发现,没有搜索到任何关键字。
api是肯定需要的,既然搜索不到。那就证明是关键字被加密了;仔细研究Jni_OnLoad函数,发现有个解密函数。
既然这样,我干脆不去管他的so库。我直接找个有root权限的系统,去注入libdvm.so库。
这样就可以打印出2个native函数的对应地址,然后算出偏移。到此为止,基本上也就完成了。
这次逆向还是学习了很多东西。
作为一个android应用,不管他怎么变化,最终调用的系统api都会暴露他极力隐藏的东西。
某些时候,换个思路。其实也不难。
参考资料:
http://bbs.pediy.com/showthread.php?t=192047 这片文章对我帮助极大。非常感谢ThomasKing
http://blog.csdn.net/luoshengyang/article/details/8923483 这篇文章我之前读过2次,没有深入研究。这次再次结合源代码读了3次,收货很大。
[注意]传递专业知识、拓宽行业人脉——看雪讲师团队等你加入!