
APK 완전 기능 파서
풀 기능을 갖춘 apk 파서입니다.
BadPack 기술에 관한 훌륭한 문서;APK Signature Block 42에 포함된 정보 추출 지원:
# type: ignore 필요 없음;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 apk file
extract Unpack apk files as zip archive [aliases: x]
axml Read and pretty-print binary AndroidManifest.xml
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
uv pip install apk-info
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():
for cert in signature.certificates:
print(f"{cert.subject=} {cert.issuer=} {cert.valid_from=} {cert.valid_until=}")
case Signature.ApkChannelBlock():
print(f"got apk channel block: {signature.value}")
case _:
print(f"oh, cool, library added some new feature - {signature}")
환경:
스크립트 script:
apk-info 라이브러리:
release-lto;테스트 케이스 (클린 컬렉션):
| # | apk-info | androguard |
|---|---|---|
| 1 |
테스트 케이스 (멀웨어 컬렉션):
[!IMPORTANT] 이 세트에는 androguard가 파싱할 수 없는 많은 악성 샘플이 포함되어 있습니다.
| # | apk-info | androguard |
|---|---|---|
| 1 |
평균적으로 속도 향상은 약 10배입니다.
주요 장점은 apk-info가 androguard보다 더 많은 악성 파일을 파싱할 수 있다는 것입니다.
제 프로젝트의 대부분은 사용하기 불편한 것에서 탄생했습니다. Androguard는 그 자체로 훌륭한 도구이지만 (제 생각에는) 유지 관리가 불가능하고 프로덕션 준비 코드에는 적합하지 않습니다. 또한 모든 로직이 최적화되지 않은 방식으로 작성되어 있어 많은 수의 파일을 분석하는 데 적합하지 않습니다.
이 라이브러리는 읽기 전용 모드로만 설계되었습니다. apk에서 정보를 쉽고 빠르게 추출할 수 있는 좋은 도구가 필요했기 때문입니다. 다른 좋은 도구들이 많이 있습니다.
| 0.98s user 4.32s system 80% cpu 6.584 total |
| 57.39s user 4.88s system 97% cpu 1:03.85 total |
| 2 | 0.96s user 4.23s system 79% cpu 6.486 total | 57.98s user 5.04s system 97% cpu 1:04.80 total |
| 3 | 0.95s user 4.15s system 79% cpu 6.422 total | 55.56s user 4.48s system 97% cpu 1:01.55 total |
| 2.49s user 4.74s system 73% cpu 9.840 total |
| 141.29s user 6.86s system 98% cpu 2:31.09 total |
| 2 | 2.50s user 4.77s system 75% cpu 9.641 total | 138.04s user 6.32s system 97% cpu 2:27.33 total |
| 3 | 2.49s user 4.78s system 75% cpu 9.650 total | 139.33s user 6.65s system 98% cpu 2:28.87 total |