|
| 1 | +<h1 align="center">GetDex</h1> |
| 2 | +<p> |
| 3 | + <a href="https://github.com/Mivik/GetDex/blob/master/LICENSE.md" target="_blank"> |
| 4 | + <img alt="License: GPL--3.0" src="https://img.shields.io/badge/License-GPL--3.0-yellow.svg" /> |
| 5 | + </a> |
| 6 | +</p> |
| 7 | + |
| 8 | +> A powerful tool to dump dex files whose instructions are replaced with nop |
| 9 | +
|
| 10 | +## Author |
| 11 | + |
| 12 | +👤 **Mivik** |
| 13 | + |
| 14 | +* Website: https://mivik.gitee.io/ |
| 15 | +* Github: [@Mivik](https://github.com/Mivik) |
| 16 | + |
| 17 | +## Introduction |
| 18 | + |
| 19 | +GetDex is designed as a Xposed plugin to dump dex, which can also fix dex opcodes that are replaced with nop. |
| 20 | + |
| 21 | +Before starting, you should have either [Xposed](https://github.com/rovo89/XposedInstaller) or [EdXposed](https://github.com/ElderDrivers/EdXposedManager) installed on your phone. **Since GetDex is only desinged for ART-supported android versions, I recommend EdXposed since Xposed has incomplete support on these android versions.** |
| 22 | + |
| 23 | +Until now, GetDex is only tested in Android 10.0. |
| 24 | + |
| 25 | +## Usage |
| 26 | + |
| 27 | +Here's simple three steps to dump "nopped" dex files from an application. |
| 28 | + |
| 29 | +### Step 1. Configure package names and classes you want to fix |
| 30 | + |
| 31 | +Look into `app/src/main/java/com/mivik/mxp/Const.java` and modify the value of `SELF_PACKAGE_NAME` to the new package name if you want (note that `SELF_PACKAGE_NAME` must be equal with the one specified in project's build.gradle and AndroidManifest.xml), and **most importantly**, modify the value of `TARGET_PACKAGE_NAME` to the package you want to dump dex from. For example: |
| 32 | + |
| 33 | +```java |
| 34 | +public final class Const { |
| 35 | + public static String T = "MXP"; |
| 36 | + public static final String SELF_PACKAGE_NAME = "com.mivik.getdex"; |
| 37 | + public static final String TARGET_PACKAGE_NAME = "com.tencent.mobileqq"; |
| 38 | + |
| 39 | + ...... |
| 40 | +} |
| 41 | +``` |
| 42 | + |
| 43 | +After configuring package names, you also need to configure the filter to specify what class you want to fix since fixing system classes would possibly cause plugin to crash. The filter is located in `app/src/main/kotlin/com/mivik/getdex/MainHook.kt`. The interface `ClassFilter` is defined to receive a class name and return whether the class should be fixed (all the classes in the application will be passed into this filter). For example: |
| 44 | + |
| 45 | +```kotlin |
| 46 | + ...... |
| 47 | + if (classLoader is BaseDexClassLoader) GetDex.fixAllClasses( |
| 48 | + classLoader, |
| 49 | + object : GetDex.ClassFilter { |
| 50 | + override fun filter(className: String): Boolean { |
| 51 | + return className.startsWith("com.tencent.mobileqq.") |
| 52 | + } |
| 53 | + }) |
| 54 | + else Log.e(T, "ClassLoader is not BaseDexClassLoader, please fixClass manually") |
| 55 | + ...... |
| 56 | +``` |
| 57 | + |
| 58 | +If you are not familiar with Kotlin, don't worry. You just need to write a java class `com.mivik.getdex.MainHook` which implemented `IXposedHookLoadPackage`, and hook the target application's `android.content.ContextWrapper.attachBaseContext` methods, and do the following steps before the hooked method starts (remember to remove the corresponding kotlin file): |
| 59 | + |
| 60 | +```java |
| 61 | + Context context = (Context) param.args[0] |
| 62 | + GetDex.initialize(context) |
| 63 | + if (context.classLoader instanceof BaseDexClassLoader) |
| 64 | + GetDex.fixAllClasses((BaseDexClassLoader) context.classLoader, new GetDex.ClassFilter() { |
| 65 | + @Override |
| 66 | + public boolean filter(String className) { |
| 67 | + // Your filter here |
| 68 | + return false; |
| 69 | + } |
| 70 | + }) |
| 71 | +``` |
| 72 | + |
| 73 | +BTW, you can call `GetDex.fixClass(Class)` to fix a single class. |
| 74 | + |
| 75 | +### Step 2. Install the plugin and reboot your phone |
| 76 | + |
| 77 | +It's a must-do to reboot your phone since Xposed plugins need rebooting to be activated. |
| 78 | + |
| 79 | +Note that I used a trick to simplify this step, so you don't need to reboot anymore after your first rebooting even you changed some code in this plugin. You just need to restart the application you want to hook into (or the application you want to dump dex from) to apply your changes. |
| 80 | + |
| 81 | +### Step 3. Start the target application |
| 82 | + |
| 83 | +That's all! After these three steps, you will see your dex dumped in `/data/data/[TARGET_PACKAGE_NAME]/files/getdex`. If you don't find any, please record all your logs contains 'GetDex' and post it as an issue. |
| 84 | + |
| 85 | +## 🤝 Contributing |
| 86 | + |
| 87 | +Contributions, issues and feature requests are welcome!<br />Feel free to check [issues page](https://github.com/Mivik/GetDex/issues). |
| 88 | + |
| 89 | +## Show your support |
| 90 | + |
| 91 | +Give a ⭐️ if this project helped you! |
| 92 | + |
| 93 | +## 📝 License |
| 94 | + |
| 95 | +Copyright © 2020 [Mivik](https://github.com/Mivik).<br /> |
| 96 | +This project is [GPL-3.0](https://github.com/Mivik/GetDex/blob/master/LICENSE.md) licensed. |
0 commit comments