OSX(10.10.4 ) 反编译APK 和 混淆

2024-01-17 21:18
文章标签 反编译 apk osx 混淆 10.10

本文主要是介绍OSX(10.10.4 ) 反编译APK 和 混淆,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

反编译

准备工作

  • 安装APKTOOL how to install
  • 安装dex2jar install(sourceforge下的dex2jar-0.0.9.15.zip)
  • 安装jd gui install

使用方法

  • apktool 安装和使用参照文档

  • dex2jar使用
    从apk所在的目录打开终端 (从文件夹打开终端),运行

    softrice$ unzip ./app-release.apk

    文件夹下出现classes.dex,把他拉入dex2jar文件夹。终端跳转到dex2jar文件夹,执行

    softrice$ sudo sh dex2jar.sh classes.dex

    文件夹下出现jar包,用jd gui 打开就可以看源码了。

    dex2jar使用的时候最开始的使用dex2jar2.0,加权限后使用的时候报无权限,。后来改用sourceforge下的dex2jar-0.0.9.15.zip.
    dex2jar使用

混淆

在build.gradle加入

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

混淆是很方便,但是打包成apk后各种问题。
proguard-android.txt和proguard-rules.pro就是用来申明哪些代码不被混淆。
proguard-android.txt是安卓默认,可以在sdk下找到他

# 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.
# 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.**

proguard-rules.pro则需要我们做一些修改。
先了解一些规则 proguard

这是我所用的

# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in D:\Android\sdk/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 *;
#}#指定代码的压缩级别-optimizationpasses 5
#包明不混合大小写-dontusemixedcaseclassnames
#不去忽略非公共的库类-dontskipnonpubliclibraryclasses
#优化  不优化输入的类文件-dontoptimize
#预校验-dontpreverify
#混淆时是否记录日志-verbose
# 混淆时所采用的算法-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
#保护注解-keepattributes *Annotation*
    # 保持哪些类不被混淆-keep public class * extends android.app.Fragment
    -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.app.backup.BackupAgentHelper
    -keep public class * extends android.preference.Preference
    -keep public class com.android.vending.licensing.ILicensingService
    #如果有引用v4包可以添加下面这行-keep public class * extends android.support.v4.app.Fragment
#忽略警告-ignorewarning
##记录生成的日志数据,gradle build时在本项目根目录输出###apk 包内所有 class 的内部结构-dump class_files.txt
    #未混淆的类和成员-printseeds seeds.txt
    #列出从 apk 中删除的代码-printusage unused.txt
    #混淆前后的映射-printmapping mapping.txt
#####混淆保护自己项目的部分代码以及引用的第三方jar包library########-libraryjars libs/umeng-analytics-v5.2.4.jar#三星应用市场需要添加:sdk-v1.0.0.jar,look-v1.0.1.jar#-libraryjars libs/sdk-v1.0.0.jar#-libraryjars libs/look-v1.0.1.jar#不混淆第三方jar包中的类-keep class com.android.volley.** {*;}
    -keep class com.Chart.** {*;}
    -keep class com.xxx.lib.** {*;}
    -keep class antistaic.spinnerwheel.** {*;}
    -keep class com.xxx.xxx.model.** {*;}
    -keep class com.xxx.xxx.modules.** {*;}
    -keep class com.facebook.** {*;}
    -keep class com.google.** {*;}
    -keep class in.srain.cube.** {*;}
-keep class cn.sharesdk.**{*;}
    -keep class com.sina.**{*;}
    -keep class **.R$* {*;}
    -keep class **.R{*;}
    -dontwarn cn.sharesdk.**
    -dontwarn **.R$*
#baidu push-libraryjars libs/pushservice-VERSION.jar
    -dontwarn com.baidu.**
    -keep class com.baidu.**{*; }
#如果引用了v4或者v7包-dontwarn android.support.**
####混淆保护自己项目的部分代码以及引用的第三方jar包library-end####-keep public class * extends android.view.View {
        public <init>(android.content.Context);public <init>(android.content.Context, android.util.AttributeSet);public <init>(android.content.Context, android.util.AttributeSet, int);public void set*(...);}#保持 native 方法不被混淆-keepclasseswithmembernames class * {
        native <methods>;}#保持自定义控件类不被混淆-keepclasseswithmembers class * {
        public <init>(android.content.Context, android.util.AttributeSet);}#保持自定义控件类不被混淆-keepclassmembers class * extends android.app.Activity {
       public void *(android.view.View);}#保持 Parcelable 不被混淆-keep class * implements android.os.Parcelable {
      public static final android.os.Parcelable$Creator *;}#保持 Serializable 不被混淆-keepnames class * implements java.io.Serializable
