text stringlengths 0 1.99k |
|---|
oatdump utility. Similar to objdump, it displays information from oat files |
in human-readable form. It is fast but produces a lot of output. We can get |
almost all information we could need like this: |
```console |
$ adb shell oatdump --oat-file=/data/app/~~ICLdeF7FOXIe1b9MxToZGQ==/\ |
app.organicmaps-2xFay0QEb95pHRC_k_T1gA==/oat/arm64/base.odex \ |
> app.organicmaps.odex.oatdump |
$ cat app.organicmaps.odex.oatdump |
[...] |
3: double app.organicmaps.util.LocationUtils.correctAngle(double, double) |
(dex_method_idx=27942) |
DEX CODE: |
0x0000: 1400 0400 0000 | const v0, #+4 |
0x0003: 1401 0100 0000 | const v1, #+1 |
0x0006: 9000 0001 | add-int v0, v0, v1 |
0x0008: 9400 0001 | rem-int v0, v0, v1 |
0x000a: 3c00 0500 | if-gtz v0, +5 |
0x000c: 2a00 1200 0000 | goto/32 +18 |
0x000f: cb53 | add-double/2addr v3, v5 |
0x0010: 1805 182d 4454 fb21 1940 | const-wide v5, \ |
#+4618760256179416344 |
0x0015: cf53 | rem-double/2addr v3, v5 |
0x0016: 1600 0000 | const-wide/16 v0, #+0 |
0x0018: 3002 0300 | cmpg-double v2, v3, v0 |
0x001a: 3b02 0300 | if-gez v2, +3 |
0x001c: cb53 | add-double/2addr v3, v5 |
0x001d: 1003 | return-wide v3 |
0x001e: 2a00 f1ff ffff | goto/32 -15 |
[...] |
CODE: (code_offset=0x00816520 size=92)... |
0x00816520: d1400bf0 sub x16, sp, #0x2000 (8192) |
0x00816524: b940021f ldr wzr, [x16] |
StackMap[0] (native_pc=0x812528, dex_pc=0x0, register_mask=0x0, \ |
stack_mask=0b) |
0x00816528: f81e0fe0 str x0, [sp, #-32]! |
0x0081652c: f9000ffe str lr, [sp, #24] |
0x00816530: fd000be8 str d8, [sp, #16] |
0x00816534: f94002b5 ldr x21, [x21] |
StackMap[1] (native_pc=0x812538, dex_pc=0x0, register_mask=0x0, \ |
stack_mask=0b) |
0x00816538: 5c0001e8 ldr d8, pc+60 (addr 0x00816574) (6.28319) |
0x0081653c: 1e612800 fadd d0, d0, d1 |
0x00816540: 1e604101 fmov d1, d8 |
0x00816544: f942027e ldr lr, [tr, #1024] ; pFmod |
0x00816548: d63f03c0 blr lr |
0x0081654c: 1e602008 fcmp d0, #0.0 |
0x00816550: 1a9f37e0 cset w0, hs |
0x00816554: 1e682801 fadd d1, d0, d8 |
0x00816558: 7100001f cmp w0, #0x0 (0) |
0x0081655c: 1e611c00 fcsel d0, d0, d1, ne |
0x00816560: fd400be8 ldr d8, [sp, #16] |
0x00816564: f9400ffe ldr lr, [sp, #24] |
0x00816568: 910083ff add sp, sp, #0x20 (32) |
0x0081656c: d65f03c0 ret |
0x00816570: 5800007f ldr xzr, pc+12 (addr 0x0081657c) \ |
(0xd1400bf0006c564f / -3368679395845974449) |
0x00816574: 54442d18 unallocated (Unallocated) |
0x00816578: 401921fb unallocated (Unallocated) |
``` |
We say it contains almost all information because the output refers to the |
code_offset relative to the oatdata section in the OAT file. To get this |
offset, we can use readelf: |
```console |
$ adb shell readelf -s /data/app/~~ICLdeF7FOXIe1b9MxToZGQ==/\ |
app.organicmaps-2xFay0QEb95pHRC_k_T1gA==/oat/arm64/base.odex \ |
| grep 'oatdata$' |
1: 0000000000000658 2865576 OBJECT GLOBAL DEFAULT 5 oatdata |
``` |
Now we know we need to add 0x658 to the addresses in the oatdump output. If |
we want to compare it directly to Ghidra's output, we also need to add |
0x100000 unless Ghidra used a different base address. |
---[ 3.4 - Wait, Where Did the Arithmetic Go? |
Eagle-eyed readers might have noticed some dummy arithmetic operations in |
the Dalvik code, with a goto instruction at the end, that seemingly |
vanished during compilation. We're sorry we were not completely honest. We |
did not use the regular build of Organic Maps, but instead a version that |
was repackaged with ObfuscAPK [15], using the "ArtithmeticBranch" |
obfuscation. This adds a branch at the beginning of each method with an |
arithmetic expression that always resolves to the same code being executed. |
The ART helpfully removed this obfuscation as part of its optimizations. |
This means we get some free normalization of code along the way, as a |
treat! Not enough to deal with advanced techniques, but enough to make a |
difference. |
To compare the same method without obfuscations, here's another oatdump of |
the original Organic Maps app: |
```console |
$ cat app.organicmaps_unobfuscated.odex.oatdump |
[...] |
3: double app.organicmaps.util.LocationUtils.correctAngle(double, double) |
(dex_method_idx=27942) |
DEX CODE: |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.