
新发布Sep 11, 2026
apk-info v1.0.13
APK全功能解析器
用于 Android apk/xapk/apkm/apks 文件的快速、抗恶意软件解析器。
文档:https://delvinru.github.io/apk-info/
$ apk-info show apkstest.apk
apkstest.apk
Package io.github.delvinru.apkstest
Label APKS Test
Version 1.0.7 (7)
SDK min 21 · target 35
Main activity io.github.delvinru.apkstest/.MainActivity
ABIs x86_64
功能特性
- 一个对恶意软件友好的 zip 读取器,能够像 Android 一样读取归档文件,包括
BadPack技术(关于它的优秀文章)以及 ZIP64; - XAPK、APKM 和 APKS 容器,通过其基础 APK 打开;
- 完整的 AXML(Android 二进制 XML)和 ARSC(Android 资源)实现,能够稳健应对垃圾数据块;
- 支持提取
APK Signing Block中包含的信息:- APK 签名方案 v1;
- APK 签名方案 v2;
- APK 签名方案 v3;
- APK 签名方案 v3.1;
- APK 签名方案 v3.2;
- Stamp Block v1 和 v2;
- 渠道块:Walle、VasDolly v2、Packer NG v2、ByteDance;
- Google Play Frosting(仅检测存在性,其结构未公开);
- 基于 Android 操作系统的实现方式正确提取 MainActivity;
- 面向 Python 3.11+ 的绑定,带类型标注——不再需要
# type: ignore;解析过程会释放 GIL,因此线程可以并行运行; - 当然,它只是一个快速的解析器——🙃
快速开始
cli
安装
使用 Homebrew:
brew install delvinru/tap/apk-info
或使用 cargo:
cargo install apk-info-cli
帮助
A command-line tool to inspect and extract APK files
Usage: apk-info [COMMAND]
Commands:
show Show basic information about the APK file
extract Unpack apk files as zip archive [alias: x]
axml Read and pretty-print binary AndroidManifest.xml
repack Repack a BadPack-damaged APK into a clean, well-formed zip archive
completion Generate shell completion
help Print this message or the help of the given subcommand(s)
Options:
-h, --help Print help
-V, --version Print version
Python
安装
uv pip install apk-info
获取 APK 的基本信息
from apk_info import APK
apk = APK("./path-to-file.apk")
package_name = apk.get_package_name()
main_activities = apk.get_main_activities()
min_sdk = apk.get_min_sdk_version()
print(f"Package Name: {package_name}")
print(f"Minimal SDK: {min_sdk}")
if not main_activities:
print("apk is not launchable!")
exit()
print(f"Main Activity: {package_name}/{main_activities[0]}")
获取签名信息
import sys
from apk_info import APK, Signature
if len(sys.argv) < 2:
print(f"usage: {sys.argv[0]} <apk>")
sys.exit(1)
file = sys.argv[1]
apk = APK(file)
signatures = apk.get_signatures()
for signature in signatures:
match signature:
case Signature.V1() | Signature.V2() | Signature.V3() | Signature.V31() | Signature.V32():
for cert in signature.certificates:
print(f"{cert.subject=} {cert.issuer=} {cert.valid_from=} {cert.valid_until=}")
case Signature.ApkChannelBlock() | Signature.VasDollyV2() | Signature.ByteDance():
print(f"got channel block: {signature.value}")
case _:
print(f"oh, cool, library added some new feature - {signature}")
# For `xapk`/`apkm`/`apks` containers, `get_container_signatures()` returns the
# distributor's signature on the outer archive, separate from the app.
container_signatures = apk.get_container_signatures()
性能分析
单线程、冷页缓存,每个工具从 Python 读取相同的元数据。Apple M3 Pro,macOS 26.6.1。
干净应用:来自应用商店的 5,714 个 APK 和 XAPK 文件,429 GB。
| 时间 | 文件/秒 | 峰值内存 | 失败 | |
|---|---|---|---|---|
| apk-info 1.1.0 | 29.7 s | 192 | 745 MB | 0 |
| apk-info 1.0.13 | 71.4 s | 80 | 770 MB | 0 |
| androguard 4.1.4 | 926.3 s | 6 | 5.8 GB | 784 |
恶意软件:来自 VirusShare Android 集合 的 23,745 个文件,106 GB。
| 时间 | 文件/秒 | 峰值内存 | 失败 | |
|---|---|---|---|---|
| apk-info 1.1.0 | 44.7 s | 531 | 88 MB | 692 |
| apk-info 1.0.13 | 76.0 s | 312 | 87 MB | 691 |
| androguard 4.1.4 | 362.6 s | 65 | 794 MB | 737 |
方法论、逐文件计时和失败原因:基准测试。
常见问题
- 为什么不直接使用 androguard?
我的几乎所有项目都源于某些使用起来不方便的东西。 Androguard 本身是一个很棒的工具,但在我看来它根本无法维护,也不适合用于生产就绪的代码。它也不适合分析大量文件,因为它的逻辑没有经过良好优化。
- 我想修改一个 APK。如何使用这个库来实现?
该库在设计上是只读的:我需要一个能轻松快速地从 APK 中提取信息的好工具。还有许多其他用于修改 APK 的优秀工具。
- 我重新打包了一个 APK。如何对它进行签名?
repack 命令会生成一个未签名的 APK。要重新签名,我推荐 uber-apk-signer,这是一个简单的单命令工具,可在一次操作中完成 v1/v2/v3 签名和 zipalign:
java -jar uber-apk-signer.jar --apks ./malware.repacked.apk