【Android】Android程序保护与破解浅析
此文源自组内成员分享的PPT,其他成员的文档由于没有得到授权,暂不公开。
本文命令如果没有特殊注明,均为windows 7环境。
本文只涉及大概的知识点,不涉及具体的细节,需要注意。
反编译
apktool
可反编译资源文件(xml,点九图)以及代码为smali代码
使用命令:apktool d xxx.apk output_filepath
dex2jar
反编译dex文件(解压apk获得的classes.dex)为jar
使用命令:dex2jar xxx.dex
jd-gui
查看jar文件代码
使用方法,直接打开jar文件即可
AXMLPrinter2 单个xml文件
java -jar AXMLPrinter2.jar xxx.xml >output.xml
反编译的应对
•代码混淆
•增加会引起反编译器异常的代码
•关键代码使用NDK
•软件加壳(如UPX)
•检测模拟器、调试器对抗动态调试
•检查签名、检验保护(classes.dex hash值)防止重编译
混淆
•混淆原理
在应用程序保持语句含义不变的前提下从程序P转换到了P'。
混淆技术是指对拟发布的应用程序进行保持语义的变换,使得变换后的程序和原来的程序在功能上相同或相近,但是更难以被逆向工程所攻击。
•常见方法
代码外形混淆(改名)
控制命令混淆(改变程序判断条件或者增加可控制条件以及其他对程序的结构以及流程进行调整)
内部数据混淆(数据结构的变换,变量的分裂、合并,数据结构变换,静态数据动态生成,类继承转换)
预防混淆(增加某些特定反编译反编译时会出错的代码)
•评价指标
强度,混淆算法对程序增加的复杂度
弹性,混淆后程序的抗机器攻击能力
开销,由代码转换带来的额外开销
Proguard
•代码外形混淆
•sdkpath\tools\proguard \proguard-android.txt
•项目proguard-project.txt
# This is a configuration file for ProGuard.
# http://proguard.sourceforge.net/index.html#manual/usage.html -dontusemixedcaseclassnames #包明不混合大小写
-dontskipnonpubliclibraryclasses #不去忽略非公共的库类
-verbose # Optimization is turned off by default. Dex does not like code run
# through the ProGuard optimize and preverify steps (and performs some
# of these optimizations on its own).
-dontoptimize #优化
-dontpreverify #预校验
# Note that if you want to enable optimization, you cannot just
# include optimization flags in your own project configuration file;
# instead you will need to point to the
# "proguard-android-optimize.txt" file instead of this one from your
# project.properties file. -keepattributes *Annotation* #保护注解
-keep public class com.google.vending.licensing.ILicensingService #保护指定的类
-keep public class com.android.vending.licensing.ILicensingService # For native methods, see http://proguard.sourceforge.net/manual/examples.html#native
#不混淆jni方法
-keepclasseswithmembernames class * {
native <methods>;
} # keep setters in Views so that animations can still work.
# see http://proguard.sourceforge.net/manual/examples.html#beans
-keepclassmembers public class * extends android.view.View {
void set*(***);
*** get*();
} # We want to keep methods in Activity that could be used in the XML attribute onClick
-keepclassmembers class * extends android.app.Activity {
public void *(android.view.View);
} # For enumeration classes, see http://proguard.sourceforge.net/manual/examples.html#enumerations
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
#不混淆Parcelable的子类,防止android.os.BadParcelableException
-keep class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}
#不混淆资源类
-keepclassmembers class **.R$* {
public static <fields>;
} # The support library contains references to newer platform versions.
# Don't warn about those in case this app is linking against an older
# platform version. We know about them, and they are safe.
-dontwarn android.support.**
原理图,经过压缩->优化->混淆->预校验4个步骤,默认优化以及预校验是没有打开的
•混淆注意事项
避免混淆泛型(fastjson)
-keepattributes Signature
排除反射、序列化相关的类
排除native方法,以及AndroidManifest.xml提到的类
忽略警告
-ignorewarnings
-dontwarn android.support.**
保留一个完整的包
-keep class com.sogou.appmall.**{*;}
•调试与bug追踪
1.dump.txt apk包内所有class的内部结构
2.mapping.txt 混淆前后的映射
3.seeds.txt 未混淆的类和成员
4.usage.txt 列出从apk中删除的代码
•还原日志
retrace.bat|retrace.sh [-verbose] mapping.txt [<stacktrace_file>]
比如:retrace.bat -verbose mapping.txt obfuscated_trace.txt
如果需要输出的日志有行号,需要添加
-renamesourcefileattribute SourceFile
-keepattributes SourceFile,LineNumberTable #输出错误信息行号
更多
•1. http://proguard.sourceforge.net/
•2.http://developer.android.com/tools/help/proguard.html
【Android】Android程序保护与破解浅析的更多相关文章
- 微信5.0 Android版飞机大战破解无敌模式手记
微信5.0 Android版飞机大战破解无敌模式手记 转载: http://www.blogjava.net/zh-weir/archive/2013/08/14/402821.html 微信5.0 ...
- Android 4.0 ICS SystemUI浅析——StatusBar结构分析
Android 4.0 ICS SystemUI浅析——StatusBar结构分析 分类: Android2012-06-30 14:45 23687人阅读 评论(8) 收藏 举报 androidsi ...
- Android开发学习之对话框浅析
对话框式程序运行中弹出的窗口.Android系统中有四种默认的对话框:警告对话框AlertDialog.进度对话框ProgressDialog.日期选择对话框DatePickerDialog以及时间选 ...
- Stack Overflow 排错翻译 - Closing AlertDialog.Builder in Android -Android环境中关闭AlertDialog.Builder
Stack Overflow 排错翻译 - Closing AlertDialog.Builder in Android -Android环境中关闭AlertDialog.Builder 转自:ht ...
- [Android]Android端ORM框架——RapidORM(v2.1)
以下内容为原创,欢迎转载,转载请注明 来自天天博客:http://www.cnblogs.com/tiantianbyconan/p/6020412.html [Android]Android端ORM ...
- [Android]Android端ORM框架——RapidORM(v2.0)
以下内容为原创,欢迎转载,转载请注明 来自天天博客:http://www.cnblogs.com/tiantianbyconan/p/5626716.html [Android]Android端ORM ...
- Android android:gravity属性介绍及效果图
转自: http://blog.csdn.net/aminfo/article/details/7784229 Android:gravity的属性官方说明如下: public static fina ...
- [转][Android][Android Studio] *.jar 与 *.aar 的生成与*.aar导入项目方法
转自:http://blog.csdn.net/qiujuer/article/details/39754517?utm_source=tuicool [Android][Android Studi ...
- 图解Android - Android GUI 系统 (1) - 概论
Android的GUI系统是Android最重要也最复杂的系统之一.它包括以下部分: 窗口和图形系统 - Window and View Manager System. 显示合成系统 - Surfac ...
随机推荐
- jQuery 1.4.4 中 function( window, undefined ) 写法原因
读 jQuery 1.4.4 版本代码的时候,发现下面的写法: (function( window, undefined ) { ... // code goes here })(window); w ...
- SQL技巧之分类汇总
数据表结构username type numaaaa 玉米 1212aaaa 玉米 212bbb 小麦 2323bbb .... 只有两种产品 玉米和小麦,玉米价格1.5,小麦价格 ...
- trigger
trigger() 方法触发被选元素的指定事件 <html><head><script type="text/javascript" src=&quo ...
- Cassandra1.2文档学习(5)—— Snitch
参考资料:http://www.datastax.com/documentation/cassandra/1.2/webhelp/index.html#cassandra/architecture/a ...
- 写 一个PHP脚本遇到的问题总结
在项目中,因为之前的人员,基础数据没有处理好,后面需要写一个脚本来处理这个问题,经验少,总结如下: 1.在linux下直接连接跑处理MySQL数据的脚本,要用PDO的方式连接数据库,长时间在框架中处理 ...
- PHP页面中文乱码分析
php出现出现乱码的原因:页面文件的编码方式(.html,.php等).html.head中指定浏览器的编码方式.MySql数据库传输的编码方式.Apache字符集. PHP页面中文乱码出现的原因有几 ...
- python 数据类型(列表)学习笔记
列表 创建列表: name_list = ['alex', 'seven', 'eric'] 或 name_list = list(['alex', 'seven', 'eric']) 其实今天学习的 ...
- 第四章 Web表单
4.1 跨站请求伪造保护 安装flask-wtf app = Flask(__name__) app.config['SECRET_KEY'] = 'hard to guess string' 密钥不 ...
- 10.MVC框架开发(Ajax应用)
1.MVC自带的Ajax应用, 使用步骤: 第一步,引入js框架 <script src="../../Scripts/jquery-1.4.4.js" type=" ...
- 在使用Fake framework的时候,为什么有一些函数没有生产mock呢?
在使用Visual studio 2012 的Fake framework 做单元测试的时候,你会发现有一些函数没有生产Stub 或者 Shim的版本,这可能是由于Fake的一些限制导致的,但如何知道 ...