Android APK Prevent anti-compilation technology fourth-against Jd-gui

Source: Internet
Author: User

Again to the weekend a person wabi at home nothing to do, this is the sorrow of the programmer. All right, let's use the weekend to continue to introduce another way for Android APK to prevent anti-compilation technology. Top three we talked about Shell technology (http://my.oschina.net/u/2323218/blog/393372), Runtime modification bytecode (http://my.oschina.net/u/2323218/blog/396203) and pseudo-encryption (http://my.oschina.net/u/2323218/blog/399326), if you have an understanding of the first three articles of my blog, you can view the introduction of these three technologies. Next we will introduce another technique to prevent apk decompile-against Jd-gui.

First, the principle of anti-Jd-gui

Most of the two tools used to decompile the apk are Apk-tool and Dex2jar. Use these two tools to first decompile the APK into Classes.dex and then decompile the classes.dex into a jar file, or decompile the APK directly into a jar file, and the jar file can be opened with the jar file Jd-gui will be able to directly view the APK Java source code. We spent so much effort to write the program is so easy to be someone else to get the source code is not very reconciled, now I tell you against Jd-gui view Source method. When we use Jd-gui to view the source code, sometimes some functions do not see the root of the error directly, we use this to protect our apk. It turns out that when Jd-gui a class bytecode file in a obfuscated jar into a Java file, the function error is prompted when encountering a special implementation of a branch that is simply not in the function. At this time we just look at these tips error file or function corresponding to the source code is what the statement caused, add these statements to our source code can prevent the use of Jd-gui to view our APK source code.

Second, the principle of realization

(1) If our apk OnCreate function is implemented as follows:

12345  @Override protected voidonCreate(Bundle savedInstanceState) {         super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);    }

(2) After we have obfuscated our apk and signed it to export our apk, we use the Dex2jar tool to convert our apk into a jar file

(3) Open our Jar file with Jd-gui to see the source code of our apk oncreate function. As follows:

(4) We then add the Impossible Special Branch statement in the APK oncreate function, the code is as follows:

123456789101112131415161718192021222324   @Override    protectedvoidonCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);       switch(0)       {       case1:           JSONObject jsoObj;           String date=null;           String second=null;           try           {              jsoObj=newJSONObject();              date=jsoObj.getString("date");               second=jsoObj.getString("second");           }           catch(JSONException e)           {              e.printStackTrace();           }           test.settime(date,second);           break;       }    }
1234 classtest{   public static voidsettime(String a,String b){}}

(5) We use the same method in (2) to turn the apk into a jar file, and then open with Jd-gui will see the prompt error. As follows:

According to the above, I believe that we have a certain understanding of the method against Jd-gui, I just cite one of the methods, the reason is that the Special Branch statement is because not all the branch statements can let Jd-gui hint error. We can pay attention to some of these Special Branch statements in order to protect our apk, next we will explain another Android APK to prevent anti-compilation technology, look forward to everyone's support. If you have any questions about the technology you are talking about:

Welcome to the personal public platform : Programmer Interaction Alliance (Coder_online) , sweep the QR code or search number below Coder_online can follow , we can communicate online.

Android APK Prevent anti-compilation technology fourth-against Jd-gui

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.