Skip to content

Instantly share code, notes, and snippets.

@lieyunye
Last active July 6, 2016 09:03
Show Gist options
  • Save lieyunye/e1ff3ad9fa3a377cc1269d88840230b0 to your computer and use it in GitHub Desktop.
Save lieyunye/e1ff3ad9fa3a377cc1269d88840230b0 to your computer and use it in GitHub Desktop.
if [ $# -gt 0 ]; then
echo "开始分析..."
else
echo "请输入.rar的文件名!!!"
exit;
fi
name=$1
suffix=".rar"
#解压rar包
unrar x -inul ${name}${suffix}
for file in ${name}/*
do
echo $file
#提取文件名中的渠道名字符串
string=`echo $file | sed 's/\(.*\)_\(.*\)_\(.*\)/\3/g' | cut -d '.' -f 1`
#echo $string
mkdir ${name}/tmp
#解压apk文件
/usr/bin/unzip -q ${file} -d ${name}/tmp
#反编译AndroidManifest.xml
java -jar AXMLPrinter2.jar ${name}/tmp/AndroidManifest.xml > ${name}/tmp/tmp.txt
#找出渠道名所在的行
cat ${name}/tmp/tmp.txt | sed -n '/UMENG_CHANNEL/,/android:value/p' > ${name}/tmp/result.txt
#去掉行首空格
sed 's/^[[:space:]]*//g' ${name}/tmp/result.txt > ${name}/tmp/result1.txt
#去掉字符串内的空格
sed 's/ //g' ${name}/tmp/result1.txt > ${name}/tmp/finalresult.txt
#cat ${name}/tmp/finalresult.txt
#找出字符串内的渠道名
finalstring=`sed '1d' ${name}/tmp/finalresult.txt | cut -d '"' -f 2`
if [ $string = $finalstring ]; then
echo "==========================OK"
else
echo "===========WTF==============="
fi
# echo $finalstring
rm -rf ${name}/tmp/
done
rm -rf ${name}
echo "分析结束!"
@lieyunye
Copy link
Author

lieyunye commented Jul 6, 2016

依赖 JDK、unrar、unzip 、AXMLPrinter2.jar

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment