Manipulate AXML file and create one from scratch
Project description
README
GENERAL INFO
Project: Library to parse and modify AXML files (Rust implementation) Author: Benoît Forgette alias MadSquirrel License: GNU General Public License v3.0 and later
GOAL
pyaxml-rs is a full Rust rewrite of PyAxml to parse and write AXML (Android XML) binary files. It exposes the same functionality as the original Python library through three interfaces:
- A native Rust library crate (
pyaxml_rs) for use in Rust projects. - A Python package (
pyaxml) built with maturin and PyO3, providing the same API as the originalpyaxmlPython package. - Two CLI entry-points with identical commands:
pyaxml-rs: native Rust binary, no Python required.
Runtime dependencies (minimal by design):
quick-xml: XML parsing for thexml2axmldirectionzip: APK/ZIP file support in the CLIpyo3: (optional, only when building the Python extension)
PyAxml is a Rust tool with python wrapper to play with AXML (Android XML) files. This tool is useful to decode and encode AXML files and manipulate AXML files over a Protocol Buffers object. It is designed to work with Python 3 only. Some examples of the use of the tool is provided with the project:
- copymanifest.py that allow to decode and reencode the original file
- replace_activity_name.py to change the name an activity and replace by an other
If you want to see more example you can dig more on the project apkpatcher that use this library to add some useful permission and inject a library inside the target application.
BUILD & INSTALL
Prerequisites
- Rust toolchain (
rustup): https://rustup.rs/ - Python 3.8+ with a virtual environment (for the Python extension)
Build the Python extension
python3 -m venv .venv
source .venv/bin/activate
pip install maturin
maturin develop # debug build (fast)
maturin develop --release # release build
This installs both the pyaxml Python package and the pyaxml-rs CLI entry-point.
Build the Rust CLI binary
cargo build --release
# Binary at: target/release/pyaxml-rs
Install the Rust CLI system-wide
cargo install --path .
Or use the Makefile:
make build # compile release binary
make install # cargo install
CLI USAGE
pyaxml-rs [-h] [-i INPUT] [-o OUTPUT] [-p PATH] [-v]
[--stringblocks-file STRINGBLOCKS_FILE]
{axml2xml,xml2axml,arsc2xml,axml2proto}
Commands
| Command | Description |
|---|---|
axml2xml |
Decode a binary AXML file (or AndroidManifest.xml from an APK) to plain XML |
xml2axml |
Encode a plain XML file back to binary AXML |
arsc2xml |
Parse a resources.arsc file to XML grouped by locale |
arsc2proto |
Decode a resources.arsc file to protobuf text format |
axml2proto |
Decode a binary AXML file to protobuf text format |
Options
| Flag | Description |
|---|---|
-i FILE / --input FILE |
Input file (AXML, XML, or APK/ZIP) |
-o FILE / --output FILE |
Output file (default: stdout) |
-p PATH / --path PATH |
Path of a specific file inside a ZIP/APK |
-v / --version |
Print version |
--stringblocks-file FILE |
Export or import the string pool as JSON (axml2xml / xml2axml) |
--pretty |
Pretty-print protobuf output (arsc2proto / axml2proto) |
Examples
# Decode AndroidManifest.xml from a binary AXML file
pyaxml-rs axml2xml -i AndroidManifest.xml
# Decode from an APK
pyaxml-rs axml2xml -i app.apk -o manifest.xml
# Decode a specific file from an APK
pyaxml-rs axml2xml -i app.apk -p res/xml/network_security_config.xml
# Encode XML back to binary AXML
pyaxml-rs xml2axml -i manifest.xml -o AndroidManifest.xml
# Dump the intermediate protobuf text representation
pyaxml-rs axml2proto -i AndroidManifest.xml
# Export string pool alongside the XML
pyaxml-rs axml2xml -i AndroidManifest.xml --stringblocks-file strings.json
# Re-encode using a previously exported string pool
pyaxml-rs xml2axml -i manifest.xml -o out.axml --stringblocks-file strings.json
# Same commands work with the Python CLI
pyaxml axml2xml -i AndroidManifest.xml
PYTHON API
import pyaxml
# Parse binary AXML
with open("AndroidManifest.xml", "rb") as f:
data = f.read()
axml = pyaxml.AXML.from_axml(data)
# Convert to an XML Element (lxml or stdlib ET)
element = axml.to_xml()
# Re-pack to binary
binary = axml.pack()
# Build from XML
axml2 = pyaxml.AXML()
axml2.from_xml(element)
binary2 = axml2.pack()
# String pool access
print(axml.string_count())
print(axml.get_string(0))
# Parse binary ARSC
arsc = pyaxml.ARSC.from_axml(data)
xml_str = arsc.list_packages()
# Auto-detect AXML vs ARSC
obj = pyaxml.AXMLGuess.from_axml(data)
TESTS
# Rust integration tests
cargo test
# Python tests (requires maturin develop first)
python3 -m pytest tests-py/ -v
Or use the Makefile:
make test # both Rust and Python tests
make test-rs # Rust only
make test-py # Python only
MAKEFILE TARGETS
| Target | Description |
|---|---|
make build |
Compile the release binary (pyaxml-rs) |
make develop |
Build and install the Python extension (maturin develop) |
make lint |
Run all linters (Rust + Python) |
make test |
Run all tests (Rust + Python) |
make test-rs |
Run Rust integration tests only |
make test-py |
Run Python tests only |
make install |
Install pyaxml-rs binary via cargo install |
make bump VERSION=x.y.z |
Bump the version in Cargo.toml |
make clean |
Remove build artefacts |
make help |
Show available targets |
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyaxml-0.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: pyaxml-0.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 1.1 MB
- Tags: CPython 3.12, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9be04494e8b05d45f81d7d8a60ca0b40b8ef9e053effec9e68a4cd59124734da
|
|
| MD5 |
0d7d7386494023da2ab6e970ce3b69d0
|
|
| BLAKE2b-256 |
6b5b1bbc2ab7519607e508ae061b54f44aa1744dce079ed92876ca8680b7711f
|
File details
Details for the file pyaxml-0.1.0-cp312-cp312-manylinux_2_17_armv7l.manylinux2014_armv7l.whl.
File metadata
- Download URL: pyaxml-0.1.0-cp312-cp312-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
- Upload date:
- Size: 968.3 kB
- Tags: CPython 3.12, manylinux: glibc 2.17+ ARMv7l
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8033871956b7390d30d38c703f57182eb42480f8d6563d9685043da2d3b0ca80
|
|
| MD5 |
9790f00999ce1297004ba989be529d76
|
|
| BLAKE2b-256 |
8dcd3d78363442e39032725d38dce98e225bb0c1616f77d9747a27ae8918b2e8
|
File details
Details for the file pyaxml-0.1.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: pyaxml-0.1.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 970.3 kB
- Tags: CPython 3.12, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2162307477d132cb01a2d342b6edba787d0cd98712b7b7da51990ce19da55671
|
|
| MD5 |
7908d18edb499e6029d2c6779a3e571e
|
|
| BLAKE2b-256 |
8055a02f1f9b0359c379b05426deadb2411d7be9994177eabb69248fa9afed65
|
File details
Details for the file pyaxml-0.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: pyaxml-0.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 1.1 MB
- Tags: CPython 3.11, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ce6cf91e44ffd0756ee8515d5257388b20b91c8f35f936d93aa6a256f21c13f9
|
|
| MD5 |
2c5fb49e7fe12eebcf38c4e323fbd04e
|
|
| BLAKE2b-256 |
2817b34a6d583ef78294ceca2bebe90d5baba1761494adb3c4ffe20e46051bdb
|
File details
Details for the file pyaxml-0.1.0-cp311-cp311-manylinux_2_17_armv7l.manylinux2014_armv7l.whl.
File metadata
- Download URL: pyaxml-0.1.0-cp311-cp311-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
- Upload date:
- Size: 969.1 kB
- Tags: CPython 3.11, manylinux: glibc 2.17+ ARMv7l
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f9a66345519b2bac64aee7869b0a4c8b841fa8704bbc49a32c22b9cffdb337aa
|
|
| MD5 |
3972b207e3d29c62868fdc419d847afa
|
|
| BLAKE2b-256 |
1f31ea827679316cf4a5bfa5ed913e548356648118d70d58eeebad605dfab23c
|
File details
Details for the file pyaxml-0.1.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: pyaxml-0.1.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 970.6 kB
- Tags: CPython 3.11, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f6330b3da6cd04cd17de1f9c404d83933d3e586e9faa4298c570c27eca75415f
|
|
| MD5 |
02f95667319d3a77d43deee5bb7c63a9
|
|
| BLAKE2b-256 |
c50f45fb63e8e4a2463e4f1aa99770ccefcee4bbbb6544cd7ac6c78cc4a21816
|
File details
Details for the file pyaxml-0.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: pyaxml-0.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 1.1 MB
- Tags: CPython 3.10, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cd4187e04c34f1e9370ee746ccaa39492050303e46dd9e2c152d5e73e04aa4ed
|
|
| MD5 |
f1562ded168c6c354cd345f76f3b269a
|
|
| BLAKE2b-256 |
d3102e1272803fa7f2122f48703f49cd42307cddd889ef87f0c7a2d7b56512e8
|
File details
Details for the file pyaxml-0.1.0-cp310-cp310-manylinux_2_17_armv7l.manylinux2014_armv7l.whl.
File metadata
- Download URL: pyaxml-0.1.0-cp310-cp310-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
- Upload date:
- Size: 969.4 kB
- Tags: CPython 3.10, manylinux: glibc 2.17+ ARMv7l
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cd7c84c6b39d1eb991d791bb8b3cfbd14315bf863a9eccadf7aa0303faef3cf3
|
|
| MD5 |
3f540b9966ea93bf429c31e146d58ec3
|
|
| BLAKE2b-256 |
a5cea746bf126c2c499fcabee8264c331b26f327e86d09ffca937cd2cbc8468c
|
File details
Details for the file pyaxml-0.1.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: pyaxml-0.1.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 970.6 kB
- Tags: CPython 3.10, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bcacbc39e1643c392afff8a1b9a0ecbd1e1983b9f9fc9f1edf9e92bf191d5ce5
|
|
| MD5 |
72262724b33585bdf36ec556f79feb2d
|
|
| BLAKE2b-256 |
8363aa654fdff3ea6cf51064a462172355faf8a099871f8c902865e1931db090
|
File details
Details for the file pyaxml-0.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: pyaxml-0.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 1.1 MB
- Tags: CPython 3.9, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ff6a79129ba65bb7a4a5d98b11505c9b69e1777f206fa3d8a990b7626f2fb435
|
|
| MD5 |
6504440566ff72cfd96f61038a72eb23
|
|
| BLAKE2b-256 |
f7d30458273849deeeab07c57a6c475f6923d7950d0aab291251376caea158cc
|
File details
Details for the file pyaxml-0.1.0-cp39-cp39-manylinux_2_17_armv7l.manylinux2014_armv7l.whl.
File metadata
- Download URL: pyaxml-0.1.0-cp39-cp39-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
- Upload date:
- Size: 969.9 kB
- Tags: CPython 3.9, manylinux: glibc 2.17+ ARMv7l
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3f19e9f7090a42e8af2a56388c0c4874ba724b429a06c7a2b5053f2fd5ea10af
|
|
| MD5 |
87dcf033abcaf690d0ea47c1ce8a96d8
|
|
| BLAKE2b-256 |
c72a35915c48a8c33d3b336be1af98228a7d968d89f45bb1cc99f8c112ef8244
|
File details
Details for the file pyaxml-0.1.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: pyaxml-0.1.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 971.1 kB
- Tags: CPython 3.9, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
45d36eb680eeb8d26313bb230bb595a42ce506ddece1986e9cb4b7dec6b23ad3
|
|
| MD5 |
01099ad6febaa957ad5a504f9a1af3f0
|
|
| BLAKE2b-256 |
17254ff5afb7fb21ce3a791510665e124ecf47daa99dc0b63accf452dd3feadd
|
File details
Details for the file pyaxml-0.1.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: pyaxml-0.1.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 1.1 MB
- Tags: CPython 3.8, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a172668abc269c98ffa684adb2f76c342cdd909468af502d14eaa947af35a499
|
|
| MD5 |
78101792e178547a892d579eede10baf
|
|
| BLAKE2b-256 |
acd55e7836caf529b68693ae19270b465f67d79a349e4c85a7cb224f84d95390
|
File details
Details for the file pyaxml-0.1.0-cp38-cp38-manylinux_2_17_armv7l.manylinux2014_armv7l.whl.
File metadata
- Download URL: pyaxml-0.1.0-cp38-cp38-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
- Upload date:
- Size: 969.7 kB
- Tags: CPython 3.8, manylinux: glibc 2.17+ ARMv7l
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
466f85fe56839ed5d470627a4747854e3dd15096704208d1719d0acfca0b8aa7
|
|
| MD5 |
41735a3c578c279e53f2e98313ca6845
|
|
| BLAKE2b-256 |
1516ee7b4964e1598bb485ca4acdc121cde5950e2bd1aa7fb57bd57710bfe7e2
|
File details
Details for the file pyaxml-0.1.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: pyaxml-0.1.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 971.1 kB
- Tags: CPython 3.8, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b8c29c84d920fd5510dc71b3707d0d47732ded272684fb9069b38d6badbf7719
|
|
| MD5 |
52b71721382c69951e274623abf77f1e
|
|
| BLAKE2b-256 |
eb5a363b59307da5707426a747ec56d8f69f76e05a99899f815cb13d88a06e7e
|
File details
Details for the file pyaxml-0.1.0-cp38-abi3-win_amd64.whl.
File metadata
- Download URL: pyaxml-0.1.0-cp38-abi3-win_amd64.whl
- Upload date:
- Size: 944.3 kB
- Tags: CPython 3.8+, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aacfd5a7a4074da81f7f045a85498b77ac4a4b0395c287f7a6d9ce8685a12939
|
|
| MD5 |
c84a3252cdaefc632aae6d1c221f01bd
|
|
| BLAKE2b-256 |
c04e53e4e0594e5114d469e84009dabd9b6908ec3d62fc44aeb6712a9bb85aea
|
File details
Details for the file pyaxml-0.1.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: pyaxml-0.1.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 1.1 MB
- Tags: CPython 3.8+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5608d9fc4cb8aedbd2f334baf4feabc8eb2e11b368bbd4c78cea74c2aa8ac269
|
|
| MD5 |
d5ef1396b4a6594dc1982d98cff4b066
|
|
| BLAKE2b-256 |
bab59f94853cbf248ca2c7343104fb3b1225ffaaf6d9c3b57a4d094fd5f91db2
|