当前位置:网站首页>Knowing things by learning | app slimming down, the way of safety reinforcement under the new generation AAB framework
Knowing things by learning | app slimming down, the way of safety reinforcement under the new generation AAB framework
2022-07-27 17:59:00 【Netease Yidun】
stay Google I/O At the conference ,Google towards Android The introduction of new APP Dynamic framework Android APP Bundle (AAB), Be regarded as right Android In the future, we will develop subversive dynamic solutions . This paper starts from AAB Starting from the advantages of dynamic framework , Analysis of how to AAB Format to achieve high-quality reinforcement , Help mobile applications switch freely between domestic and foreign markets , Provide a quality experience with smaller applications .

chart | AAB Format architecture diagram
01 AAB Applied slimming
Compared with APK,Google The strength of APP Packaging format AAB It is superior in many ways , It is mainly reflected in the following points :
1.1. Dynamic distribution
One APK It often contains the language resources of various countries 、ABI、 Screen density and other resources . However , For a single user , Often only some of these resources are needed .
at present , Domestic developers put all resources in a single APK in , This will lead to APK Especially huge , and AAB In compression APK It has advantages in volume .
In order to reduce the volume , Some developers will deliberately reduce APK Medium ABI Catalog . for example , take arm64-v8a Of SO from APK Medium removal , Leave only armeabi-v7a Of SO. But this practice makes 64 position CPU Your phone can't play its 64 The operational advantages of bits , Reduce the running speed of the program .
Split APKs yes Android 5.0 Start offering more APK Build mechanism , With the help of Split APKs You can put a APK be based on ABI、 Screen density and CPU The architecture is split into multiple APK , This can effectively reduce single APK Volume . When the user downloads the application installation package ,Google Play It will automatically recognize the user's language and CPU framework , Automatically set the corresponding platform SO And resources APK Distribute to users .
1.2. Dynamic function module
stay Android Studio A new module is added in : Dynamic function module . The functions developed through this module can be downloaded when users need it , It is similar to the hot renewal mechanism widely used in China , Just don't overheat updates are mostly used to fix functionality BUG Of , Dynamic function modules tend to form an independent function .
User is installing APK when , Just download one that contains APP Main functions APK , Other additional functions can be dynamically downloaded and installed when users need them . This further reduces APK Volume , Improved for users APP Installation experience .
02 AAB Reinforcement solutions
AAB Format is giving Android APP Bring convenience at the same time , It also brings new challenges to the field of mobile security :AAB Format installation package , In terms of organizational structure and document content APK The format is quite different , Conventional APP Shelling technology cannot be directly applied to APP Bundle Schema generated packets .
Yi Dun passed on AAB Format for in-depth study , For the new AAB The format makes a systematic adjustment and improvement to the existing reinforcement , So as to support new AAB Format .
that , The current reinforcement scheme should be compatible AAB What difficulties does the format face , How did Yidun improve ?
2.1. Prevent second packing
We know , natural APK When uploading the application market, they have already signed in advance , When the cracker from the application market APK download , After repacking , It must be modified APK The signature of the , The general anti secondary packaging function will be right APK Verify the signature of , if APK The signature of is inconsistent with the original signature , be APP Will directly exit . As shown below :

And the anti secondary packaging scheme in reinforcement , They are read in advance during reinforcement APK Signature content in , Before reinforcement APK Signature feature is used as the verification standard , stay APP Runtime on APK Signature characteristics of , If at runtime APK Signature features and pre reinforcement APK Signature characteristics are inconsistent , be APK Will flash back directly .
While using AAB When the format ,Google Play Users will be asked to upload the signature certificate file , from Google Play I'm issuing APK Sign again when . In other words ,AAB The format cannot be signed , Try to use apksigner Yes APK To sign , The output is as follows :

You can see ,apksigner Will try to find the root directory AndroidManifest.xml, But because the file is AAB Format , Lead to apksigner Unable to parse correctly .
This leads to , The reinforcement manufacturer cannot correctly obtain APK Original signature of , Therefore, it is impossible to prevent secondary packaging . that , How does the reinforcement solution made by Yidun solve this problem ?
as everyone knows ,android The first generation of signature tools used , yes jarsigner, instead of apksigner, and jarsigner yes JAVA SDK Built in for JAR Package signing tool . since jarsigner It can be done to JAR and APK To sign , that jarsigner Is it possible to AAB Sign it ?
The answer is yes . We try to use jarsigner Yes AAB Sign the document , Signed AAB The file structure is as follows :

in fact ,jarsigner It's a right ZIP A tool for signing compressed packets in format , And whether it's JAR、APK still AAB, It's all... In essence ZIP Format . therefore , As long as the user uses it before reinforcement jarsigner Yes AAB To sign , Reinforcement manufacturers can correctly obtain APK Signature characteristics of .
2.2. Resource confusion
Resource confusion is often used to reduce APK Volume and protection of resources .
some APP May be APP Some key data in res In file , The cracker uses the resources in the code ID You can easily find the corresponding resource file , Thus, it can be easily modified without modifying the code APK Some important logical effects of . And through resource confusion ,APK Medium res The resource name will be changed to a meaningless name , It is no longer easy for the cracker to find the resource file corresponding to the code .
meanwhile , By confusing the file names of resources , Confuse long file names with short file names , So as to achieve APK Of " Slimming " effect . According to each APK The details of , Every APK After resource confusion, it can be reduced 1 to N MB Volume .
stay APK in , All resources are recorded in the resource index file resource.arsc in , As shown below :

