Android anti-compilation apk and repack the signature (Mac environment)

Source: Internet
Author: User

Tools download
    • Apktool:https://ibotpeaches.github.io/apktool/install
    • Dex2jar:https://github.com/pxb1988/dex2jar
    • jd-gui:http://jd.benow.ca
According to the Apktool website tips download method, right-click Wrapper script, link storage as Apktool, do not take extension and then click Find newest here Download Apktool.jar, select the first download the latest version
After downloading, rename the Apktool_2.3.3.jar to Apktool.jar, and then copy the Apktool.jar and Apktool together to the/usr/local/bin path.

So the environment is ready, open the terminal, enter apktoolcommand, see the following output description Apktool configuration succeeded
Create a new MyTest directory easy to manage, put a test.apk in as a test package
Anti-compilation

Terminal input cd /Users/zachary/zachary/MyTest into the directory where the test apk is apktool d test.apk located, enter to start the anti-compilation

Compile the end can see the mytest directory more than a test folder, which is the product after the anti-compilation, we want to androidmanifest.xml and res/. The resource file is now recompiled, and the following continues to decompile the Java code, It's going to use Dex2jar and Jd-gui.
Download Dex2jar and Jd-gui unzip it, copy to mytest directory for easy operation
Terminal into mytest directory, enter command sh dex2jar-2.0/d2j-dex2jar.sh test.apk(If you are prompted for a permission Deny permission issue, enter the command first chmod +x dex2jar-2.0/d2j-dex2jar.shChange the permissions on the end of the run, in the MyTest directory will generate file Test-dex2jar.jar, is the Java code we need to compress files Right-click Open with Jd-gui (or open Jd-gui and drag Test-dex2jar.jar to Jd-gui Auto Import, you can see the Java code back to compile

Just now we apktool d test.apk 're doing the anti-compilation to get the test directory

Back to compile is to execute command apktool b test
After success, the test directory will generate build and Dist directory build directory under the package of Dex files and resource files (and the same as APK decompression) image.pngdist directory is stored in the re-packaged APK file
Re-signing

Copy the signature file to the Dist directory for easy operation

Terminal enters Dist directory, executes command jarsigner -verbose -keystore [your_key_store_path] -signedjar [signed_apk_name] [usigned_apk_name] [your_key_store_alias] -digestalg SHA1 -sigalg MD5withRSA
Field Description:
    • [Your_key_store_path]: Absolute path where key is located
    • [Signed_apk_name]: Install package name after signing
    • [Usigned_apk_name]: Unsigned installation package name
    • [Your_key_store_alias]: Alias of key
Because we put the secret key and test.apk in the same path, so the absolute path of the location of the key is filled testkey just fine, Macjenkinskey is my secret key alias, do not misunderstand (evil. jpg) lose the password, do not see the input, start signing signed after the name, In the Dist directory you can see the APK after signing the name something

When you decompile, you can also change the extension name of test.apk to Test.zip extract.

Copy the Classes.dex into the dex2jar-2.0 path under the dex2jar-2.0 path and execute the command ./d2j-dex2jar.sh classes.dexThe same can get Classes-dex2jar.jar decompile, and then back to compile, the same can be obtained classes.dex, just under this path. png

Android anti-compilation apk and repack the signature (Mac environment)

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.