Metadata-Version: 2.4
Name: dexpp
Version: 0.3.1
Summary: Fast static analysis of Android APK / DEX files (C++ core with Python bindings)
Keywords: android,dex,apk,static-analysis,reverse-engineering
Author: Mohamed Nasser
License-Expression: Apache-2.0
License-File: LICENSE
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Operating System :: MacOS
Classifier: Operating System :: Microsoft :: Windows
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: C++
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Topic :: Security
Classifier: Topic :: Software Development :: Disassemblers
Classifier: Typing :: Typed
Project-URL: Homepage, https://github.com/burogurama/dexpp
Project-URL: Documentation, https://burogurama.github.io/dexpp/
Project-URL: Issues, https://github.com/burogurama/dexpp/issues
Project-URL: Changelog, https://github.com/burogurama/dexpp/blob/main/CHANGELOG.md
Requires-Python: >=3.10
Description-Content-Type: text/markdown

# dex++

Fast static analysis of Android APK / DEX files — a C++23 core with Python, C,
Go and Java bindings.

The current release is **0.3.1** (alpha): the API may still change between
0.x releases. See [CHANGELOG.md](https://github.com/burogurama/dexpp/blob/main/CHANGELOG.md).

**Documentation: <https://burogurama.github.io/dexpp/>** — guides with
examples in Python, Go and Java, the Python reference, and the C++ and C
reference, for the latest release.

## What it does

- **APK metadata** — manifest (package, SDK levels, permissions, components and
  their exported/intent-filter/permission attributes), resource resolution
  (`@string/...`), and signing-scheme/certificate inspection (v1/v2/v3).
- **DEX analysis** — classes, methods, fields; decoded bytecode with mnemonics;
  per-method control-flow graphs and try/catch; annotations and static-field
  initial values.
- **Whole-program** — call graph (with class-hierarchy-aware virtual dispatch),
  class hierarchy, and a cross-reference index (who calls / reads / writes /
  loads what), both forward and reverse.
- **DEX editing** — read a DEX file into an editable model, change it or
  build one from scratch, and write a valid DEX file (`dex::model`). From
  Python (`dexpp.Model`), Go and Java, the model works a whole class at a
  time: copy, move, remove and rename classes, then write.

It inspects APK and DEX files and edits DEX files. It does not decompile or
verify signatures.

## Install (Python)

dexpp needs Python 3.10 or newer.

```bash
pip install dexpp
```

PyPI has prebuilt wheels for CPython 3.10, 3.11, 3.12, 3.13 and 3.14 on Linux
x86_64 (glibc 2.28+ and musl), macOS 14 or newer (Apple Silicon and Intel) and
Windows x64. The same wheels are attached to each
[GitHub release](https://github.com/burogurama/dexpp/releases).

On other platforms and Python versions, pip builds dexpp from the source
distribution. That needs
a C++23 compiler (GCC ≥ 13, Clang ≥ 19, Apple Clang from Xcode 16 or MSVC from
Visual Studio 2022) and CMake ≥ 3.18. `pip install .` builds a checkout the
same way.

The package ships type stubs, so editors and `mypy`/`pyright` get full
completion.

```python
import dexpp

apk = dexpp.Apk.open("app.apk")
print(apk.manifest.package, apk.manifest.permissions)
print("signed:", apk.signing.is_signed, [c.sha256_hex for c in apk.signing.certificates])

ctx = apk.analysis()                      # cross into the code
for target, sites in ctx.xrefs.method_refs_by_name("loadUrl"):
    print(target.class_descriptor, len(sites), "call sites")
```

## Build & test (C++)

```bash
cmake -S . -B build
cmake --build build -j
ctest --test-dir build --output-on-failure   # run from the project root

./build/main_test tests/data/classes.dex     # demo disassembler
```

The Python module can also be built in-tree for development:

```bash
cmake -S . -B build -DDEXPP_BUILD_PYTHON=ON
cmake --build build -j
PYTHONPATH=build python3 bindings/python/test_dexpp.py
```

## Using it from C++, Go or Java

The C++ library and the C / Go / Java bindings are source-only for now: there
are no install rules or prebuilt binaries.

- **C++**: add the checkout to your build with `add_subdirectory(dexpp)`, link
  the `dexpp_core` target, and include `dex.hpp`. `DEXPP_VERSION` gives the
  library version.

Editing a DEX file in C++, for example splitting it into one file per class:

```cpp
#include "dex.hpp"

auto input = dex::model::read_file("classes.dex").value();
for (std::size_t i = 0; i < input.classes.size(); ++i) {
    dex::model::Dex one{input.version, {input.classes[i]}};
    if (auto ok = dex::model::write_file(one, "class" + std::to_string(i) + ".dex"); !ok)
        std::cerr << ok.error().message << '\n';
}
```

`write()` builds the file's pools from the references the model holds, so a
class can move to another file as it is. See `src/model/io.hpp` for reading,
writing, `validate()` and `rename_types()`, and `src/model/types.hpp` for the
model itself.
- **Go**: see [bindings/go/README.md](https://github.com/burogurama/dexpp/blob/main/bindings/go/README.md). The cgo package
  reaches the same API as Python: the whole analysis API, the APK metadata,
  and the editable model a whole class at a time. It links the C shim from
  this repository's `build/` directory, so it works from a checkout, not
  through `go get`. It supports Linux and macOS, not Windows.
- **Java**: see [bindings/java/README.md](https://github.com/burogurama/dexpp/blob/main/bindings/java/README.md).
  The package `io.github.burogurama.dexpp`
  (`bindings/java`, built with Maven) reaches the same API as Go. It needs
  Java 22 or newer: it calls the C API through the Foreign Function & Memory
  API, from the shared library that the CMake option
  `-DDEXPP_BUILD_C_SHARED=ON` adds (`dexpp_c_shared`). It works on Linux,
  macOS and Windows, from a checkout; it is not on Maven Central yet.

  ```bash
  cmake -S . -B build -DDEXPP_BUILD_C_SHARED=ON
  cmake --build build --target dexpp_c_shared --config Release -j
  cd bindings/java && mvn verify     # builds the jar and runs the tests
  ```

The library, its tests and the Python module are built and tested on Linux,
macOS (Apple Silicon and Intel) and Windows x64.

## Layout

- `src/raw/` — `dex::raw`: stateless DEX format parser + a minimal ZIP reader,
  and the format-level pieces a writer needs (opcode table, MUTF-8, digests).
- `src/common/` — vocabulary types shared by the layers (`MethodId`, `FieldId`,
  `AccessFlags`).
- `src/analysis/` — `dex`: the handle-based analysis API (the code surface).
- `src/model/` — `dex::model`: the editable DEX model (read, validate, write,
  rename).
- `src/apk/` — `dex::apk`: package metadata (manifest, resources, signing).
- `src/dex.hpp` — the single public umbrella header.
- `bindings/python/` — the pybind11 module, stubs, and Python tests.
- `bindings/c/`, `bindings/go/` — the C ABI shim and the Go package over it.
- `bindings/java/` — the Java package over the same C ABI (FFM, Java 22+),
  with its Maven build and tests.
- `docs/` — the sources of the documentation site (see `docs/README.md`).
