baksmali
Disassemble DEX to Smali code
SYNOPSIS
baksmali [options] <dex-or-apk-file-or-directory>
PARAMETERS
-o, --output <DIR>
Output directory for smali files (default: out).
-p, --bootclasspath <PATHS>
Colon-separated bootclasspath for type resolution.
--api-level <N>
Android API level (default: detects or 17).
-x, --no-debug-info
Omit debug info (.local, .line, etc.).
-f, --force-debug-info
Include debug info even if absent in DEX.
--debug
Print stack traces on errors.
-l, --use-locals
Emit .locals directive (default).
--no-use-locals
Omit .locals directive.
-r, --register-info
Annotate registers with types (default).
--no-register-info
Omit register type annotations.
--ignore-errors
Continue processing despite errors.
-m, --multi
Allow multiple input files/directories.
--bookmark
Experimental: bookmark registers across blocks.
-V, --version
Print version and exit.
-h, --help
Print usage summary.
DESCRIPTION
Baksmali is a disassembler for Android's DEX (Dalvik Executable) files, converting compact bytecode into human-readable smali assembly language. Smali syntax resembles Jasmin for Java, with directives like .class, .super, .method, and Dalvik opcodes. This tool is crucial for Android reverse engineering, modding APKs, debugging obfuscated apps, and malware analysis.
Input can be DEX files, APKs (extracts DEX), or directories. Output mirrors Java package structure, e.g., com/example/Main.smali. It handles multiple files, resolves types via bootclasspath, and supports API-specific features. Debug info (.line, .local) can be included/excluded for cleaner or detailed output.
Java-based, baksmali runs cross-platform on Linux via JVM. Commonly paired with smali (assembler), apktool (APK toolkit), or deodexers. Challenges include obfuscation resistance and large APKs, but options like --ignore-errors aid robustness.
CAVEATS
Requires Java (java -jar baksmali.jar); not native binary. May struggle with ProGuard-obfuscated or encrypted DEX. APK input auto-extracts classes.dex; multidex needs --multi.
INVOCATION
Typically: java -jar baksmali-<version>.jar [options] (symlink as 'baksmali' common).
EXAMPLE
baksmali -o out/ classes.dex
Creates out/com/example/Main.smali.
baksmali -x --api-level 30 app.apk
SOURCE
GitHub: github.com/JesusFreke/smali (latest JAR downloads).
HISTORY
Created by JesusFreke in 2009 as part of open-source smali/baksmali project on GitHub. Evolved for Android versions up to latest APIs; key for early deodexing and now integrated in tools like apktool. Active development with 2.x releases adding API 30+ support.


