Skip to content

Commit e83fee7

Browse files
committed
Add multi-dex dump support
1 parent 6cb6769 commit e83fee7

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

android/oat2dex.sh

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,24 @@ if [ -z "${OAT}" ]; then
77
echo "Usage: $0 <file.oat>"
88
exit 0
99
fi
10-
HIT=$(r2 -n -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"
10+
HITS=( $(r2 -n -q -c '/ dex\n035' "${OAT}" 2>/dev/null |grep hit |awk '{print $1}') )
11+
if [ ${#HITS[@]} -eq 0 ]; then
12+
echo "[-] ERROR: Can't find dex headers"
1313
exit 1
14+
elif [ ${#HITS[@]} -eq 1 ]; then
15+
echo "[+] DEX header found at address: ${HITS[0]}"
1416
else
15-
echo "[+] DEX header found at address: ${HIT}"
16-
fi
17-
SIZE=$(r2 -n -q -c "pf i @${HIT}+32 ~[2]" "${OAT}" 2>/dev/null)
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 :("
17+
echo "[+] Multiple DEX headers found at addresses:"
18+
for addr in ${HITS[@]}; do echo " $addr"; done
2419
fi
20+
21+
for DEX_ADDR in ${HITS[@]}; do
22+
SIZE=$(r2 -n -q -c "pf i @${DEX_ADDR}+32 ~[2]" "${OAT}" 2>/dev/null)
23+
echo "[+] Dex file size: ${SIZE} bytes"
24+
r2 -q -c "pr ${SIZE} @${DEX_ADDR} > ${OAT}.${DEX_ADDR}.dex" "${OAT}" 2>/dev/null
25+
if [ $? -eq 0 ]; then
26+
echo "[+] Dex file dumped to: ${OAT}.${DEX_ADDR}.dex"
27+
else
28+
echo "[-] ERROR: Something went wrong :("
29+
fi
30+
done

0 commit comments

Comments
 (0)