Androguard

4.1.3 · active · verified Sat Apr 11

Androguard is a comprehensive Python toolkit for reverse engineering and analyzing Android applications. It supports various Android file formats like DEX, ODEX, APK, Android's binary XML, and resources. The library offers capabilities for disassembly, basic decompilation, static and dynamic analysis, and Frida integration. The project is actively maintained, with version 4.1.3 released on February 24, 2025, representing a significant evolution from the 3.x series.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to load and perform basic static analysis on an APK file using `AnalyzeAPK`. It retrieves the package name, main activity, permissions, and counts of DEX files and classes. Replace 'path/to/your/app.apk' or set the `ANDROGUARD_SAMPLE_APK` environment variable to a valid APK path for execution.

from androguard.misc import AnalyzeAPK
import os

# NOTE: Replace 'path/to/your/app.apk' with an actual APK file path.
# For a runnable example, you'd need a sample APK.
apk_file_path = os.environ.get('ANDROGUARD_SAMPLE_APK', 'path/to/your/app.apk')

try:
    # Analyze the APK file
    a, d, dx = AnalyzeAPK(apk_file_path)

    print(f"Package Name: {a.get_package()}")
    print(f"Main Activity: {a.get_main_activity()}")
    print("Permissions:")
    for perm in a.get_permissions():
        print(f"  - {perm}")

    print(f"Number of DEX files: {len(d)}")
    print(f"Total classes analyzed: {len(dx.get_classes())}")

except Exception as e:
    print(f"Error analyzing APK: {e}")
    print("Please ensure 'ANDROGUARD_SAMPLE_APK' environment variable points to a valid APK, or replace 'path/to/your/app.apk' with a real path.")

view raw JSON →