But in AAB in , The format and name of the resource index file have also changed :

2.3. AndroidManifest.xml modify
although VMP Scheme and JAVA2C The program has been around for many years , But for performance reasons , At present, the mainstream reinforcement scheme on the market is still DEX strengthening ,VMP Scheme and JAVA2C It is only used for the protection of core classes . and DEX The basic principle of reinforcement is to modify the entry of application Application Take over the startup logic of the application , In execution DEX After a series of operations such as dynamic loading of , Return the program logic to APP The original entrance of Application, As shown below :

chart | The entrance reinforced by Yidun Application
Some careless developers will even APP Of debuggable The switch is set to "true", Thus making APK Can be easily debugged . Yi Dun will automatically recognize this situation in the process of reinforcement , Change the corresponding switch to "false".
The data mentioned above are recorded in AndroiManifest.xml In file , And packaged APK, Its AndroidManifest.xml Is a compiled binary format , It also involves some and APK Data related to resources in , It is not as easy to modify as the clear text in the development stage , The compiled AndroidManifest.xml The contents are shown below :
You can see , Compared with the development stage AndroidManifest.xml, After compiling AndroidManifest.xml There are many more invisible characters , This often corresponds to some data structures . To modify it , You need to be right about AndroiManifest.xml Have a deep understanding of .
and AAB Medium AndroiManifest.xml Compared with APK Medium AndroiManifest.xml There has been a certain degree of change , But the original modification scheme cannot be reused directly .
Above AndroiManifest.xml The change of Google Not documented . Yidun is based on the original modification scheme , I have further studied Android Bundle Tool Packaging source code , Extracted AAB Medium AndroiManifest.xml File format , So that AAB In the format AndroiManifest.xml File modification .
2.4. DEX and SO The reinforcement of
in fact , stay AAB In the format ,DEX Document and SO The contents of the document have not been modified , It's just that APK The directory organization structure in has changed . As shown below :

The compatibility of this part of the change is relatively simple , We just need to extract the corresponding files , Press again APK The directory structure of is organized into a pseudo APK. After reinforcement , We will restore the consolidated file to AAB in , It can be perfectly adapted without modifying the original reinforcement scheme AAB Format .
03 summary
AAB Format compared to APK Format , stay DEX Format and SO There is not much change in the format , This also makes for DEX and SO The protection scheme of can be easily migrated .
And the more difficult part is , The formats of various configuration files and resource files have changed greatly , As a result, the original scheme cannot be used directly .
From the perspective of users, Yidun , Considering the reinforcement needs of the vast number of sea applications , Be positive about AAB Format for adaptation , So that the original reinforcement scheme can be completely transferred to AAB On the format , Help applications safely and easily adapt to changes .
边栏推荐
- Flutter的布局
- Fast analysis combined with Haidian medicine
- 知物由学 | 从0到1搭建实时反外挂机制,多维度补充手游攻防力
- 泰山OFFICE技术讲座:WORD奇怪的段落边框
- Interviewer: what is scaffolding? Why do you need scaffolding? What are the commonly used scaffolds?
- 选择体育场馆的LED显示屏时应该注重哪些方面
- Lichuang EDA - layout and inspection of schematic diagram (III)
- Maximum number less than n
- Subject 3: straight driving
- 卷积神经网络——FPN(Feature Pyramid Networks)介绍
猜你喜欢

Fast analysis combined with Haidian medicine

Wechat applet realizes location map display and introduces map map without navigation

Taishan Office Technology Lecture: word strange paragraph borders

笔试缺考者入围教师招聘面试?河南祥符:个别考生成绩统计错误

卷积神经网络——YOLOV1论文翻译

交换机和路由器技术-02-以太网交换机工作原理

机器学习之评价指标(一)——回归评价指标

运行loam_velodyne实时建图

交换机和路由器技术-03-交换机基本配置

Soul 1: why is es more suitable for complex condition search than MySQL?
随机推荐
6月第1周易盾业务风控关注 | 新东方学而思等15家机构被顶格罚款
知物由学 | 小游戏的安全风险在哪里?
笔试缺考者入围教师招聘面试?河南祥符:个别考生成绩统计错误
Introduction to cue language foundation: cue is a language born for configuration
初识多态
Establishing SSL connection without server‘s identity verification is not recommended
【Codeforces】 A. Computer Game
Fast analysis combined with Haidian medicine
[OBS] newsocketloopenable network optimization
Initial polymorphism
VO、DO、DTO、PO是什么
如何限制root远程登入,使普通用户拥有root权限
Explain the pile of binary trees in detail
卷积神经网络——从R-CNN,Fast R-CNN到Faster R-CNN,Mask R-CNN
运行loam_velodyne实时建图
Explain the idempotence of distributed system in detail
ACL 2022 | prompt based automatic depolarization: effectively reducing bias in the pre training language model
Tencent cloud upload
如何开发一款在线Excel表格系统(上)
Notes on standardized management of "ancestral warehouse" of meituan meal