标签:
用shell写了一个查看apk签名的脚本。代码很少也很简单
支持递归目录查询
#!/bin/bash #使用方法 ./getcertificate.sh xx.apk get_signature() { path=`jar tf "$1" | grep RSA` #查找apk中RSA文件 jar xf $1 $path #把RSA文件解压出来 keytool -printcert -file $path #查看指纹证书 rm -r $path #删除之前解压的文件 } mypath=`pwd` filepath="" if [ -d .temp_for_certificate ] then echo ".temp_for_certificate is exist,remove it first!" exit fi mkdir .temp_for_certificate cd .temp_for_certificate count=0 while [ -n "$1" ] do if [ `expr substr "$1" 1 1` = "/" ] #绝对路径 then filepath="$1" else #相对路径 filepath="$mypath/$1" fi if [ -d $filepath ] then all_apk=`find $filepath -name "*.apk"` for apk_path in $all_apk do count=$[$count+1] echo "(#$count) "`basename "$apk_path"`":" filepath=$apk_path get_signature "$filepath" echo "-----------------------------------------------------------" done else count=$[$count+1] echo "(#$count) "`basename "$1"`":" get_signature "$filepath" echo "-----------------------------------------------------------" fi shift done cd .. rm -r .temp_for_certificate echo "done!"
使用方法:
Leo-MBP:a kangyi$ ./getcertificate.sh test1.apk test2.apk
输出:
脚本也支持递归目录,比如
Bash代码: Leo-MBP:a kangyi$ ./getcertificate.sh app/A.apk app/Dir1 app/Dir2/
查看签名也可以使用jarsigner
jarsigner详细用法详见帮助
原文地址:http://su1216.iteye.com/blog/1884363
标签:
原文地址:http://www.cnblogs.com/kangyi/p/4468971.html