-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbootstrap.sh
More file actions
68 lines (56 loc) · 1.35 KB
/
Copy pathbootstrap.sh
File metadata and controls
68 lines (56 loc) · 1.35 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
#!/bin/bash
WORKER_THREADS=${WORKER_THREADS:-1}
DECOMPILE_TOOL=${DECOMPILE_TOOL:=jadx}
[[ -d /input ]] || mkdir /input
[[ -d /output ]] || mkdir /output
die()
{
>&2 echo "$@"
exit 1
}
runat()
{
_LOCATION=$1
shift
>/dev/null pushd ${_LOCATION}
"$@"
>/dev/null popd
}
extract_apk()
{
_OUTDIR="$1"
_APK=$2
_OPTS=${DECOMPILER_OPTS}
case ${DECOMPILE_TOOL} in
jadx)
_OPTS="${_OPTS} --deobf"
;;
apktool)
_OPTS="${_OPTS} decode"
;;
*)
die "unknown DECOMPILE_TOOL ${DECOMPILE_TOOL}"
esac
[[ -d ${_OUTDIR} ]] || mkdir -p ${_OUTDIR}
runat ${_OUTDIR} ${DECOMPILE_TOOL} ${_OPTS} "${_APK}"
}
shopt -s nullglob
if [ -n "${TARGET_APK}" ]
then
$(python3 -c "import validators; import sys; sys.exit(1 if validators.url(\"${TARGET_APK}\") else 0);")
if [ $? == 1 ]
then
runat /input wget -O target "${TARGET_APK}"
else
[[ -f "${TARGET_APK}" ]] && ln -S "${TARGET_APK}" /input/target
fi
fi
[[ -e "/input/target" ]] || die "APK not specified"
>&2 extract_apk /output/src /input/target
# in case original is an [.xapk] file, analyze internal [.apk] files
for ff in $(find /output/src -type f \( -iname \*.apk -o -iname \*.zip \))
do
>&2 extract_apk /output/src "${ff}"
done
[[ -d "/output/src" ]] || die "no files to analyze"
python3 /gitGraber/fileGraber.py -m '/output/src/**/*' -t ${WORKER_THREADS} ${GRABER_OPTS}