-
Notifications
You must be signed in to change notification settings - Fork 80
Expand file tree
/
Copy pathunpacker.sh
More file actions
74 lines (51 loc) · 1.58 KB
/
Copy pathunpacker.sh
File metadata and controls
74 lines (51 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/bin/bash
AOSP="$1" # aosp directory location
APK="$2" # apk full path
echo "###############################################################"
echo "# APK Unpacking"
echo "###############################################################"
echo "Extracting package name..."
WORK_DIR="$PWD"
PKG="$(aapt dump badging "$APK" | awk '/package/{gsub("name=|'"'"'",""); print $2}')"
DATA_DIR="/data/data/$PKG"
echo "Running of an emulator..."
cd $AOSP
source build/envsetup.sh > /dev/null 2>&1
lunch full-eng > /dev/null 2>&1
emulator > /dev/null 2>&1 &
cd $WORK_DIR
echo "Waiting for emulator loading..."
while [ "$EBOOT" != "1" ]
do
sleep 3s
EBOOT="$(adb shell getprop sys.boot_completed 2>/dev/null | tr -d ' \r\n')"
done
echo "Installing of apk..."
adb install $APK > /dev/null 2>&1
echo "Launching of app..."
adb shell monkey -p $PKG -c android.intent.category.LAUNCHER 1 > /dev/null 2>&1
echo "Waiting for the app loading..."
iter=0
max_iter=5
while [ -z "$DEX" ] && [ $iter -lt $max_iter ];
do
sleep 3s
(( iter++ ))
DEX="$(adb shell find $DATA_DIR -name *__unpacked_dex | tr -d ' \r\n')"
done
if [ $iter -eq $max_iter ]; then
echo "Something wrong. Unpacked dex was not created!"
kill %1
exit
fi
OAT="$(adb shell find $DATA_DIR -name *__unpacked_oat | tr -d ' \r\n')"
echo "Pulling unpacked DEX from emulator..."
echo " $DEX"
echo " $OAT"
adb pull $DEX > /dev/null 2>&1
adb pull $OAT > /dev/null 2>&1
echo "Uninstalling of apk..."
adb uninstall $PKG > /dev/null 2>&1
kill %1
echo "App was successfully unpacked!"
echo "###############################################################"