Android apk反编译及AS代码混淆方法

Android apk反编译及AS代码混淆方法

反编译工具下载地址:http://download.csdn.net/download/shenyuanqing/9187933

一.反编译

1.用压缩包管理软件(如WinRAR、WinZIP等)解压apk得到classes.dex文件,把该文件放到dex2jar文件夹里。

2.用dex2jar工具软件得到相应的jar文件。

(1)打开命令行界面。

(2)定位到dex2jar.bat所在目录。

(3)输入命令dex2jar.bat classes.dex即可生成jar文件(classes_dex2jar.jar)。


3.用jd-gui工具软件打开jar文件,就可查看源码。

(1)File/Open File

 

真是一览无余啊,安全工作刻不容缓。

二.混淆

1.app/build.gradle/buildTypes把minifyEnabled从false改成ture来启动Proguard混淆功能(AS1.2)。

    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

2.在proguard-rules.pro文件中配置混淆规则(根据自己项目情况)。

# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /Users/zhouping/Documents/code/android-sdk-macosx/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
#   http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
#   public *;
#}
-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keep public class * extends android.support.v4.app.FragmentActivity
-keep public class * extends android.support.v4.app.Fragment
-keep class * extends java.lang.annotation.Annotation { *; }
#-keep class com.lidroid.xutils.** {*;}
-keep class cn.lkhealth.epos.pub.common.SerialPort {*;}
##---------------Begin: proguard configuration for Gson  ----------
# Gson uses generic type information stored in a class file when working with fields. Proguard
# removes such information by default, so configure it to keep all of it.
-keepattributes Signature

# Gson specific classes
-keep class sun.misc.Unsafe { *; }
-keep class com.google.gson.stream.** { *; }
-keep class com.google.gson.examples.android.model.** { *; }
-keep class com.google.gson.** { *;}

# Application classes that will be serialized/deserialized over Gson
-keep class cn.lkhealth.epos.about.bean.**{ *; }
-keep class cn.lkhealth.epos.cashier.bean.**{ *; }
-keep class cn.lkhealth.epos.order.bean.**{ *; }
-keep class cn.lkhealth.epos.pub.bean.**{ *; }
##---------------End: proguard configuration for Gson  ----------

3.混淆后效果如下图:


可以看到变量、方法名等都由字母来代替了,虽然代码结构没有变,但至少增加了破解的难度了。

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Android APK反编译教程是一个关于如何将已编译的Android应用程序(APK)还原为原始的Java源代码和资源文件的指南。反编译APK可以帮助开发人员了解其他应用程序的实现细节,学习和借鉴他们的设计思路和技术方法。 以下是一个基本的Android APK反编译教程的步骤: 1. 下载反编译工具:首先,你需要下载一个反编译工具,例如dex2jar、apktool或Jadx等。这些工具可以从互联网上免费获取。 2. 安装和配置工具:解压缩下载的工具,并按照其文档中的说明进行安装和配置。确保将工具所在的目录添加到系统的环境变量中,以便可以在命令行中调用它们。 3. 反编译APK文件:在命令行中使用反编译工具将APK文件转换为可读的源代码。例如,使用dex2jar工具可以运行`d2j-dex2jar.bat yourapkfile.apk`命令将APK文件转换为JAR文件。 4. 反编译资源文件:使用apktool工具反编译APK文件的资源文件,以便可以查看和编辑应用程序的布局、图片和其他资源。例如,运行`apktool d yourapkfile.apk`命令将APK文件反编译到当前目录中的一个文件夹中。 5. 分析源代码和资源:通过查看反编译得到的Java源代码和资源文件,你可以深入研究和理解应用程序的实现细节。这些文件将在反编译的目录中找到,并使用文本编辑器或开发工具打开。 需要注意的是,反编译APK文件是为了学习和研究目的,以及对自己开发的应用程序进行检查和测试。在商业和法律层面上,我们不鼓励使用这些技术来获取未授权的应用程序源代码和资源。 总之,Android APK反编译教程可以帮助开发人员深入了解其他应用程序的实现细节,学习和借鉴他们的设计思路和技术方法。通过反编译APK文件,我们可以将已编译的二进制应用程序还原为可读的源代码和资源文件,以便进行更多的探索和分析。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值