# BlackDex

![](https://img.shields.io/badge/language-java-brightgreen.svg)

BlackDex is an Android unpack tool, it supports Android 5.0~12 and need not rely to any environment. BlackDex can run on any Android mobile phone or emulator, you can unpack APK File in several seconds.

## Declaration

### This project is not directed against any encryption, it does not deal with environment detection. BlackDex is a free and open source project, only for learning, do not use it for illegal purpose. Otherwise, the legal consequences and liabilities will be born by violator.

## Description

This project supports almost all the Android system above 5.0, it has **high successful rate** to dump DexFile **quickly** and **conveniently**. Generally, it only takes a few seconds to unpack an installed app. For the APK File that is not installed on your device, BlackDex will spends some time on copying file, the length of time depend on file size.

## Principle

BlackDex unpacks APK File by DexFile cookie. In theory, it supports all version Android systems that use ART (Android Runtime). But it may vary from a few special devices. We do not have enough resources to execute a lot of testing, if you have problems with this project, please open an issue on the GitHub.

## Deep Unpacking

BlackDex will fix the DexCode in deep unpacking mode, it can load DexCode which were pointed to other Memory Blocks into DexFile. By this way, we can restore some methods which were erased with NOP. But it can not fix all methods. For example, some applications restore the instructions just before being executed. In this situation, BlackDex can not restore the instructions into DexFile. Deep Unpacking dose not include operation of decryption and executing methods. This feature was still in the test phase, **it is possible that following cases will occur, may the NOP has no longer exists in this world!**

1.BlackDex will take more time to unpack an app, it expected to take a few minutes or more.

2.The target application is possible to crash when BlackDex is unpacking it(Environment detection, etc).

3.The failure rate of unpacking will be increased.

4.It may not always fix all methods successfully.

### Comparison
![xx](nop_diff.jpg)

## Environment

- An Android mobile phone or emulator
- ~~Xposed~~
- ~~Frida~~
- ~~Magisk~~
- ~~Root~~
- ~~A custom ROM~~

## Special Instructions

This project distinguishes between 32-bit and 64-bit, it was compiled to 2 different demos. If you can not find your target in installed packages list, please use another version.

BlackDex download：https://github.com/CodingGay/BlackDex/releases

## Preview

![xx](demonstration.gif)

## References

- [VirtualApp](https://github.com/asLody/VirtualApp)
- [VirtualAPK](https://github.com/didi/VirtualAPK)
- [FreeReflection](https://github.com/tiann/FreeReflection)
- [Dreamland](https://github.com/canyie/Dreamland)

### License

> ```
> Copyright 2021 Milk
>
> Licensed under the Apache License, Version 2.0 (the "License");
> you may not use this file except in compliance with the License.
> You may obtain a copy of the License at
>
> http://www.apache.org/licenses/LICENSE-2.0
>
> Unless required by applicable law or agreed to in writing, software
> distributed under the License is distributed on an "AS IS" BASIS,
> WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
> See the License for the specific language governing permissions and
> limitations under the License.
> ```