Abstract
This paper introduces Dexpler, a software package which converts Dalvik bytecode to Jimple. Dexpler is built on top of Dedexer and Soot. As Jimple is Soot's main internal representation of code, the Dalvik bytecode can be manipulated with any Jimple-based tool, for instance for performing points-to or flow analysis.
Introduction
Android applications are predominantly written in Java but are compiled into Dalvik bytecode and packaged as .dex files for execution on the Dalvik Virtual Machine (DVM) or Android Runtime (ART). While mature static analysis frameworks like Soot, WALA, and BCEL exist for standard Java bytecode (.class files), they cannot natively process Dalvik bytecode. This creates a significant hurdle for security researchers and developers who wish to perform sophisticated analyses like data-flow or points-to analysis on Android applications.
The Challenge of Dalvik Bytecode
Dalvik bytecode is specifically optimized for the resource-constrained environment of mobile devices. Unlike the stack-based architecture of standard Java bytecode, Dalvik uses a register-based architecture. Furthermore, while a Java application consists of many individual .class files, an Android application consolidates all classes into a single classes.dex file to reduce redundancy and file size.
As shown in the comparison above, the .dex format shares constant pools across all classes, which differs significantly from the per-class constant pools found in standard Java bytecode. Existing approaches to bridge this gap often involve converting Dalvik back to Java bytecode (e.g., using dex2jar), but this intermediate step can introduce translation errors and performance overhead.
Methodology: The Dexpler Approach
Dexpler provides a direct bridge from Dalvik bytecode to Jimple, Soot’s primary intermediate representation. This integration allows researchers to leverage the extensive suite of analysis tools available within the Soot ecosystem. The conversion process involves several key components:
- Instruction Mapping: The authors developed a comprehensive mapping for 217 of the 237 Dalvik opcodes. This process translates Dalvik's register-based instructions into Jimple’s three-address, stack-less statements.
- Type Inference and the "Fast Typing" Algorithm: A major technical hurdle is the ambiguity of certain Dalvik instructions. For instance, the same opcode is used to initialize a variable to either the integer
0or the object referencenull. Dexpler employs a "Fast Typing" algorithm—a depth-first search that examines the future usage of a variable within the control flow to retroactively assign the correct type. - Branch and Control Flow Handling: To maintain the integrity of the original program logic, Dexpler maps Dalvik instruction addresses to their corresponding Jimple statements, ensuring that all jumps and branches are correctly preserved.
Evaluation and Results
The effectiveness of Dexpler was evaluated using a custom test suite and the "Snake" Android demonstration application.
Functional Correctness and Efficiency
Dexpler successfully converted all test cases. The resulting Jimple code was used to generate standard Java .class files that executed correctly on a standard JVM, validating the accuracy of the translation. The conversion of the Snake application (comprising 11 classes and 884 instructions) was completed in approximately one second, indicating that the tool is efficient enough for large-scale analysis.
Static Analysis Capabilities
By converting code to Jimple, Dexpler enables the generation of sophisticated analytical artifacts. The figure below illustrates a Control Flow Graph (CFG) generated directly from the converted code of the Snake application.
Such visualizations are critical for understanding complex application behaviors and identifying potential security vulnerabilities directly from Android binaries.
Conclusion and Future Work
Dexpler offers a robust, direct path for analyzing Android applications within the Soot framework. By avoiding the pitfalls of Dalvik-to-Java-bytecode conversion, it provides a cleaner and more reliable foundation for static analysis. Future work includes extending support to optimized Dalvik (odex) instructions and enhancing the type inference engine's resilience against intentionally obfuscated or malicious bytecode.
Summary updated