├── .gitignore
├── DexProtect
├── .gitignore
├── .idea
│ └── vcs.xml
├── app
│ ├── .gitignore
│ ├── build.gradle
│ ├── proguard-rules.pro
│ └── src
│ │ ├── androidTest
│ │ └── java
│ │ │ └── com
│ │ │ └── stormagain
│ │ │ └── dexprotect
│ │ │ └── ExampleInstrumentedTest.java
│ │ ├── main
│ │ ├── AndroidManifest.xml
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── stormagain
│ │ │ │ └── dexprotect
│ │ │ │ ├── DemoApplication.java
│ │ │ │ ├── MainActivity.java
│ │ │ │ └── SecondActivity.java
│ │ └── res
│ │ │ ├── drawable-v24
│ │ │ └── ic_launcher_foreground.xml
│ │ │ ├── drawable
│ │ │ └── ic_launcher_background.xml
│ │ │ ├── layout
│ │ │ ├── activity_main.xml
│ │ │ └── activity_second.xml
│ │ │ ├── mipmap-anydpi-v26
│ │ │ ├── ic_launcher.xml
│ │ │ └── ic_launcher_round.xml
│ │ │ ├── mipmap-hdpi
│ │ │ ├── ic_launcher.png
│ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-mdpi
│ │ │ ├── ic_launcher.png
│ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xhdpi
│ │ │ ├── ic_launcher.png
│ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ ├── ic_launcher.png
│ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ ├── ic_launcher.png
│ │ │ └── ic_launcher_round.png
│ │ │ └── values
│ │ │ ├── colors.xml
│ │ │ ├── strings.xml
│ │ │ └── styles.xml
│ │ └── test
│ │ └── java
│ │ └── com
│ │ └── stormagain
│ │ └── dexprotect
│ │ └── ExampleUnitTest.java
├── build.gradle
├── dexshell
│ ├── .gitignore
│ ├── build.gradle
│ ├── proguard-rules.pro
│ └── src
│ │ └── main
│ │ ├── AndroidManifest.xml
│ │ └── java
│ │ └── com
│ │ └── stormagain
│ │ └── dexshell
│ │ ├── ClassLoaderDelegate.java
│ │ ├── Decrypt.java
│ │ ├── ProxyApplication.java
│ │ └── Reflect.java
├── gradle.properties
├── gradle
│ └── wrapper
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── protect-plugin
│ ├── .gitignore
│ ├── build.gradle
│ ├── proguard-rules.pro
│ └── src
│ │ └── main
│ │ ├── groovy
│ │ └── com.stormagain.dexprotect
│ │ │ ├── Constant.groovy
│ │ │ ├── DexProtectExtension.groovy
│ │ │ ├── DexProtectPlugin.groovy
│ │ │ ├── DexProtectTransform.groovy
│ │ │ └── Utils.java
│ │ └── resources
│ │ └── META-INF
│ │ └── gradle-plugins
│ │ └── protect-plugin.properties
├── release
│ └── com
│ │ └── stormagain
│ │ └── dexprotect
│ │ └── protect-plugin
│ │ ├── 1.0
│ │ ├── protect-plugin-1.0.jar
│ │ ├── protect-plugin-1.0.jar.md5
│ │ ├── protect-plugin-1.0.jar.sha1
│ │ ├── protect-plugin-1.0.pom
│ │ ├── protect-plugin-1.0.pom.md5
│ │ └── protect-plugin-1.0.pom.sha1
│ │ ├── maven-metadata.xml
│ │ ├── maven-metadata.xml.md5
│ │ └── maven-metadata.xml.sha1
└── settings.gradle
├── LICENSE
└── README.md
/.gitignore:
--------------------------------------------------------------------------------
1 | # Built application files
2 | *.apk
3 | *.ap_
4 |
5 | # Files for the ART/Dalvik VM
6 | *.dex
7 |
8 | # Java class files
9 | *.class
10 |
11 | # Generated files
12 | bin/
13 | gen/
14 | out/
15 |
16 | # Gradle files
17 | .gradle/
18 | build/
19 |
20 | # Local configuration file (sdk path, etc)
21 | local.properties
22 |
23 | # Proguard folder generated by Eclipse
24 | proguard/
25 |
26 | # Log Files
27 | *.log
28 |
29 | # Android Studio Navigation editor temp files
30 | .navigation/
31 |
32 | # Android Studio captures folder
33 | captures/
34 |
35 | # Intellij
36 | *.iml
37 | .idea/workspace.xml
38 | .idea/tasks.xml
39 | .idea/gradle.xml
40 | .idea/dictionaries
41 | .idea/libraries
42 |
43 | # Keystore files
44 | *.jks
45 |
46 | # External native build folder generated in Android Studio 2.2 and later
47 | .externalNativeBuild
48 |
49 | # Google Services (e.g. APIs or Firebase)
50 | google-services.json
51 |
52 | # Freeline
53 | freeline.py
54 | freeline/
55 | freeline_project_description.json
56 |
--------------------------------------------------------------------------------
/DexProtect/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 | .externalNativeBuild
10 | .idea
11 |
--------------------------------------------------------------------------------
/DexProtect/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/DexProtect/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/DexProtect/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | apply plugin: 'protect-plugin'
4 |
5 | buildscript {
6 | repositories {
7 | maven {
8 | url uri('../release')
9 | }
10 | google()
11 | }
12 | dependencies {
13 | classpath 'com.android.tools.build:gradle:3.0.1'
14 | classpath 'com.stormagain.dexprotect:protect-plugin:1.0'
15 | }
16 | }
17 |
18 | android {
19 | compileSdkVersion 26
20 | defaultConfig {
21 | applicationId "com.stormagain.dexprotect"
22 | minSdkVersion 14
23 | targetSdkVersion 26
24 | versionCode 1
25 | versionName "1.0"
26 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
27 | }
28 | buildTypes {
29 | release {
30 | minifyEnabled false
31 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
32 | }
33 | }
34 | }
35 |
36 | dependencies {
37 | implementation fileTree(dir: 'libs', include: ['*.jar'])
38 | implementation 'com.android.support:appcompat-v7:26.1.0'
39 | implementation 'com.android.support.constraint:constraint-layout:1.1.0'
40 | testImplementation 'junit:junit:4.12'
41 | androidTestImplementation 'com.android.support.test:runner:1.0.1'
42 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
43 | }
44 |
45 | protect {
46 | //禁用插件可修改成false
47 | dexProtectEnable = true
48 | }
--------------------------------------------------------------------------------
/DexProtect/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/DexProtect/app/src/androidTest/java/com/stormagain/dexprotect/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.stormagain.dexprotect;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumented test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.stormagain.dexprotect", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/DexProtect/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/DexProtect/app/src/main/java/com/stormagain/dexprotect/DemoApplication.java:
--------------------------------------------------------------------------------
1 | package com.stormagain.dexprotect;
2 |
3 | import android.app.Application;
4 |
5 | /**
6 | * Created by liujian on 2018/4/21.
7 | */
8 |
9 | public class DemoApplication extends Application {
10 | }
11 |
--------------------------------------------------------------------------------
/DexProtect/app/src/main/java/com/stormagain/dexprotect/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.stormagain.dexprotect;
2 |
3 | import android.content.Intent;
4 | import android.support.v7.app.AppCompatActivity;
5 | import android.os.Bundle;
6 | import android.view.View;
7 |
8 | public class MainActivity extends AppCompatActivity {
9 |
10 | @Override
11 | protected void onCreate(Bundle savedInstanceState) {
12 | super.onCreate(savedInstanceState);
13 | setContentView(R.layout.activity_main);
14 |
15 | findViewById(R.id.tv_main).setOnClickListener(new View.OnClickListener() {
16 | @Override
17 | public void onClick(View v) {
18 | Intent intent = new Intent(MainActivity.this, SecondActivity.class);
19 | startActivity(intent);
20 | }
21 | });
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/DexProtect/app/src/main/java/com/stormagain/dexprotect/SecondActivity.java:
--------------------------------------------------------------------------------
1 | package com.stormagain.dexprotect;
2 |
3 | import android.os.Bundle;
4 | import android.support.v7.app.AppCompatActivity;
5 |
6 | /**
7 | * Created by liujian on 2018/4/21.
8 | */
9 |
10 | public class SecondActivity extends AppCompatActivity{
11 |
12 | @Override
13 | protected void onCreate(Bundle savedInstanceState) {
14 | super.onCreate(savedInstanceState);
15 | setContentView(R.layout.activity_second);
16 |
17 |
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/DexProtect/app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
12 |
13 |
19 |
22 |
25 |
26 |
27 |
28 |
34 |
35 |
--------------------------------------------------------------------------------
/DexProtect/app/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
15 |
20 |
25 |
30 |
35 |
40 |
45 |
50 |
55 |
60 |
65 |
70 |
75 |
80 |
85 |
90 |
95 |
100 |
105 |
110 |
115 |
120 |
125 |
130 |
135 |
140 |
145 |
150 |
155 |
160 |
165 |
170 |
171 |
--------------------------------------------------------------------------------
/DexProtect/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/DexProtect/app/src/main/res/layout/activity_second.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/DexProtect/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/DexProtect/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/DexProtect/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stormagain/DexProtectPlugin/262c33e9df812ca426dba542ba090d33667099a1/DexProtect/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/DexProtect/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stormagain/DexProtectPlugin/262c33e9df812ca426dba542ba090d33667099a1/DexProtect/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/DexProtect/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stormagain/DexProtectPlugin/262c33e9df812ca426dba542ba090d33667099a1/DexProtect/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/DexProtect/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stormagain/DexProtectPlugin/262c33e9df812ca426dba542ba090d33667099a1/DexProtect/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/DexProtect/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stormagain/DexProtectPlugin/262c33e9df812ca426dba542ba090d33667099a1/DexProtect/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/DexProtect/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stormagain/DexProtectPlugin/262c33e9df812ca426dba542ba090d33667099a1/DexProtect/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/DexProtect/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stormagain/DexProtectPlugin/262c33e9df812ca426dba542ba090d33667099a1/DexProtect/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/DexProtect/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stormagain/DexProtectPlugin/262c33e9df812ca426dba542ba090d33667099a1/DexProtect/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/DexProtect/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stormagain/DexProtectPlugin/262c33e9df812ca426dba542ba090d33667099a1/DexProtect/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/DexProtect/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stormagain/DexProtectPlugin/262c33e9df812ca426dba542ba090d33667099a1/DexProtect/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/DexProtect/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/DexProtect/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | DexProtect
3 |
4 |
--------------------------------------------------------------------------------
/DexProtect/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/DexProtect/app/src/test/java/com/stormagain/dexprotect/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.stormagain.dexprotect;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/DexProtect/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 |
5 | repositories {
6 | google()
7 | jcenter()
8 | }
9 | dependencies {
10 | classpath 'com.android.tools.build:gradle:3.0.1'
11 |
12 |
13 | // NOTE: Do not place your application dependencies here; they belong
14 | // in the individual module build.gradle files
15 | }
16 | }
17 |
18 | allprojects {
19 | repositories {
20 | google()
21 | jcenter()
22 | }
23 | }
24 |
25 | task clean(type: Delete) {
26 | delete rootProject.buildDir
27 | }
28 |
--------------------------------------------------------------------------------
/DexProtect/dexshell/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/DexProtect/dexshell/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 26
5 |
6 | defaultConfig {
7 | applicationId "com.stormagain.dexshell"
8 | minSdkVersion 14
9 | targetSdkVersion 26
10 | versionCode 1
11 | versionName "1.0"
12 |
13 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
14 |
15 | }
16 |
17 | buildTypes {
18 | release {
19 | minifyEnabled false
20 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
21 | }
22 | }
23 |
24 | }
25 |
26 | task clearJar(type: Delete) {
27 | delete('build/libs/shell.jar')
28 | }
29 |
30 | task collFileToJar(type: org.gradle.api.tasks.bundling.Jar) {
31 | baseName 'shell'
32 |
33 | from {
34 | List allFiles = new ArrayList<>()
35 | configurations.compile.collect {
36 | for (File f : zipTree(it).getFiles()) {
37 | if (f.getName().equals("classes.jar")) {
38 | //去掉不需要打包的目录和文件
39 | exclude('com/stormagain/dexshell/BuildConfig.class')
40 | exclude('com/stormagain/dexshell/R.class')
41 | exclude('android/**')
42 | allFiles.addAll(zipTree(f).getAt("asFileTrees").get(0).getDir())
43 | }
44 | }
45 | }
46 | allFiles.add(new File('build/intermediates/classes/release'))
47 | allFiles // To return the obj inside a lambda
48 | }
49 | }
50 | collFileToJar.dependsOn(clearJar, build)
51 |
52 | task makeShellDex(type: Exec, dependsOn: ['collFileToJar']) {
53 | String dexPath = rootProject.rootDir.absolutePath + java.io.File.separator + "dexshell" + java.io.File.separator + "shell.dex"
54 | File dexFile = new File(dexPath)
55 | doFirst {
56 | if (dexFile.exists()) {
57 | dexFile.delete()
58 | }
59 | }
60 |
61 | if (System.getProperty('os.name', '').toLowerCase().contains('windows')) {
62 | commandLine 'cmd', '/c', String.format("\"\"%s\" --dex --output=\"%s\" build/libs/shell.jar\"", combine(android.getSdkDirectory(), "build-tools", android.buildToolsVersion, "dx"), dexPath)
63 | } else {
64 | commandLine combine(android.getSdkDirectory(), "build-tools", android.buildToolsVersion, "dx"), '--dex', "--output=" + dexPath, 'build/libs/shell.jar'
65 | }
66 | standardOutput = new ByteArrayOutputStream()
67 | ext.output = {
68 | return standardOutput.toString()
69 | }
70 | }
71 |
72 | File combine(java.io.File f, java.lang.String[] parts) {
73 | for (String part : parts) {
74 | f = new File(f, part)
75 | }
76 | return f
77 | }
--------------------------------------------------------------------------------
/DexProtect/dexshell/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/DexProtect/dexshell/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
9 |
10 |
--------------------------------------------------------------------------------
/DexProtect/dexshell/src/main/java/com/stormagain/dexshell/ClassLoaderDelegate.java:
--------------------------------------------------------------------------------
1 | package com.stormagain.dexshell;
2 |
3 | import android.app.Application;
4 | import android.app.Instrumentation;
5 | import android.content.Context;
6 | import android.content.pm.ApplicationInfo;
7 |
8 | import java.io.ByteArrayOutputStream;
9 | import java.io.File;
10 | import java.io.FileNotFoundException;
11 | import java.io.FileOutputStream;
12 | import java.io.IOException;
13 | import java.io.InputStream;
14 | import java.lang.ref.WeakReference;
15 | import java.lang.reflect.Field;
16 | import java.lang.reflect.Method;
17 | import java.util.ArrayList;
18 | import java.util.Map;
19 |
20 | import dalvik.system.DexClassLoader;
21 |
22 | /**
23 | * Created by liujian on 2018/4/12.
24 | */
25 |
26 | public class ClassLoaderDelegate {
27 |
28 | private Context context = null;
29 | private Class> loadedApkClass = null;
30 | private WeakReference> loadedApkRef = null;
31 |
32 | public ClassLoaderDelegate(Context ctx) {
33 | this.context = ctx;
34 | try {
35 | Class> activityThreadClass = Class.forName("android.app.ActivityThread");
36 | Method currentActivityThreadMethod = activityThreadClass.getDeclaredMethod("currentActivityThread");
37 | Object activityThread = currentActivityThreadMethod.invoke(null);
38 |
39 | Field mPackagesField = activityThreadClass.getDeclaredField("mPackages");
40 | mPackagesField.setAccessible(true); //取消默认 Java 语言访问控制检查的能力(暴力反射)
41 | Map mPackages = (Map) mPackagesField.get(activityThread);
42 | loadedApkRef = (WeakReference) mPackages.get(ctx.getPackageName());
43 |
44 | loadedApkClass = Class.forName("android.app.LoadedApk");
45 | } catch (Exception e) {
46 | throw new RuntimeException(e);
47 | }
48 | }
49 |
50 | public ClassLoader getAppClassLoader() {
51 | try {
52 | Field mClassLoaderField = loadedApkClass.getDeclaredField("mClassLoader");
53 | mClassLoaderField.setAccessible(true);
54 | return (ClassLoader) mClassLoaderField.get(loadedApkRef.get());
55 | } catch (Exception e) {
56 | e.printStackTrace();
57 | }
58 | return null;
59 | }
60 |
61 | private boolean setAppClassLoader(ClassLoader newClassLoader) {
62 | try {
63 | Field mClassLoaderField = loadedApkClass.getDeclaredField("mClassLoader");
64 | mClassLoaderField.setAccessible(true);
65 | mClassLoaderField.set(loadedApkRef.get(), newClassLoader);
66 | return true;
67 | } catch (NoSuchFieldException e) {
68 | e.printStackTrace();
69 | } catch (IllegalAccessException e) {
70 | e.printStackTrace();
71 | } catch (IllegalArgumentException e) {
72 | e.printStackTrace();
73 | }
74 | return false;
75 | }
76 |
77 | public ClassLoader loadDex(InputStream inputStream) {
78 | try {
79 | ClassLoader appClassLoader = getAppClassLoader();
80 | ClassLoader newClassLoader = null;
81 | File decryptFile = new File(context.getCacheDir(), "classes.dex");
82 | String libPath = context.getApplicationInfo().nativeLibraryDir;
83 | File odexDir = context.getFilesDir();
84 | dex2file(inputStream, decryptFile);
85 | if (appClassLoader != null) {
86 | newClassLoader = new DexClassLoader(decryptFile.getAbsolutePath(), odexDir.getAbsolutePath(), libPath, appClassLoader);
87 | } else {
88 | newClassLoader = new DexClassLoader(decryptFile.getAbsolutePath(), odexDir.getAbsolutePath(), libPath, context.getClassLoader());
89 | }
90 | setAppClassLoader(newClassLoader);
91 | return newClassLoader;
92 | } catch (Exception e) {
93 | e.printStackTrace();
94 | }
95 | return null;
96 | }
97 |
98 |
99 | public static boolean dex2file(InputStream in, File outFile) {
100 | File outDir = outFile.getParentFile();
101 | if (!outDir.exists() && outDir.isDirectory()) {
102 | outDir.mkdirs();
103 | }
104 |
105 | FileOutputStream out = null;
106 | try {
107 | if (outFile.exists()) {
108 | outFile.delete();
109 | }
110 |
111 | out = new FileOutputStream(outFile);
112 | ByteArrayOutputStream byteOutput = new ByteArrayOutputStream();
113 |
114 | byte[] buff = new byte[1024];
115 | int len;
116 | while ((len = in.read(buff)) != -1) {
117 | byteOutput.write(buff, 0, len);
118 | }
119 |
120 | byte[] dexBytes = byteOutput.toByteArray();
121 | byte[] decryptBuff = Decrypt.decrypt(dexBytes);
122 | out.write(decryptBuff, 0, decryptBuff.length);
123 | out.flush();
124 | return true;
125 | } catch (FileNotFoundException e) {
126 | e.printStackTrace();
127 | } catch (IOException e) {
128 | e.printStackTrace();
129 | } finally {
130 | try {
131 | in.close();
132 | out.close();
133 | } catch (IOException e) {
134 | e.printStackTrace();
135 | }
136 | }
137 | return false;
138 | }
139 |
140 | public static Application changeTopApplication(String appClassName) {
141 | Object currentActivityThread = Reflect.invokeMethod("android.app.ActivityThread", null, "currentActivityThread", new Object[]{}, new Class[]{});
142 | Object mBoundApplication = Reflect.getFieldValue(
143 | "android.app.ActivityThread", currentActivityThread,
144 | "mBoundApplication");
145 | Object loadedApkInfo = Reflect.getFieldValue(
146 | "android.app.ActivityThread$AppBindData",
147 | mBoundApplication, "info");
148 | Reflect.setFieldValue("android.app.LoadedApk", loadedApkInfo, "mApplication", null);
149 | Object oldApplication = Reflect.getFieldValue(
150 | "android.app.ActivityThread", currentActivityThread,
151 | "mInitialApplication");
152 | ArrayList mAllApplications = (ArrayList) Reflect
153 | .getFieldValue("android.app.ActivityThread",
154 | currentActivityThread, "mAllApplications");
155 | mAllApplications.remove(oldApplication);
156 |
157 | ApplicationInfo loadedApk = (ApplicationInfo) Reflect
158 | .getFieldValue("android.app.LoadedApk", loadedApkInfo,
159 | "mApplicationInfo");
160 | ApplicationInfo appBindData = (ApplicationInfo) Reflect
161 | .getFieldValue("android.app.ActivityThread$AppBindData",
162 | mBoundApplication, "appInfo");
163 |
164 | loadedApk.className = appClassName;
165 | appBindData.className = appClassName;
166 |
167 | Application app = (Application) Reflect.invokeMethod(
168 | "android.app.LoadedApk", loadedApkInfo, "makeApplication",
169 | new Object[]{false, null},
170 | boolean.class, Instrumentation.class);
171 |
172 | Reflect.setFieldValue("android.app.ActivityThread", currentActivityThread, "mInitialApplication", app);
173 | return app;
174 | }
175 | }
176 |
--------------------------------------------------------------------------------
/DexProtect/dexshell/src/main/java/com/stormagain/dexshell/Decrypt.java:
--------------------------------------------------------------------------------
1 | package com.stormagain.dexshell;
2 |
3 | /**
4 | * Created by liujian on 2018/4/12.
5 | */
6 |
7 | public class Decrypt {
8 |
9 | public static byte[] decrypt(byte[] src) {
10 | for (int i = 0; i < src.length; i++) {
11 | src[i] = (byte) (src[i] ^ 3);
12 | }
13 | return src;
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/DexProtect/dexshell/src/main/java/com/stormagain/dexshell/ProxyApplication.java:
--------------------------------------------------------------------------------
1 | package com.stormagain.dexshell;
2 |
3 | import android.app.Application;
4 | import android.content.Context;
5 | import android.content.pm.ApplicationInfo;
6 | import android.content.pm.PackageManager;
7 | import android.text.TextUtils;
8 |
9 | /**
10 | * Created by liujian on 2018/4/19.
11 | */
12 |
13 | public class ProxyApplication extends Application {
14 | private String realApplication;
15 | private final String encryptFileName = "data.sec";
16 | private final String KEY = "REAL_APP";
17 |
18 | @Override
19 | protected void attachBaseContext(Context base) {
20 | super.attachBaseContext(base);
21 | try {
22 | ApplicationInfo applicationInfo = getPackageManager().getApplicationInfo
23 | (getPackageName(), PackageManager.GET_META_DATA);
24 | realApplication = applicationInfo.metaData.getString(KEY);
25 |
26 | new ClassLoaderDelegate(this).loadDex(base.getAssets().open(encryptFileName));
27 | } catch (Exception e) {
28 | e.printStackTrace();
29 | }
30 |
31 | }
32 |
33 |
34 | @Override
35 | public void onCreate() {
36 | super.onCreate();
37 | if (!TextUtils.isEmpty(realApplication)) {
38 | Application app = ClassLoaderDelegate.changeTopApplication(realApplication);
39 | if (app != null) {
40 | app.onCreate();
41 | }
42 | }
43 | }
44 |
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/DexProtect/dexshell/src/main/java/com/stormagain/dexshell/Reflect.java:
--------------------------------------------------------------------------------
1 | package com.stormagain.dexshell;
2 |
3 | import java.lang.reflect.Field;
4 | import java.lang.reflect.InvocationTargetException;
5 | import java.lang.reflect.Method;
6 |
7 | public class Reflect {
8 |
9 | /**
10 | * 调用类或对象的方法并返回结果
11 | *
12 | * @param clazz 类
13 | * @param methodName 方法名
14 | * @param obj 调用该方法的对象,如果是静态方法则传null
15 | * @param args 参数,如果没有则传null
16 | * @param parameterTypes 方法参数类型的class,如果没有则传null
17 | * @return 调用结果
18 | */
19 | public static Object invokeMethod(Class> clazz, Object obj, String methodName, Object[] args, Class>... parameterTypes) {
20 | try {
21 | // 反射类指定方法
22 | Method method = clazz.getDeclaredMethod(methodName, parameterTypes);
23 | method.setAccessible(true); // 暴力反射
24 | // 调用方法并返回结果
25 | return method.invoke(obj, args);
26 | } catch (NoSuchMethodException e) {
27 | e.printStackTrace();
28 | } catch (IllegalAccessException e) {
29 | e.printStackTrace();
30 | } catch (IllegalArgumentException e) {
31 | e.printStackTrace();
32 | } catch (InvocationTargetException e) {
33 | e.printStackTrace();
34 | }
35 | return null;
36 | }
37 |
38 | /**
39 | * 调用类或对象的方法并返回结果
40 | *
41 | * @param className 类名
42 | * @param methodName 方法名
43 | * @param obj 调用该方法的对象,如果是静态方法则传null
44 | * @param args 参数,如果没有则传null
45 | * @param parameterTypes 方法参数类型的class,如果没有则传null
46 | * @return 调用结果
47 | */
48 | public static Object invokeMethod(String className, Object obj, String methodName, Object[] args, Class>... parameterTypes) {
49 | try {
50 | // 防止空指针错误
51 | if (parameterTypes == null) {
52 | parameterTypes = new Class[0];
53 | }
54 | if (args == null) {
55 | args = new Object[0];
56 | }
57 | // 加载类的字节码
58 | Class> clazz = Class.forName(className);
59 | return invokeMethod(clazz, obj, methodName, args, parameterTypes);
60 | } catch (ClassNotFoundException e) {
61 | e.printStackTrace();
62 | }
63 | return null;
64 | }
65 |
66 | /**
67 | * 获取对象或类某个字段的值
68 | *
69 | * @param clazz 类
70 | * @param obj 对象,如果是静态字段则传null
71 | * @param fieldName 字段名称
72 | * @return 字段的值
73 | */
74 | public static Object getFieldValue(Class> clazz, Object obj, String fieldName) {
75 | try {
76 | Field field = clazz.getDeclaredField(fieldName);
77 | field.setAccessible(true);
78 | return field.get(obj);
79 | } catch (NoSuchFieldException e) {
80 | e.printStackTrace();
81 | } catch (IllegalAccessException e) {
82 | e.printStackTrace();
83 | } catch (IllegalArgumentException e) {
84 | e.printStackTrace();
85 | }
86 | return null;
87 | }
88 |
89 | /**
90 | * 获取对象或类某个字段的值
91 | *
92 | * @param className 类名
93 | * @param obj 对象,如果是静态字段则传null
94 | * @param fieldName 字段名称
95 | * @return 字段的值
96 | */
97 | public static Object getFieldValue(String className, Object obj, String fieldName) {
98 | try {
99 | Class> clazz = Class.forName(className);
100 | return getFieldValue(clazz, obj, fieldName);
101 | } catch (ClassNotFoundException e) {
102 | e.printStackTrace();
103 | } catch (IllegalArgumentException e) {
104 | e.printStackTrace();
105 | }
106 | return null;
107 | }
108 |
109 | /**
110 | * 设置对象或类某个字段的值
111 | *
112 | * @param clazz 类
113 | * @param obj 对象,如果是静态字段则传null
114 | * @param fieldName 字段名称
115 | * @param value 字段值
116 | * @return 是否设置成功
117 | */
118 | public static boolean setFieldValue(Class> clazz, Object obj, String fieldName, Object value) {
119 | try {
120 | Field field = clazz.getDeclaredField(fieldName);
121 | field.setAccessible(true);
122 | field.set(obj, value);
123 | return true;
124 | } catch (NoSuchFieldException e) {
125 | e.printStackTrace();
126 | } catch (IllegalAccessException e) {
127 | e.printStackTrace();
128 | } catch (IllegalArgumentException e) {
129 | e.printStackTrace();
130 | }
131 | return false;
132 | }
133 |
134 | /**
135 | * 设置对象或类某个字段的值
136 | *
137 | * @param className 类名
138 | * @param obj 对象,如果是静态字段则传null
139 | * @param fieldName 字段名称
140 | * @param value 字段值
141 | * @return 是否设置成功
142 | */
143 | public static boolean setFieldValue(String className, Object obj, String fieldName, Object value) {
144 | try {
145 | Class> clazz = Class.forName(className);
146 | setFieldValue(clazz, obj, fieldName, value);
147 | return true;
148 | } catch (ClassNotFoundException e) {
149 | e.printStackTrace();
150 | } catch (IllegalArgumentException e) {
151 | e.printStackTrace();
152 | }
153 | return false;
154 | }
155 |
156 | /**
157 | * 根据类名实例化一个对象
158 | *
159 | * @param className 类名
160 | * @return 对象实例,如果实例化失败返回null
161 | */
162 | public static Object newInstance(String className) {
163 | try {
164 | Class> clazz = Class.forName(className);
165 | return clazz.newInstance();
166 | } catch (ClassNotFoundException e) {
167 | e.printStackTrace();
168 | } catch (InstantiationException e) {
169 | e.printStackTrace();
170 | } catch (IllegalAccessException e) {
171 | e.printStackTrace();
172 | }
173 | return null;
174 | }
175 | }
176 |
--------------------------------------------------------------------------------
/DexProtect/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | org.gradle.jvmargs=-Xmx1536m
13 |
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 |
--------------------------------------------------------------------------------
/DexProtect/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stormagain/DexProtectPlugin/262c33e9df812ca426dba542ba090d33667099a1/DexProtect/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/DexProtect/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Sat Apr 21 21:00:49 CST 2018
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
7 |
--------------------------------------------------------------------------------
/DexProtect/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/DexProtect/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/DexProtect/protect-plugin/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/DexProtect/protect-plugin/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'groovy'
2 | apply plugin: 'maven'
3 |
4 | dependencies {
5 | implementation gradleApi()
6 | implementation localGroovy()
7 | implementation 'com.android.tools.build:gradle:3.0.1'
8 | }
9 |
10 | repositories {
11 | mavenCentral()
12 | }
13 |
14 | uploadArchives {
15 | repositories {
16 | mavenDeployer {
17 | pom.groupId = 'com.stormagain.dexprotect'
18 | pom.artifactId = 'protect-plugin'
19 | pom.version = 1.0
20 |
21 | repository(url: uri('../release'))
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/DexProtect/protect-plugin/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/DexProtect/protect-plugin/src/main/groovy/com.stormagain.dexprotect/Constant.groovy:
--------------------------------------------------------------------------------
1 | package com.stormagain.dexprotect
2 | /**
3 | * Created by liujian on 2018/4/20.
4 | */
5 | class Constant {
6 |
7 | def static ENCRYPT_FILE_NAME = 'data.sec'
8 |
9 | def static COMM_DEX = 'classes.dex'
10 |
11 | def static ORIGIN_DEX = 'origin.dex'
12 |
13 | def static TARGET_DEX = 'target.dex'
14 |
15 | def static SHELL_DEX = 'shell.dex'
16 |
17 | def static SHELL_MODULE = 'dexshell'
18 |
19 |
20 | }
--------------------------------------------------------------------------------
/DexProtect/protect-plugin/src/main/groovy/com.stormagain.dexprotect/DexProtectExtension.groovy:
--------------------------------------------------------------------------------
1 | package com.stormagain.dexprotect
2 | /**
3 | * Created by liujian on 2018/4/20.
4 | */
5 | class DexProtectExtension {
6 |
7 | boolean dexProtectEnable = true
8 |
9 | }
--------------------------------------------------------------------------------
/DexProtect/protect-plugin/src/main/groovy/com.stormagain.dexprotect/DexProtectPlugin.groovy:
--------------------------------------------------------------------------------
1 | package com.stormagain.dexprotect
2 |
3 | import com.android.build.gradle.AppExtension
4 | import com.android.build.gradle.api.ApplicationVariant
5 | import com.android.build.gradle.internal.pipeline.TransformTask
6 | import com.android.build.gradle.internal.transforms.DexTransform
7 | import groovy.xml.Namespace
8 | import org.gradle.api.GradleException
9 | import org.gradle.api.Plugin
10 | import org.gradle.api.Project
11 | import org.gradle.api.Task
12 | import org.gradle.api.execution.TaskExecutionGraph
13 | import org.gradle.api.execution.TaskExecutionGraphListener
14 |
15 | import java.lang.reflect.Field
16 |
17 | /**
18 | * Created by liujian on 2018/4/20.
19 | */
20 | class DexProtectPlugin implements Plugin {
21 |
22 | def PROXY_APPLICATION = "com.stormagain.dexshell.ProxyApplication"
23 | def META_KEY = "REAL_APP"
24 | def dexProtectEnable
25 |
26 | @Override
27 | void apply(Project project) {
28 |
29 | if (!project.plugins.hasPlugin('com.android.application')) {
30 | throw new GradleException('Android Application plugin required')
31 | }
32 | project.extensions.create('protect', DexProtectExtension)
33 | project.afterEvaluate {
34 | dexProtectEnable = project.extensions.protect.dexProtectEnable
35 | if (!dexProtectEnable) {
36 | return
37 | }
38 | def android = project.extensions.getByType(AppExtension)
39 | try {
40 | //close preDexLibraries
41 | android.dexOptions.preDexLibraries = false
42 | //open jumboMode
43 | android.dexOptions.jumboMode = true
44 | //disable dex archive mode
45 | disableArchiveDex()
46 | } catch (Throwable e) {
47 | //no preDexLibraries field, just continue
48 | }
49 |
50 | android.applicationVariants.all {
51 | variant ->
52 | checkInstantRun(project, variant)
53 | checkMultiDex(variant)
54 | inject(project, variant)
55 | variant.outputs.each {
56 | output ->
57 | output.processManifest.doLast {
58 |
59 | output.processManifest.outputs.files.each { File file ->
60 | def manifestFile = null;
61 | //在gradle plugin 3.0.0之前,file是文件,且文件名为AndroidManifest.xml
62 | //在gradle plugin 3.0.0之后,file是目录,且不包含AndroidManifest.xml,需要自己拼接
63 | //除了目录和AndroidManifest.xml之外,还可能会包含manifest-merger-debug-report.txt等不相干的文件,过滤它
64 | if ((file.name.equalsIgnoreCase("AndroidManifest.xml") && !file.isDirectory()) || file.isDirectory()) {
65 | if (file.isDirectory()) {
66 | //3.0.0之后,自己拼接AndroidManifest.xml
67 | manifestFile = new File(file, "AndroidManifest.xml")
68 | } else {
69 | //3.0.0之前,直接使用
70 | manifestFile = file
71 | }
72 | //检测文件是否存在
73 | if (manifestFile != null && manifestFile.exists()) {
74 | def space = new Namespace('http://schemas.android.com/apk/res/android', 'android')
75 | def root = new XmlParser().parse(manifestFile)
76 | def realApp = root.application[0].attributes().get(space.name)
77 | if (realApp == null || "".equals(realApp)) {
78 | throw new GradleException("no application find")
79 | }
80 |
81 | root.application[0].attributes().put(space.name, PROXY_APPLICATION)
82 | root.application[0].appendNode('meta-data', [(space.name): META_KEY, (space.value): realApp])
83 |
84 | def updatedContent = groovy.xml.XmlUtil.serialize(root)
85 | manifestFile.write(updatedContent, 'UTF-8')
86 | }
87 | }
88 | }
89 |
90 | }
91 | }
92 | }
93 | }
94 | }
95 |
96 | private void checkMultiDex(def variant) {
97 | boolean multiDexEnabled = variant.variantData.variantConfiguration.isMultiDexEnabled()
98 | if (multiDexEnabled) {
99 | throw new GradleException(
100 | "DexProtect does not support multiDex currently."
101 | )
102 | }
103 | }
104 |
105 | private void checkInstantRun(Project project, ApplicationVariant variant) {
106 | def variantName = variant.name.capitalize()
107 | def instantRunTask = getInstantRunTask(project, variantName)
108 | if (instantRunTask != null) {
109 | throw new GradleException(
110 | "DexProtect does not support instant run mode, please trigger build"
111 | + " by assemble${variantName} or disable instant run"
112 | + " in 'File->Settings...'."
113 | )
114 | }
115 | }
116 |
117 | void disableArchiveDex() {
118 | try {
119 | def booleanOptClazz = Class.forName('com.android.build.gradle.options.BooleanOption')
120 | def enableDexArchiveField = booleanOptClazz.getDeclaredField('ENABLE_DEX_ARCHIVE')
121 | enableDexArchiveField.setAccessible(true)
122 | def enableDexArchiveEnumObj = enableDexArchiveField.get(null)
123 | def defValField = enableDexArchiveEnumObj.getClass().getDeclaredField('defaultValue')
124 | defValField.setAccessible(true)
125 | defValField.set(enableDexArchiveEnumObj, false)
126 | } catch (Throwable thr) {
127 | // To some extends, class not found means we are in lower version of android gradle
128 | // plugin, so just ignore that exception.
129 | if (!(thr instanceof ClassNotFoundException)) {
130 | project.logger.error("reflectDexArchiveFlag error: ${thr.getMessage()}.")
131 | }
132 | }
133 | }
134 |
135 | void inject(Project project, ApplicationVariant variant) {
136 |
137 | if (project.name.equals('dexshell')) {
138 | return
139 | }
140 |
141 | project.getGradle().getTaskGraph().addTaskExecutionGraphListener(new TaskExecutionGraphListener() {
142 | @Override
143 | public void graphPopulated(TaskExecutionGraph taskGraph) {
144 | for (Task task : taskGraph.getAllTasks()) {
145 | if (task instanceof TransformTask) {
146 | if (((TransformTask) task).getTransform() instanceof DexTransform && !(((TransformTask) task).getTransform() instanceof DexProtectTransform)) {
147 | DexTransform dexTransform = task.transform
148 | DexProtectTransform hookDexTransform = new DexProtectTransform(project, variant, task.name, dexTransform)
149 |
150 | Field field = TransformTask.class.getDeclaredField("transform")
151 | field.setAccessible(true)
152 | field.set(task, hookDexTransform)
153 | break
154 | }
155 | }
156 | }
157 | }
158 | })
159 | }
160 |
161 | Task getInstantRunTask(Project project, String variantName) {
162 | String instantRunTask = "transformClassesWithInstantRunFor${variantName}"
163 | return project.tasks.findByName(instantRunTask)
164 | }
165 |
166 | }
--------------------------------------------------------------------------------
/DexProtect/protect-plugin/src/main/groovy/com.stormagain.dexprotect/DexProtectTransform.groovy:
--------------------------------------------------------------------------------
1 | package com.stormagain.dexprotect
2 |
3 | import com.android.build.api.transform.*
4 | import com.android.build.gradle.api.ApplicationVariant
5 | import com.android.build.gradle.internal.pipeline.TransformManager
6 | import com.android.build.gradle.internal.transforms.DexTransform
7 | import org.gradle.api.Project
8 |
9 | /**
10 | * Created by liujian on 2018/4/20.
11 | */
12 |
13 | class DexProtectTransform extends Transform {
14 |
15 | Project project
16 | ApplicationVariant variant
17 | DexTransform transform
18 | String buildType
19 |
20 | DexProtectTransform(Project project, ApplicationVariant variant, String taskName, DexTransform transform) {
21 | this.project = project
22 | this.variant = variant
23 | this.transform = transform
24 | //variant.buildType.name not reliable
25 | buildType = taskName.replace('transformDexWithDexFor', '').toLowerCase()
26 | }
27 |
28 | @Override
29 | void transform(TransformInvocation transformInvocation) throws TransformException, InterruptedException, IOException {
30 | transform.transform(transformInvocation)
31 |
32 | File outputDir = transformInvocation.getOutputProvider().getContentLocation("main", TransformManager.CONTENT_DEX, TransformManager.SCOPE_FULL_PROJECT, Format.DIRECTORY)
33 | File outputDex = new File(outputDir.getAbsolutePath() + File.separator + Constant.COMM_DEX)
34 | File originDex = new File(outputDir.getAbsolutePath() + File.separator + Constant.ORIGIN_DEX)
35 | outputDex.renameTo(originDex)
36 |
37 | File targetDex = new File(outputDir.getAbsolutePath() + File.separator + Constant.TARGET_DEX)
38 | if (targetDex.exists()) {
39 | targetDex.delete()
40 | }
41 |
42 | Utils.makeEncryptDex(originDex.absolutePath, targetDex.absolutePath)
43 |
44 | def assetsPath = new File(variant.packageApplication.assets.asPath).getParent() + File.separator + buildType + File.separator
45 | File assetsFile = new File(assetsPath)
46 | if (!assetsFile.exists()) {
47 | assetsFile.mkdirs()
48 | }
49 | File encDexFile = new File(assetsFile, Constant.ENCRYPT_FILE_NAME)
50 | targetDex.renameTo(encDexFile)
51 |
52 | File shellDex = new File(project.rootProject.project(Constant.SHELL_MODULE).projectDir.absolutePath + File.separator + Constant.SHELL_DEX)
53 | Utils.copyFile(shellDex, outputDex)
54 |
55 | originDex.delete()
56 | targetDex.delete()
57 | }
58 |
59 | @Override
60 | String getName() {
61 | return transform.getName()
62 | }
63 |
64 | @Override
65 | Set getInputTypes() {
66 | return transform.getInputTypes()
67 | }
68 |
69 | @Override
70 | Set getOutputTypes() {
71 | return transform.getOutputTypes()
72 | }
73 |
74 | @Override
75 | Set super QualifiedContent.Scope> getScopes() {
76 | return transform.getScopes()
77 | }
78 |
79 | @Override
80 | boolean isIncremental() {
81 | return transform.isIncremental()
82 | }
83 |
84 | @Override
85 | Set super QualifiedContent.Scope> getReferencedScopes() {
86 | return transform.getReferencedScopes()
87 | }
88 |
89 | @Override
90 | Collection getSecondaryFiles() {
91 | return transform.getSecondaryFiles()
92 | }
93 |
94 | @Override
95 | Collection getSecondaryFileOutputs() {
96 | return transform.getSecondaryFileOutputs()
97 | }
98 |
99 | @Override
100 | Collection getSecondaryDirectoryOutputs() {
101 | return transform.getSecondaryDirectoryOutputs()
102 | }
103 |
104 | @Override
105 | Map getParameterInputs() {
106 | return transform.getParameterInputs()
107 | }
108 |
109 | @Override
110 | boolean isCacheable() {
111 | return transform.isCacheable()
112 | }
113 | }
114 |
--------------------------------------------------------------------------------
/DexProtect/protect-plugin/src/main/groovy/com.stormagain.dexprotect/Utils.java:
--------------------------------------------------------------------------------
1 | package com.stormagain.dexprotect;
2 |
3 | import java.io.ByteArrayOutputStream;
4 | import java.io.File;
5 | import java.io.FileInputStream;
6 | import java.io.FileOutputStream;
7 | import java.io.IOException;
8 |
9 | /**
10 | * Created by liujian on 2018/4/20.
11 | */
12 |
13 | public class Utils {
14 |
15 | public static void makeEncryptDex(String originDexPath, String targetDexPath) throws Exception {
16 | File originDex = new File(originDexPath);
17 | byte[] encrypt = encrypt(readFileBytes(originDex));
18 | File targetDex = new File(targetDexPath);
19 | if (targetDex.exists()) {
20 | targetDex.delete();
21 | }
22 | targetDex.createNewFile();
23 |
24 | FileOutputStream ops = new FileOutputStream(targetDex);
25 | ops.write(encrypt);
26 | ops.flush();
27 | ops.close();
28 | }
29 |
30 | public static void copyFile(File fromFile, File toFile) throws IOException {
31 | FileInputStream ins = new FileInputStream(fromFile);
32 | FileOutputStream out = new FileOutputStream(toFile);
33 | byte[] b = new byte[1024];
34 | int n = 0;
35 | while ((n = ins.read(b)) != -1) {
36 | out.write(b, 0, n);
37 | }
38 | ins.close();
39 | out.close();
40 | }
41 |
42 | public static byte[] encrypt(byte[] src) {
43 | for (int i = 0; i < src.length; i++) {
44 | src[i] = (byte) (src[i] ^ 3);
45 | }
46 | return src;
47 | }
48 |
49 | public static byte[] readFileBytes(File file) throws IOException {
50 | byte[] buffer = new byte[1024];
51 | ByteArrayOutputStream os = new ByteArrayOutputStream();
52 | FileInputStream fis = new FileInputStream(file);
53 | try {
54 | while (true) {
55 | int i = fis.read(buffer);
56 | if (i != -1) {
57 | os.write(buffer, 0, i);
58 | } else {
59 | return os.toByteArray();
60 | }
61 | }
62 | } catch (IOException e) {
63 | throw e;
64 | } finally {
65 | fis.close();
66 | os.close();
67 | }
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/DexProtect/protect-plugin/src/main/resources/META-INF/gradle-plugins/protect-plugin.properties:
--------------------------------------------------------------------------------
1 | implementation-class=com.stormagain.dexprotect.DexProtectPlugin
--------------------------------------------------------------------------------
/DexProtect/release/com/stormagain/dexprotect/protect-plugin/1.0/protect-plugin-1.0.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stormagain/DexProtectPlugin/262c33e9df812ca426dba542ba090d33667099a1/DexProtect/release/com/stormagain/dexprotect/protect-plugin/1.0/protect-plugin-1.0.jar
--------------------------------------------------------------------------------
/DexProtect/release/com/stormagain/dexprotect/protect-plugin/1.0/protect-plugin-1.0.jar.md5:
--------------------------------------------------------------------------------
1 | 0ce3638635917421ce1ce9ffd7985b7d
--------------------------------------------------------------------------------
/DexProtect/release/com/stormagain/dexprotect/protect-plugin/1.0/protect-plugin-1.0.jar.sha1:
--------------------------------------------------------------------------------
1 | aa5f40ae4e4264189fcb65b6f2bf229bb51bd95a
--------------------------------------------------------------------------------
/DexProtect/release/com/stormagain/dexprotect/protect-plugin/1.0/protect-plugin-1.0.pom:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 | com.stormagain.dexprotect
6 | protect-plugin
7 | 1.0
8 |
9 |
10 | com.android.tools.build
11 | gradle
12 | 3.0.1
13 | runtime
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/DexProtect/release/com/stormagain/dexprotect/protect-plugin/1.0/protect-plugin-1.0.pom.md5:
--------------------------------------------------------------------------------
1 | fa9e7684f6784caabfa2dd35ebf7130e
--------------------------------------------------------------------------------
/DexProtect/release/com/stormagain/dexprotect/protect-plugin/1.0/protect-plugin-1.0.pom.sha1:
--------------------------------------------------------------------------------
1 | 083772e228b918a954e9e2df09c6318185e71ced
--------------------------------------------------------------------------------
/DexProtect/release/com/stormagain/dexprotect/protect-plugin/maven-metadata.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | com.stormagain.dexprotect
4 | protect-plugin
5 |
6 | 1.0
7 |
8 | 1.0
9 |
10 | 20180421141257
11 |
12 |
13 |
--------------------------------------------------------------------------------
/DexProtect/release/com/stormagain/dexprotect/protect-plugin/maven-metadata.xml.md5:
--------------------------------------------------------------------------------
1 | 6d2adcea29d646775b40859cea406188
--------------------------------------------------------------------------------
/DexProtect/release/com/stormagain/dexprotect/protect-plugin/maven-metadata.xml.sha1:
--------------------------------------------------------------------------------
1 | 9454845873c2b36051d0bb901bb49fe456b0b5f9
--------------------------------------------------------------------------------
/DexProtect/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app',':dexshell', ':protect-plugin'
2 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "[]"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright [yyyy] [name of copyright owner]
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # DexProtectPlugin
2 | 能自动实现Apk加固的Gradle插件
3 |
4 | # 背景
5 | 很多开发者都是使用第三方加固服务,这些加固基本上都是面向Apk文件的加固,可能还涉及到重新签名,感觉挺麻烦。
6 | 也许我们需要一种加固服务,让自己可以控制核心的加解密算法,也不需要将原始apk暴露给第三方平台,
7 | 而且伴随着Gradle构建Apk的过程就自动产生了加固后的Apk,听起来是不是有趣呢?
8 |
9 | # 现有Feature
10 | 1:一代加固方案(后续会努力实现二代三代加固方案,从目前来看,知识储备有限,距离VMP加固方案还比较远,有研究的朋友可以联系我)
11 | 2:Gradle自动生成加固Apk
12 |
13 | # 预计下个版本支持的Feature
14 | 1: multiDex
15 | 2: Dex文件不落地加载
16 |
17 | # 灵感来源(感谢开源精神)
18 | 1:Tinker(https://github.com/Tencent/tinker)
19 | 2:ApkToolPlus(https://github.com/linchaolong/ApkToolPlus)
20 |
--------------------------------------------------------------------------------