1.Androidåºç¡ãV1V2V3ç¾åã
Androidåºç¡ãV1V2V3ç¾åã
åºç¡æ¦å¿µç¾åï¼å¨ APK ä¸åå ¥ä¸ä¸ªãæ纹ããæ纹åå ¥ä»¥åï¼APK ä¸æä»»ä½ä¿®æ¹ï¼é½ä¼å¯¼è´è¿ä¸ªæ纹æ æï¼Android ç³»ç»å¨å®è£ APK è¿è¡ç¾åæ ¡éªæ¶å°±ä¼ä¸éè¿ï¼ä»èä¿è¯äºå®å ¨æ§ã
æè¦ç®æ³ï¼ 使ç¨ä¸æ®µç®åççä¸å»éæºçä¸å¯éåçåºå®é¿åº¦çå符串æ¥è¡¨ç¤ºä¸ä¸ªæ件çå¯ä¸æ§ã 常è§çæè¦ç®æ³å¦MD5(个æ¯ç¹ä½)ãSHA-1ç®æ³(//个æ¯ç¹ä½)ã
å ¬é¥å¯ç ä½å¶ï¼ä¹ç§°é对称ç®æ³ï¼ç¹ç¹æ¯å ¬é¥æ¯å ¬å¼çï¼ç§é¥æ¯ä¿å¯çã常è§çå¦ï¼RSAã
å±å¼è®¨è®ºä¸ä¸RSAï¼
Androidä¸çç¾åæ¹æ¡
V1 ï¼åºäºjarsigner(JDKèªå¸¦å·¥å ·ï¼ä½¿ç¨keystoreæ件è¿è¡ç¾å) æ apksigner(Androidä¸é¨æä¾çï¼ä½¿ç¨pk8ãx.pemè¿è¡ç¾å)ãkeystoreåpk8/x.pemå¯ä»¥ç¸äºè½¬æ¢ã
ç¾ååçï¼é¦å keystoreæ件å å«ä¸ä¸ªMD5åä¸ä¸ªSHA1æè¦ãè¿ä¹æ¯å¾å¤å¼æ¾å¹³å°éè¦æ们ä¸ä¼ çæè¦æ°æ®ã
ç¾åAPKåä¼å¨META-INFæ件夹ä¸ç产CERT.RSAãCERT.SFãMANIFEST.MFä¸ä¸ªæ件ã
å¨apkä¸ï¼/META-INFæ件夹ä¸ä¿åçapkçç¾åä¿¡æ¯ï¼ä¸è¬è³å°å å«ä¸ä¸ªæ件ï¼[CERT].RSAï¼[CERT].SFåMANIFEIST.MFæ件ãè¿ä¸ä¸ªæ件就æ¯å¯¹apkçç¾åä¿¡æ¯ã
MANIFEST.MFä¸å å«å¯¹apkä¸é¤äº/META-INFæ件夹å¤æææ件çç¾åå¼ï¼ç¾åæ¹æ³æ¯å SHA1()(æå ¶ä»hashæ¹æ³)å¨base()ãåå¨å½¢å¼æ¯ï¼Nameå [SHA1]-Digestã
[CERT].SFæ¯å¯¹MANIFEST.MFæ件æ´ä½ç¾å以åå ¶ä¸å个æ¡ç®çç¾åãä¸è¬å°ï¼å¦ææ¯ä½¿ç¨å·¥å ·ç¾åï¼è¿å¤å æ¬ä¸é¡¹ãå°±æ¯å¯¹MANIFEST.MF头é¨ä¿¡æ¯çç¾åï¼å ³äºè¿ä¸ç¹åé¢æºç åæä¸å·²ç»æå°ã
[CERT].RSAå å«ç¨ç§é¥å¯¹[CERT].SFçç¾å以åå å«å ¬é¥ä¿¡æ¯çæ°åè¯ä¹¦ã
æ¯å¦åå¨ç¾å伪é å¯è½ï¼
ä¿®æ¹(å«å¢å æ¹)äºapkä¸çæ件ï¼åï¼æ ¡éªæ¶è®¡ç®åºçæ件çæè¦å¼ä¸MANIFEST.MFæ件ä¸çæ¡ç®ä¸å¹é ï¼å¤±è´¥ã
ä¿®æ¹apkä¸çæ件+MANIFEST.MF,码阅宅哥技术源码åï¼MANIFEST.MFä¿®æ¹è¿çæ¡ç®çæè¦ä¸[CERT].SF对åºçæ¡ç®ä¸å¹é ï¼å¤±è´¥ã
ä¿®æ¹apkä¸çæ件+MANIFEST.MF+[CERT].SFï¼åï¼è®¡ç®åºç[CERT].SFç¾åä¸[CERT].RSAä¸è®°å½çç¾åå¼ä¸å¹é ï¼å¤±è´¥ã
ä¿®æ¹apkä¸çæ件+MANIFEST.MF+[CERT].SF+[CERT].RSAï¼åï¼ç±äºè¯ä¹¦ä¸å¯ä¼ªé ï¼[CERT].RSAæ æ³ä¼ªé ã
V2 ï¼7.0æ°å¢ç
ç¾ååçå ä¼è¢«å为åé¨å
1. Contents of ZIP entriesï¼from offset 0 until the start of APK Signing Blockï¼
2. APK Signing Block
3. ZIP Central Directory
4. ZIP End of Central Directory
æ°åºç¨ç¾åæ¹æ¡çç¾åä¿¡æ¯ä¼è¢«ä¿åå¨åºå2ï¼APK Signing Blockï¼ä¸ï¼ èåºå1ï¼ Contents of ZIP entries ï¼ãåºå3ï¼ ZIP Central Directory ï¼ãåºå4ï¼ ZIP End of Central Directory ï¼æ¯åä¿æ¤çï¼å¨ç¾ååä»»ä½å¯¹åºå1ã3ã4çä¿®æ¹é½éä¸è¿æ°çåºç¨ç¾åæ¹æ¡çæ£æ¥ã
V3 ï¼9.0æ°å¢ç
æ ¼å¼å¤§ä½å v2 类似ï¼å¨ v2 æå ¥çç¾ååï¼Apk Signature Block v2ï¼ä¸ï¼åæ·»å äºä¸ä¸ªæ°å¿«ï¼Attråï¼ã
å¨è¿ä¸ªæ°åä¸ï¼ä¼è®°å½æ们ä¹åçç¾åä¿¡æ¯ä»¥åæ°çç¾åä¿¡æ¯ï¼ä»¥ å¯é¥è½¬è½®çæ¹æ¡ï¼æ¥åç¾åçæ¿æ¢åå级ãè¿æå³çï¼åªè¦æ§ç¾åè¯ä¹¦å¨æï¼æ们就å¯ä»¥éè¿å®å¨æ°ç APK æ件ä¸ï¼æ´æ¹ç¾å ã
v3 ç¾åæ°å¢çæ°åï¼attrï¼åå¨äºææçç¾åä¿¡æ¯ï¼ç±æ´å°ç Level åï¼ä»¥é¾è¡¨çå½¢å¼åå¨ã
å ¶ä¸æ¯ä¸ªèç¹é½å å«ç¨äºä¸ºä¹åçæ¬çåºç¨ç¾åçç¾åè¯ä¹¦ï¼ææ§çç¾åè¯ä¹¦å¯¹åºæ ¹èç¹ï¼ç³»ç»ä¼è®©æ¯ä¸ªèç¹ä¸çè¯ä¹¦ä¸ºå表ä¸ä¸ä¸ä¸ªè¯ä¹¦ç¾åï¼ä»è为æ¯ä¸ªæ°å¯é¥æä¾è¯æ®æ¥è¯æå®åºè¯¥åæ§å¯é¥ä¸æ ·å¯ä¿¡ã
è¿ä¸ªè¿ç¨æç¹ç±»ä¼¼ CA è¯ä¹¦çè¯æè¿ç¨ï¼å·²å®è£ ç App çæ§ç¾åï¼ç¡®ä¿è¦çå®è£ ç APK çæ°ç¾åæ£ç¡®ï¼å°ä¿¡ä»»ä¼ éä¸å»ã
注æï¼ç¾åæ¹å¼åªæ¯æå级ä¸æ¯æé级ï¼å¦å®è£ äºV2çå ï¼ä¸è½è¦çæ¿æ¢ä¸ºV1çå ã
åè
Android Appç¾å(è¯ä¹¦)æ ¡éªè¿ç¨æºç åæ
æ°ä¸ä»£å¼æºAndroidæ¸ éå çæå·¥å ·Walle
Android ç¾åæºå¶ v1ãv2ãv3