android Application的防反编…
来源:互联网 发布:linux 单网卡双网关 编辑:程序博客网 时间:2024/04/28 22:27
android APK防止反编译:
在android2.3之后的版本新建项目中会自动生成proguard.cfg和project.properties文件,proguard.cfg文件是混淆java代码的配置文件,里面对不需要混淆代码的类文件进行配置过滤,project.properties文件里设置android项目对应的版本和proguard.cfg的路径。
1.贴上自动生成的proguard.cfg文件的内容:
-optimizationpasses 5
-dontusemixedcaseclassnam
-dontskipnonpubliclibrary
-dontpreverify
-verbose
-optimizations!code/simplification/arithmetic,!field/*,!class/merging/*
-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extendsandroid.content.BroadcastReceiver
-keep public class * extendsandroid.content.ContentProvider
-keep public class * extendsandroid.app.backup.BackupAgentHelper
-keep public class * extendsandroid.preference.Preference
-keep public classcom.android.vending.licensing.ILicensingService
-keepclasseswithmembernam
}
-keepclasseswithmembers class * {
}
-keepclasseswithmembers class * {
}
-keepclassmembers class * extends android.app.Activity {
}
-keepclassmembers enum * {
}
-keep class * implements android.os.Parcelable {
}
<-----------系统默认proguard.cfg说明--------------------->
For some situations, the default configurations inthe proguard.cfg
- a class that is referenced only inthe
AndroidManifest.xml
file( AndroidManifest.xml文件中的引用类) - a method called from JNI(JNI调用的方法)
- dynamically referenced fields and methods(动态引用的字段和方法)
从上面的配置代码可以看出对Activity,Application,Service,BroadcastReceiver,ContentProvider,BackupAgentHelper,Preference,ILicensingService的子类不做代码混淆处理(这些类可能被其他应用或系统应用调用)。混淆之后应用出现如ClassNotFoundException异常,可以在此文件中添加过滤混淆代码:
-keep public class <</span>MyClass>
AndroidDevelopers官方资料:http://developer.android.com/tools/help/proguard.html
2.在project.properties文件:
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build systemedit
# "ant.properties", and override values to adapt the script toyour
# project structure.
#
# To enable ProGuard to shrink and obfuscate your code, uncommentthis (available properties: sdk.dir, user.home):
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
# Project target.
target=android-10
文件最后添加proguard.config=proguard.cfg(混淆配置路径),proguard.cfg也可以放到别的路径,比如放到工程根目录下的path/to/proguard.cfg,这时应设置对应的绝对路径proguard.config=/path/to/proguard.cfg,具体相关配置参考AndroidDevelopers官方文档资料:http://developer.android.com/tools/help/proguard.html
3.App签名(AndroidDevelopers官方文档资料:http://developer.android.com/tools/publishing/app-signing.html#setup)
签名主要用到的是JDK中提供的签名工具keytool(路径:your jdk path/bin/keytool)
keytool生成key.keystore签名文件的命令参数
-genkey
获得密钥对(私有密钥和公共密钥)-v
启用详细输出-alias
别名-keyalg
使用生成密钥的加密算法-keysize
密钥长度-dname
创建密钥的描述
-keypass
密钥密码
-validity
密钥有效期
Note:推荐使用大于等于10000
-keystore .keystore
输出生成密钥的.keystore文件保存路径-storepass
密钥库密码,与-keypass对应
有了以上命令参数,下面执行命令进行应用签名(以下为例):
keytool -genkey -v -keystore my-release-key.keystore-alias alias_name -keyalg RSA -keysize 2048 -validity 10000执行过程中有一些提示输入信息,输入完成后.keystore文件生成完毕。
4.导出混淆的签名应用
右击项目:Android Tools--------------------->Export sined applicationpackage
选择上一步生成的签名文件(.keystore)和输入密钥库密码,点击下一步,选择填写Alias别名和密钥密码----->导出APK对应的路径-------->finish
到处截屏以后贴上。
查看验证APK签名:同样是JDK工具jarsigner
jarsigner -verify -verbose -certs my_signed.apk
如果出现的是CN=AndroidDebug,说明是调试密钥生成签名的apk
这样一个混淆代码后的签名APK制作完毕。
- android Application的防反编…
- android Application的防反编译Proguard和应用签名
- android Application的防反编译Proguard和应用签名
- ubuntu11.10 64bit 环境android编…
- 全面分析 Spring 的编程式事务管理…
- Android防反编译工具
- android防反编译
- Android札记:防反编译、混淆文件p…
- QT opensource embedded linux 编…
- android 防反编译(ProGuard)
- Android反编译与防反编译
- Top 10 Linux console application…
- Sublime Text 2 编…
- without application to…
- 对未来WEB APPLICATION的开发需求…
- android 对话框的弹出…
- ios5 xcode 4.3 中 release 显示编…
- The web application [/stru…
- 精华Android中ProGuard的使用ZZ
- 认输能力
- java 日期判断 给定日期是否为当天 一周7天以内 一周7天以外
- Android札记:防反编译、混淆文件p…
- Android代码混淆proguard技…
- android Application的防反编…
- 使用Xcode的Refactor功能调整代码
- android工程搅混和反编译ZZ
- Android ProGuard
- conversion to dalvik&n…
- android 通过eclipse混…
- 安卓APP应用程序导出,加密和签名…
- 如何将IOS App程序发布到苹果…
- AES算法之理论与编程结合篇