Dex manipulation library

Overview

dexterity

Description

dexterity is a C library intended for manipulation and analysis of DEX files. It has python bindings for all basic DEX structures and most of the manipulation functions.

WARNING: This library is still in it's early stages of development, use at your own risk!

Examples

Mirror

The following example parses a DEX file using the built-in parser and then writes a new DEX file from the parsed structures in memory.

#!/usr/bin/python

from dx.dex import Dex

dex = Dex("classes.dex")
dex.save("mirror.dex")
Add String

The following example parses a DEX file, add a string to it, creates a new DEX file with the modifications and fix the signature and checksum of the new file.

#!/usr/bin/python

from dx.dex import Dex
from dx.hash import update_signature
from dx.hash import update_checksum

dex = Dex("classes.dex")
dex.add_string("Hello World")
dex.save("hello.dex")

update_signature("hello.dex")
update_checksum("hello.dex")

For more examples of other usages of the library, check the examples folder.

License

dexterity is released under BSD 3-clause license. Please check LICENSE for more details.

Support

For questions and/or suggestions, join #droidsec on Freenode.

Comments
  • Make Error OSX

    Make Error OSX

    gcc version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00) 12.2.1 Darwin Kernel Version 12.2.1:

    When I try run make on my OSX box I get the following errors:

    $ make make -C lib gcc -fPIC -std=gnu99 -g -c bytestream.c bytestream.c:2:20: error: malloc.h: No such file or directory bytestream.c: In function ‘bsalloc’: bytestream.c:16: warning: implicit declaration of function ‘printf’ bytestream.c:16: warning: incompatible implicit declaration of built-in function ‘printf’ bytestream.c:27: error: ‘MAP_ANONYMOUS’ undeclared (first use in this function) bytestream.c:27: error: (Each undeclared identifier is reported only once bytestream.c:27: error: for each function it appears in.) bytestream.c:31: warning: incompatible implicit declaration of built-in function ‘printf’ bytestream.c: In function ‘bsmap’: bytestream.c:46: warning: incompatible implicit declaration of built-in function ‘printf’ bytestream.c:52: warning: incompatible implicit declaration of built-in function ‘printf’ bytestream.c:60: warning: incompatible implicit declaration of built-in function ‘printf’ bytestream.c:76: warning: incompatible implicit declaration of built-in function ‘printf’ bytestream.c: In function ‘bssave’: bytestream.c:250: error: ‘FILE’ undeclared (first use in this function) bytestream.c:250: error: ‘f’ undeclared (first use in this function) bytestream.c:250: warning: implicit declaration of function ‘fopen’ bytestream.c:254: warning: implicit declaration of function ‘fwrite’ bytestream.c:254: warning: incompatible implicit declaration of built-in function ‘fwrite’ bytestream.c:256: warning: implicit declaration of function ‘fflush’ bytestream.c:257: warning: implicit declaration of function ‘fclose’ make[1]: *** [bytestream] Error 1 make: *** [build_lib] Error 2

    opened by HenryHoggard 3
  • Documentation on libdexterity.so

    Documentation on libdexterity.so

    I know it's been a while since this project has been touched but while it's being a side result of the code: Is it possible to get something like a usage example or API documentation on libdexterity?

    I was looking for a Dex-Parser in C and it was the closest I got, but I am having a hard time trying to use the lib for a project.

    Thanks in advance!

    opened by strangeloveBsc 2
  • Wrong size of the struct

    Wrong size of the struct

    DXPARSE(_name,_type) use the size of the struct to load the data. However, sizeof DexTypeItem is wrong due to the default alignment in compiler. Therefore DXPARSE read two more extra bytes when reading DexTypeItem which set the buffer position in wrong place.

    opened by fredrikluo 1
  • Improve const-correctness

    Improve const-correctness

    I suggest to add the key word "const" to the type specifiers for parameters like "filename" (functions "bsmap" and "dx_build"). Would you like to apply the advices from an article to more places in your source files?

    opened by elfring 3
  • reserved identifier violation

    reserved identifier violation

    I would like to point out that identifiers like "__DEX__" and "_ByteStream" do not fit to the expected naming convention of the C language standard. Would you like to adjust your selection for unique names?

    opened by elfring 4
Owner
Rodrigo Chiossi
Rodrigo Chiossi
A program to flip every private, protected and package-private access flag to public in an Android dex file!

DexExposed A program to flip every private, protected and package-private access flag to public in an Android dex file! Building Simply run gradle mak

John Doe 2 Aug 29, 2021
An advanced DEX editor for Android.

