Skip to main content

Native, zero-Java APK toolkit: AXML/arsc parsing, DEX disassemble/assemble/whole-DEX rewrite, native zipalign and v2/v3 APK signing.

Project description

REapk

A native, zero-Java APK toolkit. REapk parses and rewrites Android's binary formats directly in Python, with no third-party tools and no JVM. It handles recon, manifest and DEX edits, repackaging, zipalign, and v2/v3 signing.

pip install reapk

Documentation: jrbusiness.github.io/REapk

Pipeline

REapk pipeline: ingest an APK/XAPK, branch on the requested operation into a read-only recon lane or a rewrite lane, then zipalign and v2/v3 sign.

The DEX engine

REapk includes a complete smali ↔ DEX assembler: a disassembler, a single-method assembler, a constant-pool rebuilder, and a whole-DEX writer.

The writer preserves debug_info and annotations, relocates oversized method bodies, and interns brand-new strings / types / fields / methods with full index remapping. It is round-trip verified against tens of thousands of real production methods and cross-checked against Android's own dexdump.

classes*.dex is editable and recompilable: disassemble it, edit or replace method bodies, inject new methods, reassemble to valid DEX, repackage, and sign.

For resources, REapk reads resources.arsc to resolve references (turning @string/… / @xml/… in the manifest into real values and resolving deeplink schemes) and edits the binary AndroidManifest.xml directly: debuggable, permissions, cleartext, and so on. A full res/ source tree and arbitrary resources.arsc re-encoding are out of scope for the native engine; the optional decode / build commands hand that off to an external tool when one is installed.

Playground

Learn the DEX engine hands-on with a runnable Jupyter notebook. Point it at your own APK with the REAPK_TEST_APK environment variable:

pip install -e .[playground]
REAPK_TEST_APK=/path/to/app.apk jupyter lab examples/notebooks/playground.ipynb

It loads an APK, reads its manifest, disassembles a method to smali, hex-dumps raw DEX bytes, and renders a full smali listing with dump_dex. See examples/notebooks/ for details.

Library use

import reapk

# High-level facade
apk = reapk.Apk.open("app.apk")
print(apk.manifest.package, len(apk.manifest.exported_components))

apk.manifest.set_debuggable().set_cleartext()
apk.manifest.add_permission("android.permission.INTERNET")
apk.save("patched.apk")            # repackage (zipalign) + v2/v3 sign

# Disassemble a method across every dex
smali = apk.disassemble("Lp/C;->m()V")

Lower-level procedural functions (parse_axml, DexFile, disassemble, assemble, build_dex, apk_sign_v2, scan_secrets, …) are exported from the top-level package for direct use.

CLI

reapk analyze | js | dex | dexdis | dexasm | dexpool | dexwrite |
       dexpatch | dexreplace | patch | sign | decode | build

A bare path with no subcommand defaults to analyze. Every command is fully native except decode / build, which call an external tool when one is present.

Development

git clone https://github.com/JRBusiness/reapk && cd reapk
pip install -e .[test]
pytest -q                 # unit + signer tests (integration skipped w/o an APK)
ruff check .              # lint

# run the full integration round-trip oracles against a real APK:
REAPK_TEST_APK=/path/to/app.apk pytest -q

# benchmark against external tooling:
python scripts/bench_apk.py /path/to/app.apk --runs 1

License

MIT. See LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

reapk-0.1.1.tar.gz (46.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

reapk-0.1.1-py3-none-any.whl (47.1 kB view details)

Uploaded Python 3

File details

Details for the file reapk-0.1.1.tar.gz.

File metadata

  • Download URL: reapk-0.1.1.tar.gz
  • Upload date:
  • Size: 46.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for reapk-0.1.1.tar.gz
Algorithm Hash digest
SHA256 e26a6f0055c3553a26a692f6d5dcd0f42c614ea4052df33146e7eec0da2d37c4
MD5 be3dad1148bb7d897b745910ccad295f
BLAKE2b-256 4945b449b99bfde570b103aa806dbb585b05bb7d57918730d630332d89471121

See more details on using hashes here.

Provenance

The following attestation bundles were made for reapk-0.1.1.tar.gz:

Publisher: publish.yml on JRBusiness/REapk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file reapk-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: reapk-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 47.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for reapk-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2496240a6b88cfd90df93325eda9ac0015480a14362cd2546cdf0b76a0f5f3ec
MD5 40aa386604903831000b5b4235f7f3e6
BLAKE2b-256 8339f2a5c18d645e1e0a8290e7378446857b5e5b265e5d301754a4f00a647ccc

See more details on using hashes here.

Provenance

The following attestation bundles were made for reapk-0.1.1-py3-none-any.whl:

Publisher: publish.yml on JRBusiness/REapk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page