Anti-cracking technology for Android programs

Source: Internet
Author: User

0x1

Anti-decompile can be roughly divided into the following points:

1. Counter-compile tools such as Apktool, Dex2jar, etc.

2, against static compilation, divided into code obfuscation technology, NDK protection, apk shell protection.

3, against dynamic debugging, divided into detection debugger, detection simulator.

4, prevent re-compilation, divided into check signature, verification protection.

For more information, please referto "Android software security and reverse Analysis ".


0x02

Against anti-compilation tools, such as Dex2jar, usually after analyzing the Dex2jar source code, to find the vulnerability, in the Java source to trigger the Dex2jar exception, so that the Dex2jar can not be used properly.

Dex2jar beta version is 0.0.7.8, source address Https://github.com/jltxgcy/AntiCrack/tree/master/Antidex2jar. This project is done by adding the following function to the Java source code to cause Dex2jar not to work properly.

    private int position (int idx) {//Bits Big-endian in each unit        return 1 << (bits_per_unit-1-(idx% Bits_per _unit));            }

0x03

Against static compilation

1, the Code obfuscation technology, please refer to the Android obfuscation mechanism.

2, the NDK protection, is the original Java layer implementation of the logic, moved to the C + + layer to achieve, because the C + + layer code after the generation of anti-compilation arm assembly, more difficult to analyze.

3, apk shell protection, please refer to the Android apk reinforcement (shell) principle analysis and implementation.


0x04

Counter Dynamic Commissioning

1, testing the debugger, we have in the Android native anti-debugging mode and using Ida Bypass sung in the article, in detail there are several ways you can use to counter the debugger.

In addition, we introduce a Java layer anti-debugger, Https://github.com/jltxgcy/AntiCrack/tree/master/Antidebug/src/com/droider/antidebug.

2, detection Simulator, when our program runs in the simulator, we can test our program is being dynamically analyzed, then we can make our program exit. Project address: Https://github.com/jltxgcy/AntiCrack/tree/master/CheckQemu.

There are many ways to detect the simulator, refer to Android security – detect if it is an Android emulator.


0x05

Prevents recompilation.

1. Signature detection

In the Java layer to detect signatures, the project address is as follows: Https://github.com/jltxgcy/AntiCrack/tree/master/CheckSignature. The core code is:

public int getsignature (String packagename) {      Packagemanager pm = This.getpackagemanager (); PackageInfo pi = null;int sig = 0;try {pi = Pm.getpackageinfo (PackageName, packagemanager.get_signatures); Signature[] s = Pi.signatures;sig = S[0].hashcode ();  } catch (Exception e1) {sig = 0;e1.printstacktrace ();} return sig;    }
After obtaining the signature, and then comparing it with the correct signature information, if the comparison succeeds, the signature information is not changed.


2. Verification protection

The essence of recompiling Android software is to recompile the Classes.dex file, and after the code has been recompiled, the hash value of the generated Classes.dex file has changed.

Project address: Https://github.com/jltxgcy/AntiCrack/tree/master/CheckCRC.

The core code is as follows:

Private Boolean CHECKCRC () {    Boolean bemodified = false;    Long CRC = Long.parselong (GetString (R.STRING.CRC));    ZipFile zf;try {ZF = new ZipFile (Getapplicationcontext (). Getpackagecodepath ());    ZipEntry ze = zf.getentry ("Classes.dex");    LOG.D ("COM.DROIDER.CHECKCRC", String.valueof (ZE.GETCRC ()));    if (ZE.GETCRC () = = CRC) {    bemodified = true;    }} catch (IOException e) {e.printstacktrace (); bemodified = false;} return bemodified;    }   

Anti-cracking technology for Android programs

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.