Traditional app hardening technology has undergone four generations of technological change, with the level of protection each generation has improved, but its inherent security flaws and compatibility issues have not been addressed. The next generation of reinforcement technology-virtual machine source protection, the use of more extensive code type, app protection level is higher, compatibility is stronger, is a future level of protection solutions.
(Reinforcement technology development process)first generation reinforcement technology-dynamic loadingThe first-generation Android hardening technology used to protect the application's logic from being reversed and analyzed was most commonly used in malware, based on the dynamic loading technology provided by the Java Virtual machine. the protection process is:in the development phase, the program is divided into two parts: Load (Loader) and key logic (Payload), and separately packaged;
(development phase)The run-time load section (Loader) runs first, releasing the Critical Logic (Payload), and then loading the Java dynamic load technology and handing over control.
(START process)
(core code)remarks (Multidex component reinforcement principle):Android Dex files are generally smaller in the design process, so only 65,535 function references are allowed at the time of Dex file design. With the development of Android applications, a large number of application code has exceeded the limit of 65535, in order to solve this problem, Android5.0 native support to load multiple Dex, and in order to compatibility with the older version, Android provides the Multidex component. The implementation of this component is consistent with that described above. Defects and Confrontationthe flaw in the first generation of hardening technology is that it relies on the dynamic loading mechanism of Java, which requires that the critical logic (Payload) part must be decompressed and released to the filesystem, which gives an opportunity to get the corresponding file. Although the key logic (Payload) can be loaded, it is removed from the file system to prevent replication, but an attacker can intercept the corresponding delete function to prevent deletion. while the key logic (Payload) is encrypted and saved, it can be used against static analysis, but an attacker can use a custom virtual machine to intercept the key functions used by the dynamic loading mechanism, within which the key logic (Payload) files in the file system are copied. second-generation reinforcement technology-non-landing loadingrelative to the first generation of reinforcement technology, the second generation of reinforcement technology in the APK modification has been improved, can achieve 0 of the development of interference. The development process does not require special processing of the application, only need to be protected before the final release. To achieve this 0 interference process, loader needs to handle the life cycle of Android components. Main process:1) Loader is loaded by the system. 2) The system initializes the stubapplication within the loader. 3) Stubapplication decrypt and load the original Dex file (Payload). 4) stubapplication found the original application object from the original Dex file (Payload), created and initialized. 5) Replace all references to stubapplication objects in the system with the original application, this step is implemented using the Java reflection mechanism. 6) The normal life cycle management of other components by the Android system.
(for the development of 0 interference after the reinforcement start process)On the other hand, the non-landing loading technology is improved on the basis of the first generation of reinforcement technology, which mainly solves the defects of the first generation technology payload must be released to the file system (commonly known as landing), and its main technical solutions are two kinds:A. Intercepts system IO-related functions such as read, write, and provides transparent and decryption in these functions. The specific process is:1) Key logic (Payload) is stored in the APK in an encrypted manner. 2) The Runtime loading section (Loader) puts critical logic (Payload) into the file system, where critical logic (Payload) is still encrypted. 3) The loading section intercepts the corresponding system IO functions (read,write, etc.). 4) The Load section (Loader) normally calls the Java dynamic loading mechanism. Because the IO portion of the virtual machine is intercepted, the virtual machine reads the key logic (Payload) that has been decrypted.
(transparent plus decryption scheme process)B. Directly invoke the function provided by the virtual machine for non-landing loading, the specific process is:1) Key logic (Payload) is stored in the APK in an encrypted manner. 2) The Run-Time load section (Loader) puts the critical logic (Payload) into memory. 3) The load part calls the virtual machine internal interface for loading.
(no landing loading process)the key system functions are as follows:
compatibilityscheme a transparent encryption scheme because it needs to intercept the IO function of the system, this part will use the technology such as inline hook or got hook, which will bring some compatibility problems.Solution B's non-landing load scheme because of its call to invoke the internal interface, and this interface is not exported, each vendor in the implementation of their own custom modifications, resulting in a compatibility problem with the solution. Defects and Confrontationthe second generation of strengthening technology in the application to handle a large number of encryption and decryption loading operations, will cause the application of suspended animation (black screen), the user experience is poor. There is no essential difference in the implementation of the reinforcement technology, although it is possible to prevent the first generation of reinforcement technology files from being copied to the ground, but can also be confrontational from the following aspects:For example, the Dex file header in memory is cleared to prevent it from being found in the dump file, and the Dex file structure is corrupted, such as adding some wrong data to increase the cost of recovery. But after the payload is loaded, in memory is continuous, using debugging tools such as GDB dump memory can be directly found payload, after simple processing can recover 100% of the payload file. As with the first generation of hardening techniques, it is not possible to load against a custom virtual machine without landing. Simply intercept the key functions above and write the corresponding memory segments to restore the payload. Note that because IO-related functions are intercepted, it is not possible to directly call Read/write and other functions for direct read and write, bypassing the Syscall function. Although the vendor will implement the above function itself, it bypasses the interception of the above function. However, the Android ClassLoader must be able to find the structure to perform properly, and an attacker could use the ClassLoader as a starting point to find the location of the corresponding payload in memory. third generation reinforcement technology-instruction extractionsince the second-generation hardening technology only encrypts file-level, the problem is that in-memory payload are contiguous and can be easily obtained by attackers. The third-generation hardening technique has been improved to reduce the protection level to the function level. The main process is that the release phase clears the function contents (Code Item) within the original Dex and removes it to a single file.
(Release phase)The run phase restores the contents of the function back to the corresponding function body. There are several ways to restore the point in time:A. Restoring function contents to the memory area where the Dex shell resides after loading
(Run phase)B. After loading, the function content is restored to the structure inside the virtual machine: After the virtual machine reads the Dex file, there is a struct inside each function, which has a pointer to the function content (Codeitem), which can be modified by modifying the pointer to modify the corresponding function content.
C. Intercept functions within the virtual machine that are related to finding execution code, returning function content. compatibilityinstruction Extraction technology uses a large number of virtual internal structures and non-documented features, coupled with Android's complex vendor customization, resulting in a number of compatibility issues. Defects and Confrontationsome schemes of instruction extraction technology conflict with the JIT performance optimization of the virtual machine, which can not achieve the best running performance. Java virtual machines are still used for function content execution. An attacker could record the contents of a function (Codeitem) on the interpreter's code by customizing the Android virtual machine. The next step is to trigger all functions to get all the function contents. Eventually reassembled into a complete Dex file. There are already automated tools that can be instructed to remove shelling from technology.
(third-generation hardened Dex file shelling process)Fourth generation reinforcement Technology-instruction conversion/VMPthird-generation hardening techniques are protected at the function level, using an interpreter inside an Android virtual machine to execute code, resulting in potentially documented flaws, and fourth-generation hardening techniques use their own interpreters to avoid third-generation defects. The custom interpreter cannot make direct calls to other functions within the Android system, and must be invoked using the Java JNI interface. Its main implementation consists of two kinds:the functions within the A.dex file are marked as native, and the content is extracted and converted into a dynamic library that conforms to the JNI requirements. The dynamic library interacts with the Android system via JNI.
the functions within the B.dex file are marked as native, the contents are extracted and converted into a custom instruction format, which is executed using a custom receiver, and a is required to be invoked using JNI and the Android system.
compatibilityfourth generation VMP reinforcement technology is generally used in conjunction with the third generation of reinforcement technology, so the third generation of all compatibility issues, instruction conversion/VMP reinforcement also exists. Defects and Confrontationregardless of a scheme or B scheme, which is reinforced with the instruction conversion/VMP, it must interact with the virtual machine through the JNI interface provided by the virtual machine, and the attacker can directly convert the instruction conversion/VMP hardening scheme as a black box, and through the custom Jni interface object, the inside of the black box is probed, recorded and analyzed, Then get the complete Dex program.
(fourth generation hardened Dex file recovery)In addition, the fourth generation of VMP reinforcement technology only to achieve Java code protection, not to use VMP technology to protect the code, C + +, lack of security capabilities. Next-generation reinforcement technology-virtual machine source Protectionwith the fourth generation of VMP reinforcement technology, virtual machine source protection and reinforcement is the use of virtual machine technology to protect all the code, including Java,kotlin,c/c++,objective-c,swift and other code, with very high compatibility, so that the app has a higher level of security protection, More stable operation. Virtual Machine Source code protection to provide users with a complete set of tool chain, first the user to protect the core codes compiled into intermediate binary files, and then generate a unique virtual machine source protection execution environment and only in the environment to execute the running program. virtual Machine Source protection will isolate the internal execution environment within the app, and the running program of the core code runs in this independent execution environment. Even if the app itself is cracked, this part of the core code is still invisible.
(virtual machine source protection reinforcement process)the generated virtual machine source code protection has a unique variable instruction set, which greatly improves the difficulty of instruction tracking and reverse analysis. At the same time, the virtual machine source protection also provides anti-debugging capabilities and monitoring capabilities. Virtual machine source protection can be detected by their own probe to the environment changes, real-time detection of the external environment for debugging, injection and other abnormal execution process changes, the commissioning action into the program traps, and issued an alarm, and then real-time update, improve security intensity. Reinforcement technology development and the change of attack and defense confrontation, with the development of the Internet technology is constantly upgrading, we are convinced that evil can not win, and the virtual machine source protection reinforcement as the current leading reinforcement technology, in the future for a long time, to provide the app with enough strength protection for the business development of enterprises and developers escort. * More technology and case study of black ash production, please pay attention to the top image technology: Https://www.dingxiang-inc.com/blog
Application hardening process and future level plan: virtual Machine Source Protection