Skip to main content

DEX-Parser: The Scalpel for Dalvik Executables

Powered By: Androguard Sponsor PYPY

Description

The soul of every Android app is its code, compiled into a compact, efficient Dalvik Executable (DEX) format. dex-parser is the surgical tool designed to lay this soul bare.

This is a standalone, dependency-free, native Python library built to parse the complete structure of DEX files. It is a core pillar of the new Androguard Ecosystem, providing a high-fidelity map of an application's code layout—its classes, methods, fields, and strings—before deeper analysis begins.

Philosophy

Following the "Deconstruct to Reconstruct" philosophy, dex-parser operates as a specialized, independent library. It does not concern itself with the meaning of the bytecode; its singular focus is on perfectly and performantly reading the blueprint of the executable. This separation of concerns makes it a robust and reliable foundation for any tool that needs to understand the structure of Dalvik code.

Key Features

  • Full Structure Parsing: Reads and indexes the entire DEX file, including the header, string table, type identifiers, method prototypes, and class definitions.
  • Class & Method Enumeration: Provides a clean, Pythonic API to iterate through all defined classes, their methods (both direct and virtual), and their fields.
  • On demand access for each fields by using Hachoir library.
  • Cross-Reference Ready: Lays the groundwork for building cross-references by cleanly separating method and field definitions from their invocations.
  • Pure & Pythonic: Written in native Python with zero external dependencies for maximum portability.
  • [TODO] Multi-DEX Aware: Natively understands and can parse classes.dex, classes2.dex, and so on, providing a unified view of the application's code.

Installation

If you would like to install it locally, please create a new venv to use it directly, and then:

$ git clone https://github.com/androguard/dex-parser.git
$ pip install -e .

or directly via pypi:

$ pip install dexparser-ag

Examples

You can directly use it by command line to parse and display quickly information about a DEX file, but the purpose of this tool is mainly to be a library for other tools like Androguard.

$ dexparser -i Test.dex

## Usage

You can open a dex file directly by using the DEX class:

from hachoir.stream.input_helper import FileInputStream
from dexparser import DEX

d = DEX(FileInputStream(arguments.input))

and use directly the raw access to each field of the DEX structure, like the header, and after access to each subfields:

print(d["header"])
print(d["headermagic/magic"].value)

Main fields that are accessible are:

  • header
  • map_list
  • string_id_item
  • string_data_item
  • proto_id_item
  • type_id_item
  • method_id_item
  • field_id_item
  • class_id_item
  • class_data_item

And so you can have access to all subfields, please see each corresponding class in the source code :)

Or you can use the DEXHelper class to quickly get access to class name, method name, field name, but also code item for each method for disassembling:

from dexparser import DEXHelper
dh = DEXHelper.from_rawdex(d)

for method in dh.get_methods():
        print("METHOD", method, method.get_internal_struct())
        code = method.get_code()
        if code:
            print(
                "\t CODE",
                code["debug_info_off"],
                code["insns_size"],
                len(code["insns"].value),
            )
            my_func_to_disassemble(code["insns"].value)

License

Distributed under the Apache License, Version 2.0.

Metadata

Release files for dexparser-ag 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dexparser-ag 0.0.1
File Size Uploaded Provenance
dexparser_ag-0.0.1.tar.gz 1.8 MB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for dexparser-ag 0.0.1
File Interpreter ABI Platform
dexparser_ag-0.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 1.9 MB

Release files / dexparser_ag-0.0.1.tar.gz

Download URL dexparser_ag-0.0.1.tar.gz
Size 1.8 MB
Tags Source
SHA-256 checksum
How to use checksums
5db76b573e34c035fc3f66308c558dd3f06d6d2ad8aaf64980e15a522daf7b0e
BLAKE2b-256 checksum
How to use checksums
40df5cc57a0280f3d7dcb706571bdb4f6cc7af853dbc0de9d2d9b9b2a2a4dd6c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.3

Release files / dexparser_ag-0.0.1-py3-none-any.whl

Download URL dexparser_ag-0.0.1-py3-none-any.whl
Size 24.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f486a51133e718253d4b8e8d60c6f35b5dc62071ee849cbbbfdb45136abe15e9
BLAKE2b-256 checksum
How to use checksums
515b26d3e7718f8555f21c63b517ca77b1a518068d62311063a2fe8a2ec8f4d8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.3

Security for dexparser-ag 0.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page