text stringlengths 0 1.99k |
|---|
/data/app/~~ICLdeF7FOXIe1b9MxToZGQ==/app.organicmaps-2xFay0QEb95pHRC_k_T1gA= |
=/oat/arm64/base.odex |
``` |
---[ 3.2 - How Can We Compile an App's Code Fully Ahead-of-Time? |
We could run dex2oat ourselves, recreating the invocation as closely as |
possible. Fortunately we don't have to deal with this, and can instead ask |
Android nicely to do it for us. The package manager `pm` will do it: |
```console |
$ adb shell pm compile -m everything app.organicmaps |
Success |
``` |
Looking at the logs, we see a very similar invocation, but now the compiler |
filter has been set to 'everything': |
```console |
$ adb logcat artd:I *:S # formatted for convenience |
[...] |
02-29 15:51:15.515 6074 6583 I artd : Running dex2oat: |
/apex/com.android.art/bin/art_exec --drop-capabilities |
--set-task-profile=Dex2OatBootComplete --set-priority=background |
--keep-fds=6:7:8:9:10:11:12 -- |
/apex/com.android.art/bin/dex2oat64 |
--zip-fd=6 -zip-location=/data/app/[...]/base.apk |
--oat-fd=7 --oat-location=/data/app/[...]/oat/arm64/base.odex |
--output-vdex-fd=8 --swap-fd=9 --class-loader-context-fds=10:11 |
--class-loader-context=PCL[]{PCL[...]} |
--classpath-dir=/data/app/[...] --input-vdex-fd=12 |
--instruction-set=arm64 --instruction-set-features=default |
--instruction-set-variant=cortex-a55 |
--compiler-filter=everything |
--compilation-reason=cmdline --compact-dex-level=none |
--max-image-block-size=524288 --resolve-startup-const-strings=true |
--generate-mini-debug-info --runtime-arg -Xtarget-sdk-version:35 |
--runtime-arg -Xhidden-api-policy:enabled --cpu-set=0,1,2,3,4,5,6,7,8 |
-j8 --runtime-arg -Xms64m --runtime-arg -Xmx512m |
--comments=app-name:app.organicmaps,[...] |
``` |
And indeed, the odex now contains a lot more binary code: |
```console |
$ adb shell ls -lah |
/data/app/~~ICLdeF7FOXIe1b9MxToZGQ==/app.organicmaps-2xFay0QEb95pHRC_k_T1gA= |
=/oat/arm64/base.odex |
-rw-r--r-- 1 system all_a306 14M 2025-02-29 15:51 |
/data/app/~~ICLdeF7FOXIe1b9MxToZGQ==/app.organicmaps-2xFay0QEb95pHRC_k_T1gA= |
=/oat/arm64/base.odex |
``` |
Pull the file from your (virtual) device and you are ready to go! We'll |
save our example as `app.organicmaps.odex`. |
---[ 3.3 - How Can We Disassemble OAT Files? |
It's an ELF! Throw it in your favorite disassembler. They all do reasonably |
well, we checked by looking at the function boundaries [12]! |
```console |
$ file app.organicmaps.odex |
oats/PXL8_everything/app.organicmaps.odex: ELF 64-bit LSB shared object, |
ARM aarch64, version 1 (GNU/Linux), dynamically linked, stripped |
``` |
We use Ghidra 11.0.3 because it supports the BinExport [13] plugin and is |
freely available. We provide a script to do this headlessly, but using the |
GUI works just as well. |
```console |
$ ./ghidra_export_binexport.sh app.organicmaps.odex |
app.organicmaps.odex.BinExport |
[...] |
Total Time 75 secs |
[...] |
``` |
Not bad, let's try this with a more complex app like Signal [14]: |
```console |
$ ./ghidra_export_binexport.sh org.thoughtcrime.securesms.odex |
org.thoughtcrime.securesms.odex.BinExport |
[...] |
Total Time 2642 secs |
[...] |
``` |
Well, this is hardly ideal. Taking almost an hour to prepare an app will |
not scale, even though we need to disassemble each OAT file we want to |
compare only once. In the script we already included some speedups, like |
disabling the GCCExceptionAnalyzer, which takes time but in our case is |
pointless, since the OAT file has never seen GCC. But modern apps are |
ridiculously big. The Signal app has around 500k Dalvik methods alone, not |
counting native libraries. Its Linux app has around 40k, including all |
dynamically loaded libraries such as glibc. No wonder it takes almost an |
hour to analyze the OAT. |
Fortunately, Android provides another way to see the disassembly with the |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.