Wrote a script to view the APK signature with the shell. The code is very small and simple.
Supports recursive directory queries
#!/bin/bash# how to use the./getcertificate.sh xx.apkget_signature () {path= ' jar tf ' $ ' | grep RSA ' #查找apk中RSA文件 jar XF $ $p Ath #把RSA文件解压出来 keytool-printcert-file $path #查看指纹证书 rm-r $path #删除之前解压的文件}mypath= ' pwd ' filepath= "" if [-D. Temp_f Or_certificate]then echo ". Temp_for_certificate is Exist,remove it first!" Exitfimkdir. Temp_for_certificatecd. Temp_for_certificatecount=0while [-N "]" do if [' Expr substr "$ 1 1 ' =" /"] #绝对路径 then filepath=" $ "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 "" ' ":" Get_signature "$filepAth "echo"-----------------------------------------------------------"fi shiftdone CD. Rm-r. Temp_for_certificateecho "done!"
(Save it to a file, named getcertificate.sh)
How to use:
Leo-mbp:a kangyi$./getcertificate.sh test1.apk test2.apk
Output:
(#1) SUPERUSER.APK:
Owner: Cn=adam Shanks, Ou=android, O=soupcoconut, L=FWB, St=florida, C=us
Issued by: Cn=adam Shanks, Ou=android, O=soupcoconut, L=FWB, St=florida, C=us
Serial Number: 4c614057
Validity: Tue 20:04:39 CST 2010 to Sat Dec 20:04:39 CST 2037
Certificate thumbprint:
Md5:d2:42:30:aa:be:81:62:30:fe:b4:0e:f1:cf:11:b0:c0
sha1:5f:11:3f:c2:c2:0a:7c:9b:d9:28:19:22:6a:32:a1:90:4b:75:ef:8b
Signature Algorithm Name: Sha1withrsa
Version: 3
--------------------------------------------
(#2) SKYPE3.0.APK:
Owner: Cn=skype, Ou=mobile Client, O=skype, L=london, C=GB
Issuer: Cn=skype, Ou=mobile Client, O=skype, L=london, C=GB
Serial Number: 4c0e1962
Validity: Tue June 18:20:18 CST 2010 to Fri Jul 18:20:18 CST 2040
Certificate thumbprint:
Md5:37:5f:1a:56:c5:2a:51:ff:35:f3:6c:c5:a6:69:54:ec
Sha1:77:18:07:d1:b8:41:4d:69:89:e7:d8:ef:0b:97:97:24:3b:93:1f:95
Signature Algorithm Name: Sha1withrsa
Version: 3
--------------------------------------------
The script also supports recursive directories, such as
Bash code: leo-mbp:a kangyi$./getcertificate.sh app/a.apk App/dir1 app/dir2/
You can also use Jarsigner to view signatures
Bash code: Jarsigner-verify-verbose-certs superuser.apk
Jarsigner detailed usage See Help
Original address: http://su1216.iteye.com/blog/1884363
Shell Script View apk signature information