Dexter A WIP DEX editor (hence the name Dexter) for Android that uses Smali. Available decompilers JADX Fernflower CFR JD-Core Procyon TO-DO Implement

Mike Anderson 72 Dec 23, 2022
Appdbg - make it possible to run android dex file in original Java Virtual Machine

Appdbg - make it possible to run android dex file in original Java Virtual Machine

null 137 Dec 20, 2022
Smali/baksmali is an assembler/disassembler for the dex format used by dalvik, Android's Java VM implementation

About smali/baksmali is an assembler/disassembler for the dex format used by dalvik, Android's Java VM implementation. The syntax is loosely based on

Ben Gruver 5.7k Dec 27, 2022
Signal Protocol library for Java/Android

Overview A ratcheting forward secrecy protocol that works in synchronous and asynchronous messaging environments. PreKeys This protocol uses a concept

Signal 1.8k Dec 24, 2022
Grab’n Run, a simple and effective Java Library for Android projects to secure dynamic code loading.

Grab’n Run, a simple and effective Java Library for Android projects to secure dynamic code loading.

Luca Falsina 418 Dec 29, 2022
A simple library that can help you detect if you app is modded or tampered with

Android Tamper Detector A simple library that can help you detect if you app is modded or tampered with. This adds a security level that makes it diff

Mukesh Solanki 130 Nov 14, 2022
Simple API to perform AES encryption on Android. This is the Android counterpart to the AESCrypt library Ruby and Obj-C (with the same weak security defaults :( ) created by Gurpartap Singh. https://github.com/Gurpartap/aescrypt

AESCrypt-Android Simple API to perform AES encryption on Android with no dependancies. This is the Android counterpart to the AESCrypt library Ruby an

Scott Alexander-Bown 636 Dec 18, 2022
🔓 Kotlin version of the popular google/easypermissions wrapper library to simplify basic system permissions logic on Android M or higher.

?? Kotlin version of the popular google/easypermissions wrapper library to simplify basic system permissions logic on Android M or higher.

Madalin Valceleanu 327 Dec 30, 2022
PermissionX is an extension Android library that makes Android runtime permission request extremely easy

PermissionX is an extension Android library that makes Android runtime permission request extremely easy. You can use it for basic pe

Lin Guo 2.9k Dec 28, 2022
ZRoot is a library that makes it easy to use root on Android, such as calling system service with root privilege.

ZRoot is a library that makes it easy to use root on Android, such as calling system service with root privilege. Usage See sample or user guide

null 2 Nov 26, 2021
If you have trouble pinning your custom icon to Launcher dynamically, try this library

CustomIconHelperX If you have trouble pinning your custom icon to Launcher dynam

Valentine Liao 1 Jan 4, 2022
MiHawk 🦅👁️ is simple and secure 🔒 Android Library to store and retrieve pair of key-value data with encryption , internally it use jetpack DataStore Preferences 💽 to store data.

MiHawk MiHawk ?? ??️ is simple and secure ?? Android Library to store and retrieve pair of key-value data with encryption , internally it use jetpack

Nedal Hasan Ibrahem 5 Sep 3, 2022
A library for image manipulation with power of renderScript which is faster than other ordinary solutions.

Pixl is a library for image manipulation with power of renderScript which is faster than other ordinary solutions, currently it includes three basic scripts, brightness, contrast, saturation.

Jibran Iqbal 20 Jan 23, 2022
An image manipulation library for Kotlin

Sketch An image manipulation library for Kotlin. Sketch doesn't require any external installation like OpenCV or OCR and can be used right away. It's

Eugene R. 40 Oct 30, 2022
Android & Pure Java library for sound manipulation

soundtransform Android & Pure Java library to shape a voice with an instrument. Table of Contents How to use the library FluentClient FluentClient sam

LiBe 42 Sep 12, 2021
Tinker is a hot-fix solution library for Android, it supports dex, library and resources update without reinstall apk.

Tinker Tinker is a hot-fix solution library for Android, it supports dex, library and resources update without reinstalling apk. Getting started Add t

Tencent 16.6k Dec 29, 2022
A high performance dex deobfuscator library.

DexKit-Android README|中文文档 This repository update has been terminated, Please use DexKit in the future, it's easier to use. A high performance dex deo

null 39 Oct 9, 2022
Dex to Java decompiler

JADX jadx - Dex to Java decompiler Command line and GUI tools for producing Java source code from Android Dex and Apk files Main features: decompile D

null 32.8k Jan 2, 2023
Command-line tool to count per-package methods in Android .dex files

dex-method-counts Simple tool to output per-package method counts in an Android DEX executable grouped by package, to aid in getting under the 65,536

Mihai Parparita 2.6k Nov 25, 2022