#保持 Serializable 不被混淆并且enum 类也不被混淆-keepclassmembers class * implements java.io.Serializable {
        static final long serialVersionUID;private static final java.io.ObjectStreamField[] serialPersistentFields;!static !transient <fields>;!private <fields>;!private <methods>;private void writeObject(java.io.ObjectOutputStream);private void readObject(java.io.ObjectInputStream);java.lang.Object writeReplace();java.lang.Object readResolve();}#保持枚举 enum 类不被混淆 如果混淆报错,建议直接使用上面的 -keepclassmembers class * implements java.io.Serializable即可#-keepclassmembers enum * {#  public static **[] values();#  public static ** valueOf(java.lang.String);#}-keepclassmembers class * {
        public void *ButtonClicked(android.view.View);}#不混淆资源类-keepclassmembers class **.R$* {
        public static <fields>;}#避免混淆泛型 如果混淆报错建议关掉#–keepattributes Signature#移除log 测试了下没有用还是建议自己定义一个开关控制是否输出日志#-assumenosideeffects class android.util.Log {#    public static boolean isLoggable(java.lang.String, int);#    public static int v(...);#    public static int i(...);#    public static int w(...);#    public static int d(...);#    public static int e(...);#}#如果用用到Gson解析包的,直接添加下面这几行就能成功混淆,不然会报错。#gson#-libraryjars libs/gson-2.2.2.jar-keepattributes Signature
    # Gson specific classes-keep class sun.misc.Unsafe { *; }
    # Application classes that will be serialized/deserialized over Gson-keep class com.google.gson.examples.android.model.** { *; }

这篇关于OSX(10.10.4 ) 反编译APK 和 混淆的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/617246

相关文章

内置带so的APK为系统APK方法

(1)若内置为可卸载的APK,可以无需解压出lib直接编译就可以 具体参考http://blog.csdn.net/a462533587/article/details/46380795 (2)若内置为system APP,上述blog也有两种方式: 方法一:   如下例,在Android.mk中添加并配置变量(注意路径对应): LOCAL_PREBUILT_JNI_LIBS = \

apk反编译修改教程系列-----修改apk 解除软件限制功能 实例操作步骤解析_6【二十五】

目前很多软件都需要票票才可以使用完全的功能。纯免费的功能性app已经很少见了。 今天继续以一款app为大家来演示如何去除软件的限制功能。教程的目的主要是学习反编译的基础修改方法,了解app的修改步骤以及基础的入门修改常识。每个使用修改方法不一定适用于所有app。只是给你另外的思路与步骤参考。 反编译工具:MT**绿色版 演示apk;**清单 app

LLVM IR指令VM混淆分析

未混淆编译  编写一个最简单的测试代码,对 test_add函数用于对两个数相加: int __attribute((__annotate__("vm"))) test_add(int a, int b) {int c = a + b;return c;}int main(void) {int c = test_add(1, 2);return c;} 编译成中间代码:  未加

Android studio 生成自定义apk

1.获取当前时间 def buildTime() {def date = new Date()def formattedDate = date.format('yyyy_MM_dd--HH:mm')return formattedDate} 2.在app下的build.gradle文件中添加 //自定义apk名字applicationVariants.all { variant ->v

王立平--Apk安装过程及原理详解

应用安装是智能机的主要特点,即用户可以把各种应用(如游戏等)安装到手机上,并可以对其进行卸载等管理操作。APK是Android Package的缩写,即Android安装包。APK是类似Symbian Sis或Sisx的文件格式。通过将APK文件直接传到Android模拟器或Android手机中执行即可安装。 Android应用安装有如下四种方式 1.系统应用安装――开机时完成,没有安装

apk中签名文件探究(*.SF, *.MF,*.RSA)

文章来源: 作者:嘟嘟小灰 链接:https://www.jianshu.com/p/e07da93acf98 来源:简书 1、取一个apk,然后进行不同签名,生成1.apk、2.apk,并提取META-INF里面的文件进行比对 def calc_sha1(data):sha1obj = hashlib.sha1()if not isinstance(data, (bytear

Android APK获取平台系统签名权限

1.修改AndroidManifest.xml,改变uid为android.uid.system,使之与Settings能够共享数据空间。 <?xml version="1.0" encoding="utf-8"?><manifest xmlns:android="http://schemas.android.com/apk/res/android"package="com.txx.tes

有关混淆的问题解决

第一部分:(对齐) 简单优化:Zipalign Android SDK中包含一个“zipalign”的工具,它能够对打包的应用程序进行优化。在你的应用程序上运行zipalign,使得在运行时Android与应用程序间的交互更加有效率。因此,这种方式能够让应用程序和整个系统运行得更快。我们强烈推荐在新的和已经发布的程序上使用zipalign工具来得到优化后的版本——即使你的程序是在老版本的A

js混淆保护在线工具开源项目大全

具体前往:js代码混淆加密保护工具&开源项目大全

APK安装释放文件的过程

1、DDMS 在学习Android 应用程序安装相关文件的过程时,我们需要先了解一个工具DDMS( Dalvik Debug Monitor Service),即Android 开发环境中的Dalvik虚拟机调试监控服务。打开这个工具集有一个File Explorer(文件的浏览器),该文件浏览器可以帮助我们查看虚拟机上的所有文件。如图1-1所示: 2、Apk的安装