GithubHelp home page GithubHelp logo

zyq8709 / dexhunter Goto Github PK

View Code? Open in Web Editor NEW
1.3K 126.0 533.0 208.02 MB

General Automatic Unpacking Tool for Android Dex Files

License: Apache License 2.0

Makefile 0.43% C++ 50.73% C 2.27% LLVM 0.03% Shell 0.76% Assembly 21.26% Java 22.89% Objective-J 0.52% Python 0.16% CSS 0.01% HTML 0.62% JavaScript 0.19% Batchfile 0.01% Jasmin 0.07% Awk 0.06% Perl 0.01%

dexhunter's Introduction

DexHunter

#####NOTICE: The feature string is very important. It may be changed along with the evolution of hardening services. If it is incorrect, the unpacking process cannot be triggered. DexHunter leverages "fwrite" and other libc functions to manipulate files. But these functions are hooked by hardening services resulting in the crash of the process. As a result, you cannot utilize the provided image to unpack the latest hardedning services. You had better replace these functions with the direct system calls to avoid crash.

DexHunter aims at unpacking hardened dex file automatically.

DexHunter is based on the source code of Android runtime. It is composed of modified ART and DVM runtime. You can use the modified runtime to replace the original content in Android source codes (Android 4.4.3). The modification is mainly in "art/runtime/class_linker.cc" (ART) and "dalvik/vm/native/dalvik_system_DexFile.cpp" (DVM).

###Usage:

If you want to unpack an app, you need to push the "dexname" file to "/data/" in the mobile before starting the app. The first line in "dexname" is the feature string (referring to "slide.pptx"). The second line is the data path of the target app (e.g. "/data/data/com.test.test/"). Its line ending should be in the style of Unix/Linux. You can observe the log using "logcat" to determine whether the unpacking procedure is finished. Once done, the generated "whole.dex" file is the wanted result which is located in the app's data directory.

###Tips:

  1. DexHunter simply reuses the content before "class_def" section instead of parsing them for the efficiency. If there are some problems, you can parse and reassemble them again or amend them statically.

  2. It is worth noting that some "annotation_off" or "debug_info_off" fields may be invalid in the result. These fileds have nothing to do with execution just to hinder decompiling. We do not deal with this situation specifically for the moment. You can just program some scripts to set the invalid fileds with 0x00000000.

  3. As is known, some hardening services can protect several methods in the dex file by restoring the instructions just before being executed and wiping them just after finished. So you also need to modify the "DoInvoke" (ART) or "dvmMterp_invokeMethod" (DVM) function to extract the protected instruction while being executed.

4)The feature string may be changed along with the evolution of hardening services.

5)If the "fwrite" and other libc functions fail, maybe these functions are hooked by hardening sevices. As a result, you cannot dump the memory via them. You can bypass this limitation by calling relevant system calls directly.

DexHunter has its own limitation. As the hardening services develop, DexHunter may be not effective in the future. If you are interested, you can amend DexHunter to keep pace with hardening services continuously.

###File description:

"slide.pptx" is the presentation material of HITCON 2015 (http://hitcon.org/2015/ENT/Activities-Enterprise-Agenda.html#zyq) depicting the design and implementation of DexHunter.

"demo.mp4" is the demonstration video of unpacking a hardened app by Ali.

"test.apk" is the sample used in the video.

"dexname" is the configuration file used in the video.

"art" directory is the modified runtime for ART.

"dalvik" directory is the modified runtime for DVM.

"image" 7z files contain the system image files used in the video.

If you have any question, please contact me via emails to [email protected].

If you use this code, please cite the following paper. Thanks!

Yueqian Zhang, Xiapu Luo, and Haoyang Yin, DexHunter: Toward Extracting Hidden Code from Packed Android Applications, Proceedings of the 20th European Symposium on Research in Computer Security (ESORICS), Vienna, Austria, September 2015.

@inproceedings{DexHunter15, Title = {DexHunter: Toward Extracting Hidden Code from Packed Android Applications}, Author = {Yueqian Zhang and Xiapu Luo and Haoyang Yin}, Booktitle = {Proc. ESORICS}, Year = {2015}}

#####Comment:

I have tested the samples from 360 in July under DVM. The feature string is changed to "/data/app/XXX.apk" (referring to "silde.pptx"). This string is very important. If it is incorrect, the unpacking process will fail.

dexhunter's People

Contributors

tetyys avatar zyq8709 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dexhunter's Issues

请问如何重新编译dalvikvm?

请问如何重新编译dalvikvm?
我在源码top下面make dalvikvm会生成:
MD5 (out/target/product/vbox_x86/system/bin/dalvikvm) = b438d287dd74cf8c389ee805dc62d4fa MD5 (out/target/product/vbox_x86/system/lib/libc.so) = 1cd450dfff24022a7a7936bba4981d91 MD5 (out/target/product/vbox_x86/system/lib/libcutils.so) = 5c751d9eb15824ac253f40364cae0d65 MD5 (out/target/product/vbox_x86/system/lib/libdl.so) = f35221ed24b9a7d2b96600382c806861 MD5 (out/target/product/vbox_x86/system/lib/liblog.so) = b380680e1b4d8ce856938d777b979770 MD5 (out/target/product/vbox_x86/system/lib/libm.so) = 2d56296e93d8beb8730206d00205a446 MD5 (out/target/product/vbox_x86/system/lib/libnativehelper.so) = edd79e7fe1d328475f9f4044671fe857 MD5 (out/target/product/vbox_x86/system/lib/libstdc++.so) = 62687683e46f5570f35ec7a9dd227d01 MD5 (out/target/product/vbox_x86/system/lib/libstlport.so) = 5a780d5c62f7e91eeaecc9ddf70d740a MD5 (out/target/product/vbox_x86/system/usr/share/zoneinfo/tzdata) = c382c90913b3a1ad1010dff003b6a679
但是修改source/dalvikvm里面的代码后编译出来的md5一点都没有变。
请问该如何操作?

test.apk

这个test.apk本身不可以运行 在4.2.2系统中

Missing initial steps

Hi, I am missing the first few steps to get DexHunter work. Could you please explain what I am doing wrong?

I cloned the repository + I have the Android SDK tools etc.
Then, I uncompressed the 7z image, and used it to launch an emulator:

emulator -system system.img -ramdisk ramdisk.img -kernel kernel-qemu-armv7 -initdata userdata-qemu.img -avd New442 &

Is this correct? (NB. I also tried with an Android 5.1.1)

Then, I installed the packed application on the emulator:

adb install mysample.apk

As it is packed with Ijiami, I edited the file dexname to contain:

/data/data/com.mysample/cache/.
/data/data/com.mysample

Is this correct? or am I meant to put something after "cache/. "?
I transfered the file to the emulator:

adb push dexname /data

Then, I started reading the logs keeping an eye on "GOT IT" messages.

adb logcat

and I started the packed application in the emulator. I did get GOT IT messages:

Finally, I retrieved the app in /data/data/com.mysample:

 adb pull /data/data/com.mysample/com.mysample-1.apk .

But something obviously did not work because that APK is very small (5536 bytes only) and not valid (trying to open with JEB)

 Opening file com.mysample-1.dex
 Invalid file
 Error, no DEX file

Missing usage instructions

Neither the README nor the video seem to give away how to prep a device / emulator so that it runs the dexhunter code. How is this done or am I missing something?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.