Decompile Android apps to lower permissions for advertising and re-signing

Source: Internet
Author: User
Tags admob

Function: decompile APK to reduce permissions and re-sign

Scenario: A lot of software applications may lead to payment (for example, text messages, call numbers) or leakage of privacy (for example, access to Address Book) permissions, which makes people feel uneasy. For example, fetion, moji weather, ireader, and so on are all listed here. In order to make it easy to use, you need to do some cracking work to reduce the applicationProgram.

Tool: apktool-install-windows-2.2_r01-3.tar.bz2 (http://code.google.com/p/android-apktool/downloads/list)

Tool: (JDK) keytool.exe generates the signature keystore

Tool: (JDK) jarsigner.exe is used to sign the APK.
Freight expert
Tool: (optional) D: \ Android-SDK-Windows \ tools \ zipalign.exe optimizes the packaged application, making interaction between Android and the application more efficient at runtime.

Operation:

1. decompile the APK file demo.apk to the demo directory.

Apktool. Bat D demo.apk demo

2. Modify...

2.1 permission reduction: Modify the demo directory demoandroidmanifest. xml file and find <uses-Permission
...> Tag, comment out unnecessary permissions. (Reference: http://hb.qq.com/a/20101115/001156.htm
Android permissions that developers cannot know)

<! --

<Uses-Permission Android: Name = "android. Permission. set_wallpaper"/>

<Uses-Permission Android: Name = "android. Permission. Internet"/>

<Uses-Permission Android: Name = "android. Permission. access_network_state"/>

<Uses-Permission Android: Name = "android. Permission. send_sms"/>

<Uses-Permission Android: Name = "android. Permission. call_phone"/>

-->

2.2 remove advertisement: for example, smart monitor pro_2.3.16.apk

<Com. AdMob. Android. Ads. adview Android: Id = "@ ID/ads"
Android: layout_width = "fill_parent" Android: layout_height = "wrap_content"
APP: KEYWORDS = "girl friends monitor women sex adult gift electron
Wallpaper ring shirt Android Application game sport football soccer
World Cup "/>

Change to <com. AdMob. Android. Ads. adview Android: Id = "@ ID/ads"
Android: layout_width = "wrap_content" Android: layout_height = "wrap_content"
Android: width = "1dip" Android: Height = "1dip" app: KEYWORDS = ""/>

2.3 remove advertising: such as Hi-MSN.apk

<Com. Google. Ads. googleadview Android: Id = "@ ID/ad"
Android: layout_width = "fill_parent" Android: layout_height = "wrap_content"
Android: layout_alignparentbottom = "true"/>

Change to <com. Google. Ads. googleadview Android: Id = "@ ID/ad"
Android: layout_width = "fill_parent" Android: layout_height = "wrap_content"
Android: layout_alignparentbottom = "true" Android: width = "1dip"
Android: Height = "1dip"/>

Women's brand list
3. Re-compile the demo Directory into an APK file.

Apktool. Bat B demo

4. Find the demo.apk in the demo \ Dist directory and change it to demo_unsign.apk.

5. (optional) modify the content of the apksigner.input.txt file to generate the key pair and certificate and sign the APK. If it already exists, no modification is required. (Modify apksigner. BAT to remove the downstream comments)

Type apksigner.input.txt | keytool-genkey-alias % jks %-keystore
% Jks %-storepass % PWD %-keypass % PWD %-keyalg RSA-validity 20000

6. Modify the settings in the apksigner. Bat script (set APP = demo) and run apksigner. BAT to sign demo_unsign.apk to generate the demo_signed_final.apk file.

7. Delete the original APK application on your phone and reinstall demo_signed_final.apk.

---------------------------------------- ### Apksigner. BAT file

@ REM ### apksigner. bat

@ REM http://www.cnblogs.com/qianxudetianxia/archive/2011/04/09/2010468.html Android Learning Series (1) -- sign the app (for APK signature)

@ REM http://www.blogjava.net/zhaojianhua/archive/2011/06/23/352887.html Android APK Signature

@ Set jks = Android. keystore

@ Set Pwd = 111111

@ Set APP = demo

@ Set apk0=%app%_unsign.apk

@ Set out1=%app%_signed.apk

@ Set out2=%app%_signed_final.apk

@ Remtype apksigner.input.txt | keytool-genkey-alias % jks %
-Keystore % jks %-storepass % PWD %-keypass % PWD %-keyalg RSA-Validity
20000

@ if exist % out1 % del % out1 %
@ if exist % out2 % del % out2 %
@ echo ### #######################
@ echo ### signer.0 ### paiapkapps.apk

@ echo ###########################
@jarsigner.exe -verbose-keystore % jks %-storepass % PWD %-keypass % PWD %-signedjar % out1 % apk0 % jks %
@jarsigner.exe-verify % out1 %
@ echo ###########################
@ echo ### signer.1 #### % out1 %
@ echo #################### ######
@ D: \ Android-SDK-Windows \ tools \ zipalign.exe-V 4% out1 % out2 %
@jarsigner.exe-verify % out2 %
@ echo ## ########################
@ echo ### signer.2 ###% out2 %
@ echo ###########################

@ pause
---------------------------------------- apksigner.input.txt file
username
org
beijing
CN
Y

Related Article

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.