Skip to content

Commit 76f0ce3

Browse files
committed
add script to convert ART OAT to DEX
1 parent c4239fe commit 76f0ce3

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

android/oat2dex.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/bash
2+
# Extract DEX file from inside Android Runtime OAT file using radare2
3+
# (c)2013 Pau Oliva (@pof)
4+
5+
OAT="$1"
6+
if [ -z "${OAT}" ]; then
7+
echo "Usage: $0 <file.oat>"
8+
exit 0
9+
fi
10+
HIT=$(r2 -q -c '/ dex\n035' "${OAT}" 2>/dev/null |grep hit0_0 |awk '{print $1}')
11+
if [ -z "${HIT}" ]; then
12+
echo "[-] ERROR: Can't find dex header"
13+
exit 1
14+
else
15+
echo "[+] DEX header found at address: ${HIT}"
16+
fi
17+
SIZE=$(r2 -e scr.color=false -q -c "px 4 @$HIT+32" ${OAT} 2>/dev/null |tail -n 1 |awk '{print $2 $3}' |sed -e "s/^/0x/" |rax2 -e)
18+
echo "[+] Dex file size: ${SIZE} bytes"
19+
r2 -q -c "pr ${SIZE} @${HIT} > ${OAT}.dex" "${OAT}" 2>/dev/null
20+
if [ $? -eq 0 ]; then
21+
echo "[+] Dex file dumped to: ${OAT}.dex"
22+
else
23+
echo "[-] ERROR: Something went wrong :("
24+
fi

0 commit comments

Comments
 (0)