-
Notifications
You must be signed in to change notification settings - Fork 173
/
Copy pathjdgui-apk.sh
executable file
·66 lines (52 loc) · 1.35 KB
/
jdgui-apk.sh
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
#!/bin/sh
SCRIPT_DIR="$(dirname "$0")"
export SCRIPT_DIR
# 校验参数合法性
source $SCRIPT_DIR/util.sh
check $1
# 得到新的目录
newfoldername=$foldername
rm -rf $newfoldername
# 判断目录是否为空
function isEmptyDir(){
return `ls -A $1|wc -w`
}
# 执行apktool命令
sh $SCRIPT_DIR/tools/apktool/apktool d -f $absolutename
# 判断目录是否存在,不存在证明执行apktool命令出现异常
if [ ! -d "$foldername" ];
then
echo "Resource files decompile failed"
exit
fi
# 判断目录是否为空,为空证明执行apktool命令出现异常
if isEmptyDir $foldername;
then
echo "Resource files decompile failed"
exit
fi
# 执行apktool命令成功
echo "Resource files decompile successful"
# 切换到之前文件名创建的目录中
cd $foldername
echo `pwd`
# 执行dex2jar命令
sh $SCRIPT_DIR/tools/dex2jar/d2j-dex2jar.sh $absolutename
suffix="-dex2jar.jar"
jarname=${foldername}${suffix}
# 判断是否生成后缀为-dex2jar.jar的文件
if [ ! -f "$jarname" ];
then
echo "Dex file decompile failed"
exit
fi
# 执行dex2jar命令成功
echo "Dex file decompile successful"
# 打印生成后缀为-dex2jar.jar的文件的路径
path=`pwd`
pathname=${path}"/"${jarname}
echo ${pathname}
# 通过jd-gui查看jar文件
echo "View the decompile file"
# 执行jd-gui命令
java -jar $SCRIPT_DIR/tools/jd-gui/jd-gui.jar $jarname