android 反编译&防反编译(代码混淆)

一. 反编译工具 (适用于window&ubunt&mac)

1.apktool :用于反编译资源文件 Apktool官网 apktool下载地址

Apktool官网查看具体的操作

 apktool d xxx.apk 反编译
 apktool b xxx -o xxx.apk 重新打包
 jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore 签名文件名 -storepass 签名密码 待签名的APK文件名 签名的别名

2.dex2jar :用于将apk的dex反编译为jar dex2jar下载地址
3.jd-gui :将jar通过jd-gui的方式查看 jd-gui下载地址

二. 代码混淆,把类名,方法名,属性名混淆.即使反编译后也无法查看具体逻辑

凡是需要在AndroidManifest.xml中去注册的所有类的类名以及从父类重写的方法名都自动不会被混淆

# 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
-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);
}

-keepclassmembers class * implements android.os.Parcelable {
  public static final android.os.Parcelable$Creator CREATOR;
}

-keepclassmembers class **.R$* {
    public static <fields>;
}

# The support library contains references to newer platform versions.
# Dont 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.**
-dontusemixedcaseclassnames 表示混淆时不使用大小写混合类名。 
-dontskipnonpubliclibraryclasses 表示不跳过library中的非public的类。 
-verbose 表示打印混淆的详细信息。 
-dontoptimize 表示不进行优化,建议使用此选项,因为根据proguard-android-optimize.txt中的描述,优化可能会造成一些潜在风险,不能保证在所有版本的Dalvik上都正常运行。 
-dontpreverify 表示不进行预校验。这个预校验是作用在Java平台上的,Android平台上不需要这项功能,去掉之后还可以加快混淆速度。 
-keepattributes *Annotation* 表示对注解中的参数进行保留。

注意

1. 使用keep关键字后,你会发现代码中所有类的类名都不会被混淆了,因为keep关键字看到class *就认为应该将所有类名进行保留,而不会关心该类中是否含有native方法。当然这样写只会保证类名不会被混淆,类中的成员还是会被混淆的。 
2. 第三方的仿混淆
3. jar的混淆

参考

Android安全攻防战,反编译与混淆技术完全解析(上)
Android安全攻防战,反编译与混淆技术完全解析(下)
MAC上反编译android apk---apktool, dex2jar, jd-jui安装使用(含手动签名)

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 180,076评论 25 708
  • apk是安卓工程打包的最终形式,将apk安装到手机或者模拟器上就可以使用APP。反编译apk则是将该安卓工程的源码...
    隋胖胖LoveFat阅读 67,260评论 6 56
  • 声明 这篇文章更多的是做一个整理,内容来自于ProGuard官方文档以及各种博客等,相关文章的链接在参考目录里,感...
    夷陵小祖阅读 3,819评论 0 23
  • 作为一名客户端开发者,在使用别人Android应用的时候,你可能会遇到一些你觉得非常不错或者精致的布局、动画,你想...
    爱情小傻蛋阅读 1,487评论 2 1
  • 冰天雪地的时候,我就容易手脚冰凉,而且满手容易生冻疮。甚至耳朵、脸蛋、脚上也是冻烂的伤疤。 想起都想哭了,无论冬季...
    大姨妈红遍全球阅读 411评论 0 0

友情链接更多精彩内容