Android compared to iOS, security issues are often more prominent, a variety of loopholes and crack endless. The understanding of the method can be used in the development of prevention, enhance the security of the application. This series of articles will be on the Android application of the crack and protection of two aspects to do a discussion, to the development of the students some reference. Andoid Development students may encounter the need to do competitive analysis of the situation, apk reinforcement is often a barrier to analysis. 360 channels are the biggest channel for Android app distribution, and many APK uses 360 hardening. This article will talk about how to get rid of this hole. 360 after the hardened apk, on the arm device will first copy the libjiagu.so in the assets directory to the files directory, and then dynamically decrypt and load the original Dex via libjiagu.so
To the APK shelling, first of all to analyze the libjiagu.so implementation. And the so did the binary packers. So the first thing to do now is to take off the so shell first. Through the 010Editor view libjiagu.so structure, its init_proc and init_array have no real function, the real decryption is placed in Jni_onload.
jni_onload function has a lot of garbage jump command interference analysis, there will be a dynamic decryption function run, if the debugger is detected, the dynamic function will be placed into illegal code, so that the program crash
1b0c404 This position will run to fly. This analysis is more tiring. Change the idea, hook some key functions, hook log Analysis Hook Dlopen and dlsym log print out libjiagu.so load base and size
Can see the address of the jni_onload or in the libjiasu.so memory range
Hook registernatives function, print the following log
This log can see registernatives has been called, registered a Interface7 function, the function address is 51e2f211, look at this address carefully found that this address is already a thumb instruction set, The arm instruction set used by libjiagu.so is not quite consistent, and you can see that the function address has exceeded the libjiagu.so memory range. Libjiagu.so base is 51b3b000, size is 46000, max memory address is 51b81000 then, Basically, it loads another so from the/proc/%pid%/maps to find the memory block of the function address, and dumps the contiguous memory together to find the following piece of memory in the memory.
This is actually the elf Heaer, but some ELF structure information has been erased. In addition to the basic structure information is missing the following three data: 0x20 e_shoff0x30 e_shnum0x32 e_shtrndx The next job is to repair the broken memory, by analyzing the above three data, Dlopen actually did not use, Its value has no effect on Elf operation. After the repaired file can replace the original libjiagu.so, re-signed to make the APK run normally for IDA dynamic debugging analysis. Below is a revised flowchart fragment of the libjiagu.so with IDA analysis
360 when Dex is loaded, it does not call dvmdexfileopenpartial, but instead realizes the function of this function, so it can not be shelled directly up and down the breakpoint. The way it is realized is basically copied the bionic source code
As shown in the source code above, using Dex's memory will use MEMCMP to check whether the magic is Dex, so as long as the hook memcmp, and then check in the filter function is DEX, and then dump out is the original Dex. Put the hook frame well and implement the following MEMCMP filter function to automatically dump the original Dex down.
the whole process of shelling can be automated when the front is all done. The APK is automatically shelled when it starts. Click on launch apk, will output the following log
The 3rd DMP in log is the original Dex, which has been automatically written to the specified directory.
The shell can be applied to all current 360 reinforcement, simply specify the APK package name to be taken off at startup
Android Analytics hack-seconds off 360 hardening Dafa