CN105468970B - A kind of Android application programs based on protection net are anti-to usurp method and system - Google Patents
A kind of Android application programs based on protection net are anti-to usurp method and system Download PDFInfo
- Publication number
- CN105468970B CN105468970B CN201510846522.8A CN201510846522A CN105468970B CN 105468970 B CN105468970 B CN 105468970B CN 201510846522 A CN201510846522 A CN 201510846522A CN 105468970 B CN105468970 B CN 105468970B
- Authority
- CN
- China
- Prior art keywords
- defense
- node
- module
- protected
- android application
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Expired - Fee Related
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F21/00—Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
- G06F21/50—Monitoring users, programs or devices to maintain the integrity of platforms, e.g. of processors, firmware or operating systems
- G06F21/55—Detecting local intrusion or implementing counter-measures
- G06F21/554—Detecting local intrusion or implementing counter-measures involving event detection and direct action
Landscapes
- Engineering & Computer Science (AREA)
- Computer Security & Cryptography (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Computer Hardware Design (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Storage Device Security (AREA)
Abstract
本发明公开了一种基于防御网的Android应用防篡改方法及系统,其中方法步骤包括:构造防御节点模板库、待保护的Android应用程序的解析、生成目标节点集合、构造防御关联、根据用户输入,生成对应防御节点实例、生成并初始化防御网、对待保护的Android应用程序进行反编译、文件重构和签名,所述的系统用于实现该方法。本方法和系统可靠性高、易于扩展、低开销、高效率、过程自动化,软件保护的整体处理流程固定、规范化,主要以自动化为主,辅以较少的人工参与,加上处理周期短,因此完全适用于大量应用的批处理保护。
The invention discloses an anti-tampering method and system for an Android application based on a defense network, wherein the method steps include: constructing a defense node template library, parsing an Android application program to be protected, generating a target node set, constructing a defense association, and according to user input , generating a corresponding defense node instance, generating and initializing a defense network, decompiling an Android application program to be protected, reconstructing and signing a file, and the system is used to implement the method. The method and system have high reliability, easy expansion, low overhead, high efficiency, and process automation. The overall processing flow of software protection is fixed and standardized, mainly based on automation, supplemented by less manual participation, and the processing cycle is short. It is therefore perfectly suitable for batch protection of a large number of applications.
Description
技术领域technical field
本发明属于计算机安全技术领域,具体涉及一种针对Android平台应用软件的防篡改方法。The invention belongs to the technical field of computer security, and in particular relates to an anti-tampering method for application software on an Android platform.
背景技术Background technique
近年来,随着移动互联网的高速发展,网络用户的规模越来越大,接入的移动终端数目越来越多。功能日益丰富的移动终端,尤其是Android,已经代替PC成为人们工作、生活中不可缺少的平台。移动终端上的应用软件,在移动互联网的发展和移动终端的普及中扮演着极其重要的角色,其涵盖的领域不仅涉及社交、娱乐,还涉及到办公、通信、支付等。无论是公司厂商,还是政府部门,越来越多的单位参与到移动终端软件的研发、使用和管理中。In recent years, with the rapid development of the mobile Internet, the scale of network users is increasing, and the number of mobile terminals connected is increasing. Mobile terminals with increasingly rich functions, especially Android, have replaced PCs and become an indispensable platform in people's work and life. The application software on the mobile terminal plays an extremely important role in the development of the mobile Internet and the popularization of mobile terminals. It covers not only social interaction and entertainment, but also office, communication, and payment. Whether it is a company manufacturer or a government department, more and more units are involved in the development, use and management of mobile terminal software.
Android软件的广泛应用在为社会带来巨大利益的同时,其带来的安全问题也日益突出。Android软件往往运行于“白盒攻击”环境中(参见参考文献1),攻击者利用软件篡改技术攻击合法软件,生成恶意软件、破解版、盗版等非法软件,严重影响开发者的经济利益和软件产业的健康发展,甚至威胁到国家安全。因此,提高软件安全性,增强软件防篡改能力成为工业界和学术界急需解决的问题。While the wide application of Android software brings huge benefits to the society, the security problems it brings are also becoming increasingly prominent. Android software often runs in a "white box attack" environment (see Reference 1). Attackers use software tampering techniques to attack legitimate software and generate malicious software, cracked versions, and pirated software, which seriously affect the economic interests of developers and software. The healthy development of the industry even threatens national security. Therefore, improving software security and enhancing software anti-tampering capability has become an urgent problem to be solved in industry and academia.
目前针对Android应用软件的防篡改保护技术尚不成熟,主要技术有:①代码混淆技术,Proguard最早由Google研发,并在官方开发环境Android SDK中提供,开发者利用Proguard,可以对Java源码进行混淆,提高了分析难度,进而提高了软件自身防篡改的能力。然而,Proguard只是将代码中的变量名、函数名、类名进行混淆,只是延长了攻击者定位到关键信息的周期,并不能阻止对关键信息的篡改。②加壳技术,目前产业界安全提供商,例如DexGuard和Bangcle(参见参考文献3、4),针对Android软件提供了以加壳为主的加固服务,提高了Android应用逆向分析的难度。针对这些加壳保护技术,Jia Zhijun开发了脱壳器Zjdroid(参见参考文献5),能对主流的加壳方案进行有效的攻击。③篡改版本检测技术,近年来学术界一些学者致力于研究如何提高篡改版本的检测率。篡改版本检测方案,主要基于代码相似性比较(参考文献6、7、8)或者软件组件的耦合性(参见参考文献9),识别应用是否是篡改后的版本。但是,目前Android的第三方市场多达几十个,更有专门发布篡改版本的市场,因此基于检测的保护方案在实际应用中效果并不好。At present, the anti-tamper protection technology for Android application software is still immature. The main technologies are: ① Code obfuscation technology, Proguard was first developed by Google and provided in the official development environment Android SDK. Developers can use Proguard to confuse Java source code , which increases the difficulty of analysis, thereby improving the ability of the software itself to prevent tampering. However, Proguard only confuses the variable names, function names, and class names in the code, which only prolongs the period for the attacker to locate key information, but cannot prevent the tampering of key information. ② Packing technology. At present, security providers in the industry, such as DexGuard and Bangcle (see references 3 and 4), provide shell-based reinforcement services for Android software, which increases the difficulty of reverse analysis of Android applications. For these packing protection technologies, Jia Zhijun developed the sheller Zjdroid (see Reference 5), which can effectively attack mainstream packing schemes. ③ Tampered version detection technology. In recent years, some scholars in the academic circle have devoted themselves to studying how to improve the detection rate of tampered version. The tampered version detection scheme is mainly based on code similarity comparison (references 6, 7, 8) or coupling of software components (refer to reference 9), to identify whether the application is a tampered version. However, there are as many as dozens of third-party markets for Android at present, and there are even markets that specially release tampered versions, so the protection scheme based on detection does not work well in practical applications.
参考文献:references:
S Chow,P Eisen,H Johnson,P Van Oorschot.A white-box DESimplementation for DRM applications[J].Lecture notes in computer science,2003,2696:1-15.S Chow,P Eisen,H Johnson,P Van Oorschot.A white-box DESimplementation for DRM applications[J].Lecture notes in computer science,2003,2696:1-15.
ProGuard.http://developer.android.com/tools/help/proguard.html.ProGuard. http://developer.android.com/tools/help/proguard.html.
DexGuard.http://www.guardsquare.com/software/dexguard-enterprise.DexGuard. http://www.guardsquare.com/software/dexguard-enterprise.
Bangcle.http://www.bangcle.com/.Bangcle.http://www.bangcle.com/.
ZjDroid.http://seclab.safe.baidu.com/opensec_detail_2.html.ZjDroid.http://seclab.safe.baidu.com/opensec_detail_2.html.
J Crussell.Attack of The Clones:Detecting Cloned Applications onAndroid Markets.ESORICS,Springer.2012.J Crussell. Attack of The Clones: Detecting Cloned Applications on Android Markets. ESORICS, Springer. 2012.
S Hanna,L Huang.Juxtapp:A scalable system for detecting code reuseamong android applications.9th International Conference,DIMVA 2012.S Hanna, L Huang. Juxtapp: A scalable system for detecting code reuse among android applications. 9th International Conference, DIMVA 2012.
Zhou,Wu.Zhou,Yajin.Detecting repackaged smartphone applications inthird-party android marketplaces.Proceedings of the second ACM conference onData and Application Security and Privacy.2012.Zhou, Wu. Zhou, Yajin. Detecting repackaged smartphone applications in third-party android marketplaces. Proceedings of the second ACM conference on Data and Application Security and Privacy. 2012.
Zhou,Wu.Zhou,Yajin.Grace,Michael.Fast,scalable detection ofpiggybacked mobile applications.Proceedings of the third ACM conference onData and Application Security and Privacy.2013.Zhou, Wu. Zhou, Yajin. Grace, Michael. Fast, scalable detection of piggybacked mobile applications. Proceedings of the third ACM conference on Data and Application Security and Privacy. 2013.
Threat Model.https://msdn.microsoft.com/en-us/library/aa302419.aspx.Threat Model. https://msdn.microsoft.com/en-us/library/aa302419.aspx.
发明内容Contents of the invention
针对上述现有Android应用软件保护技术存在的缺陷和不足,本发明的目的在于,提供一种基于防御网的Android应用程序防篡方法,该方法利用计算机系统,对Android系统下应用软件的APK文件进行保护,其保护强度高、易于扩展。For the defects and deficiencies in the above-mentioned existing Android application software protection technology, the object of the present invention is to provide a method for anti-tampering of Android application programs based on the defense network. For protection, its protection strength is high and it is easy to expand.
为了实现上述任务,本发明采用以下技术方案:In order to achieve the above tasks, the present invention adopts the following technical solutions:
一种基于防御网的Android应用程序防篡方法,包括以下步骤:A kind of anti-tampering method for Android application program based on defense net, comprises the following steps:
步骤一,构造防御节点模板库Step 1: Construct the defense node template library
防御节点为嵌入到待保护的Android应用程序中的代码段,用于监测篡改威胁并进行响应;构建防御节点模板库,模板库中存放防御节点的实现代码;The defense node is a code segment embedded in the Android application to be protected, which is used to monitor and respond to tampering threats; build a defense node template library, and store the implementation code of the defense node in the template library;
步骤二,解析待保护的Android应用程序Step 2, analyzing the Android application program to be protected
将待保护的Android应用程序进行解析,生成该待保护的Android应用程序的函数调用图,并对函数调用图中每一个节点进行描述;Analyzing the Android application program to be protected, generating a function call graph of the Android application program to be protected, and describing each node in the function call graph;
步骤三,生成目标节点集合Step 3, generate target node set
在待保护的Android应用程序中,选取感兴趣的区域作为目标节点,并生成目标节点集合;In the Android application program to be protected, select the area of interest as the target node, and generate a target node set;
步骤四,构造防御关联Step 4, Construct Defense Association
构造目标节点与防御节点之间、防御节点与防御节点之间的关联关系;Construct the association relationship between the target node and the defense node, and between the defense node and the defense node;
步骤五,根据用户输入,生成对应防御节点实例Step 5: Generate corresponding defense node instances according to user input
根据用户定义的防御节点种类和数据,在防御节点模板库中选择对应种类的防御节点的实现代码,生成对应的防御节点实例;According to the type and data of the defense node defined by the user, select the implementation code of the defense node of the corresponding type in the defense node template library, and generate the corresponding defense node instance;
步骤六,生成并初始化防御网Step 6, generate and initialize the defense network
根据步骤四中构造的防御关联,结合步骤五中生成的防御节点实例,进行防御网的初始化,该防御网包括防御节点和目标节点以及防御关联;According to the defense association constructed in step 4, combined with the defense node instance generated in step 5, the defense network is initialized, and the defense network includes defense nodes, target nodes and defense associations;
步骤七,对待保护的Android应用程序进行反编译、文件重构和签名。Step seven, decompiling, file reconstruction and signing of the Android application program to be protected.
进一步地,所述的步骤一中防御节点模板库中,每一种防御节点的实现代码均包括三部分:触发模块、主功能模块和关键信息模块,其中,触发模块用于在检测到异常时触发主功能模块,主功能模块负责执行防篡改功能,关键信息模块用于记录该防御节点的关键信息。Further, in the defense node template library in step 1, the implementation code of each defense node includes three parts: a trigger module, a main function module and a key information module, wherein the trigger module is used to Trigger the main function module, the main function module is responsible for performing the anti-tampering function, and the key information module is used to record the key information of the defense node.
进一步地,所述的步骤四中,构造目标节点与防御节点之间、防御节点与防御节点之间的关联关系的具体方法如下:Further, in step 4, the specific method of constructing the association relationship between the target node and the defense node and between the defense node and the defense node is as follows:
构造关联关系时,需要满足以下约束条件a至c:When constructing an association relationship, the following constraints a to c need to be met:
a.每个目标节点至少被一个防御节点J_Guard进行保护;a. Each target node is protected by at least one defense node J_Guard;
b.每个防御节点至少被除自身以外的两个防御节点J_Guard和N_Guard保护;b. Each defense node is protected by at least two defense nodes J_Guard and N_Guard except itself;
c.待保护的Android应用程序执行时,执行保护功能的防御节点必须能够在被保护节点执行时间附近及时执行;c. When the Android application program to be protected is executed, the defense node that performs the protection function must be able to execute it in time near the execution time of the protected node;
对于条件a,设置目标节点与至少一个具有函数保护功能的防御节点进行关联;For condition a, set the target node to associate with at least one defense node with function protection function;
对于条件b,对每个防御节点设置至少两个防御节点进行保护,其中一个为J_Guard,负责保护防御节点的触发模块,其中另一个为N_Guard,负责保护防御节点的主功能模块;For condition b, set at least two defense nodes for each defense node to protect, one of which is J_Guard, which is responsible for protecting the trigger module of the defense node, and the other is N_Guard, which is responsible for protecting the main function module of the defense node;
对于条件c,每个目标节点或防御节点在选择保护自己的防御节点时,应选择所述待保护的Android应用程序运行时与该目标节点或防御节点执行时间间隔前后较近的防御节点作为其防御节点;For condition c, when each target node or defense node selects the defense node to protect itself, it should select the defense node that is closer to the execution time interval between the Android application program to be protected and the target node or defense node when it is running. defense node;
具体地,Android应用程序的功能实现是由一个个函数构成的,当程序运行时,多个函数按照一定的时间顺序依次执行,这些函数组成了一个函数调用链,在同一个函数调用链中两个函数在执行时间上接近;记两个函数之间的函数个数称为跳数,则跳数越小,两个函数的执行间隔越短,因此每个目标节点或防御节点选择与其跳数最小的防御节点作为其防御节点。Specifically, the function realization of an Android application is composed of functions. When the program is running, multiple functions are executed sequentially according to a certain time sequence. These functions form a function call chain, and two functions in the same function call chain The two functions are close in execution time; the number of functions between two functions is called the number of hops, the smaller the number of hops, the shorter the execution interval between the two functions, so each target node or defense node chooses its hop number The smallest defense node acts as its defense node.
一种基于防御网的Android应用程序防篡系统,该系统包括依次连接的构造防御节点模板库模块、Android应用程序解析模块、生成目标节点集合模块、构造防御关联模块、生成对应防御节点实例模块、生成并初始化防御网模块和反编译、文件重构和签名模块;其中:A kind of anti-tampering system of Android application program based on the defense network, the system includes sequentially connected structure defense node template library module, Android application program parsing module, generation target node collection module, construction defense association module, generation corresponding defense node instance module, Generate and initialize the defense network module and decompilation, file reconstruction and signature modules; where:
构造防御节点模板库模块用于实现以下功能:The construction defense node template library module is used to realize the following functions:
防御节点为嵌入到待保护的Android应用程序中的代码段,用于监测篡改威胁并进行响应;构建防御节点模板库,模板库中存放防御节点的实现代码;The defense node is a code segment embedded in the Android application to be protected, which is used to monitor and respond to tampering threats; build a defense node template library, and store the implementation code of the defense node in the template library;
Android应用程序解析模块用于实现以下功能:The Android application analysis module is used to realize the following functions:
将待保护的Android应用程序进行解析,生成该待保护的Android应用程序的函数调用图,并对函数调用图中每一个节点进行描述;Analyzing the Android application program to be protected, generating a function call graph of the Android application program to be protected, and describing each node in the function call graph;
生成目标节点集合模块用于实现以下功能:Generate target node set module is used to realize the following functions:
在待保护的Android应用程序中,选取感兴趣的区域作为目标节点,并生成目标节点集合;In the Android application program to be protected, select the area of interest as the target node, and generate a target node set;
构造防御关联模块用于实现以下功能:The construction defense association module is used to realize the following functions:
构造目标节点与防御节点之间、防御节点与防御节点之间的关联关系;Construct the association relationship between the target node and the defense node, and between the defense node and the defense node;
生成对应防御节点实例模块用于实现以下功能:Generate the corresponding defense node instance module to achieve the following functions:
根据用户定义的防御节点种类和数据,在防御节点模板库中选择对应种类的防御节点的实现代码,生成对应的防御节点实例;According to the type and data of the defense node defined by the user, select the implementation code of the defense node of the corresponding type in the defense node template library, and generate the corresponding defense node instance;
生成并初始化防御网模块用于实现以下功能:Generate and initialize the defense network module to achieve the following functions:
根据构造的防御关联,结合生成的防御节点实例,进行防御网的初始化,该防御网包括防御节点和目标节点以及防御关联;According to the constructed defense association, combined with the generated defense node instance, the defense network is initialized, the defense network includes the defense node, the target node and the defense association;
反编译、文件重构和签名模块用于实现以下功能:Decompilation, file reconstruction and signature modules are used to implement the following functions:
对待保护的Android应用程序进行反编译、文件重构和签名。Decompile, file reconstruct and sign the Android application to be protected.
本发明与现有技术相比具有以下技术特点:Compared with the prior art, the present invention has the following technical characteristics:
1.可靠性高,防御网中API节点嵌套保护,无孤立节点,使得攻击者无法直接篡改关键代码段。另外,随机化使得每个应用内嵌的防御网结构不同,使得攻击者的攻击知识不能重复利用。1. High reliability, nested protection of API nodes in the defense network, no isolated nodes, making it impossible for attackers to directly tamper with key code segments. In addition, randomization makes the structure of the defense network embedded in each application different, so that the attacker's attack knowledge cannot be reused.
2.易于扩展,通过调节KeyValue预设值的大小,使得防御网的规模具有可控性,同时支持人工添加关键API,便于增强保护效果的多样性和复杂性。2. It is easy to expand. By adjusting the size of the preset value of KeyValue, the scale of the defense network is controllable. At the same time, it supports manual addition of key APIs to enhance the diversity and complexity of the protection effect.
3.低开销、高效率,保护方案的逻辑主要是通过执行效率高的native层实现,使得保护后软件增加的性能开销和空间开销很小。3. Low overhead and high efficiency. The logic of the protection scheme is mainly realized through the native layer with high execution efficiency, so that the performance overhead and space overhead added by the protected software are very small.
4.过程自动化,软件保护的整体处理流程固定、规范化,主要以自动化为主,辅以较少的人工参与,加上处理周期短,因此完全适用于大量应用的批处理保护。4. Process automation, the overall processing flow of software protection is fixed and standardized, mainly based on automation, supplemented by less manual participation, and the processing cycle is short, so it is completely suitable for batch processing protection of a large number of applications.
附图说明Description of drawings
图1为本发明方法的整体流程图;Fig. 1 is the overall flowchart of the inventive method;
图2是防御单元模版的结构示意图;Fig. 2 is a structural schematic diagram of a defense unit template;
图3是D_Guard节点中Java Hook实现原理示意图;Figure 3 is a schematic diagram of the implementation principle of Java Hook in the D_Guard node;
图4是本发明的防御网构造框架示意图;Fig. 4 is a schematic diagram of a defense network construction framework of the present invention;
图5防御单元间关联关系的示例图;Figure 5 is an example diagram of the association relationship between defense units;
图6是保护后APK重构过程示意图;Fig. 6 is a schematic diagram of the APK reconstruction process after protection;
图7为D_Guard的实现代码示意图。Figure 7 is a schematic diagram of the implementation code of D_Guard.
具体实施方式detailed description
一、方法具体步骤详述1. Detailed description of the specific steps of the method
遵从上述技术方案,如图1所示,本发明提供了一种基于防御网的Android应用程序防篡方法,包括以下步骤:Comply with above-mentioned technical scheme, as shown in Figure 1, the present invention provides a kind of anti-tampering method of Android application program based on defensive net, comprises the following steps:
步骤一,构造防御节点模板库Step 1: Construct the defense node template library
防御节点为嵌入到待保护的Android应用程序中的代码段,用于监测篡改威胁并进行响应;构建防御节点模板库,模板库中存放防御节点的实现代码;The defense node is a code segment embedded in the Android application to be protected, which is used to monitor and respond to tampering threats; build a defense node template library, and store the implementation code of the defense node in the template library;
本方案中的防御网,是指执行某种特定安全功能的网状结构,通常网状结构是由一组节点和连接节点的边组成,在本方案的防御网中,节点包括待保护的目标节点和执行防御功能的防御节点,连接防御节点的边即为这些节点间的保护关联。The defense network in this solution refers to a network structure that performs a specific security function. Usually, the network structure is composed of a group of nodes and edges connecting nodes. In the defense network of this solution, the nodes include the target to be protected Nodes and defense nodes that perform defense functions, and the edges connecting the defense nodes are the protection associations between these nodes.
防御节点是指针对指定目标执行特定防篡改保护的安全单元,是防御网的重要组成成员之一,通常会以代码段和数据的形式嵌入到被保护目标中,监测篡改威胁并进行响应。A defense node refers to a security unit that performs specific anti-tampering protection for a designated target. It is one of the important members of the defense network. It is usually embedded in the protected target in the form of code segments and data to monitor and respond to tampering threats.
防御节点除保护目标节点外,也需考虑保护其他防御节点,按照防御节点的组成和功能,进行防御节点的构建,并将构建好的防御节点的实现代码存储到防御节点模板库中:In addition to protecting the target node, the defense node also needs to consider protecting other defense nodes. According to the composition and function of the defense node, the defense node is constructed, and the implementation code of the constructed defense node is stored in the defense node template library:
在防御节点模板库中,每一种防御节点的实现代码均包括三部分:触发模块、主功能模块和关键信息模块,其中,触发模块用于在检测到异常时触发主功能模块,主功能模块负责执行防篡改功能,关键信息模块用于记录该防御节点的关键信息。In the defense node template library, the implementation code of each defense node includes three parts: a trigger module, a main function module and a key information module, wherein the trigger module is used to trigger the main function module when an abnormality is detected, and the main function module It is responsible for implementing the anti-tampering function, and the key information module is used to record the key information of the defense node.
本实施例中给出了三种存储在模板库中的防御节点的实现代码In this embodiment, the implementation codes of three defense nodes stored in the template library are given
本方案中共分为三类防御节点,因此防御节点模板库负责存放三类防御节点的基本实现代码,用于防御网构造时提供具体的防御节点并辅助完成初始化;这三类模板结构构成如下表1所示:This scheme is divided into three types of defense nodes. Therefore, the defense node template library is responsible for storing the basic implementation codes of the three types of defense nodes. It is used to provide specific defense nodes and assist in the initialization when the defense network is constructed. The structure of the three types of templates is as follows 1 shows:
表1模板库中三种防御节点结构描述Table 1 Description of the three defense node structures in the template library
如图2所示,考虑到Java层的逆向和篡改难度较低,本方案中使用C实现防御节点的主功能模块,并提供JNI接口供触发模块调用,这样增强了防御节点中关键功能的防篡改能力。As shown in Figure 2, considering that the Java layer is less difficult to reverse and tamper with, this solution uses C to implement the main function module of the defense node, and provides a JNI interface for the trigger module to call, which enhances the defense of key functions in the defense node. tamper ability.
本方案中,将这三类防御节点依次命名为J_Guard、N_Guard和D_Guard,下面对这三类防御节点的组成结构和具体实现进行详细介绍:In this scheme, these three types of defense nodes are named J_Guard, N_Guard, and D_Guard in turn. The composition structure and specific implementation of these three types of defense nodes are introduced in detail below:
(1)防御节点J_Guard模板(1) Defense node J_Guard template
J_Guard是指负责对Android应用指定Java代码段进行防篡改保护的安全单元。触发模块由Java代码(或smali代码)实现,负责触发主功能模块。通过插入到一个Java层函数体中实现与改Java函数的绑定,当Java函数执行时被执行。实现代码实例如下:J_Guard refers to the security unit responsible for anti-tampering protection of the specified Java code segment of the Android application. The trigger module is implemented by Java code (or smali code), and is responsible for triggering the main function module. By inserting into a Java layer function body to realize the binding with the Java function, it will be executed when the Java function is executed. The implementation code example is as follows:
在上述的实例中采用的是smali代码,对于能获取源码的待保护Android应用程序,可以直接在Java源码中插入触发模块。对于无法获取源码的待保护应用,可以对其反编译后将触发模块的smali实现代码插入到所得的smali代码文件中。In the above example, the smali code is used, and for the Android application program to be protected whose source code can be obtained, the trigger module can be directly inserted into the Java source code. For the application to be protected whose source code cannot be obtained, the smali implementation code of the trigger module can be inserted into the obtained smali code file after decompiling it.
主功能模块由C代码实现,负责执行防篡改功能,由Java层的触发模块进行触发。保护对象为一个Java层函数的代码。防篡改的实现基于对该Java函数的完整性校验。主要步骤概括为执行时抽取Java函数的字节码,并计算hash值,检测该hash值是否等于预定值。The main function module is implemented by C code, which is responsible for implementing the anti-tampering function and is triggered by the trigger module of the Java layer. The protected object is the code of a Java layer function. The realization of anti-tampering is based on the integrity verification of the Java function. The main steps are summarized as extracting the bytecode of the Java function during execution, calculating the hash value, and checking whether the hash value is equal to the predetermined value.
关键信息模块用于记录本单元的关键信息,这些信息会在防御网构造时被初始化。包括单元编号,绑定的Java函数ID,作用对象Java函数的ID以及该函数的校验值。The key information module is used to record the key information of this unit, which will be initialized when the defense network is constructed. Including the unit number, the ID of the bound Java function, the ID of the target Java function and the check value of the function.
(2)防御节点N_Guard模板(2) Defense node N_Guard template
防御节点N_Guard,是指负责对其他防御节点进行防篡改保护的安全单元,它主要针对的是所有防御节点的native函数部分。N_Guard也由触发模块、主功能模块、关键信息模块三部分组成。The defense node N_Guard refers to the security unit responsible for tamper-proof protection of other defense nodes, and it is mainly aimed at the native function part of all defense nodes. N_Guard is also composed of trigger module, main function module and key information module.
触发模块由Java实现,负责调用native层的主功能模块。它通过插入到一个Java层函数执行体中实现与该Java函数的绑定,随该Java函数执行时被触发。The trigger module is implemented by Java and is responsible for invoking the main function module of the native layer. It realizes the binding with the Java function by inserting into a Java layer function execution body, and is triggered when the Java function is executed.
主功能模块仍由C代码实现,负责执行防篡改功能。与J_Guard中的主功能模块不同,它的作用对象为一个native函数。The main function module is still implemented by C code, which is responsible for performing the anti-tampering function. Different from the main function module in J_Guard, its function object is a native function.
关键信息模块负责记录本单元的关键信息,这些信息包括单元编号,绑定的Java函数的ID,作用对象Native函数的ID及该函数校验值。The key information module is responsible for recording the key information of the unit, which includes the unit number, the ID of the bound Java function, the ID of the Native function of the target and the check value of the function.
(3)防御节点D_Guard模板(3) Defense node D_Guard template
防御节点D_Guard,是指负责对Android应用中的dex可执行文件进行防篡改保护的安全单元,由于所有的防御节点中触发模块均在dex中,因此通过对dex文件的防篡改保护,可以实现对防御节点触发模块的保护。The defense node D_Guard refers to the security unit responsible for tamper-proof protection of the dex executable file in the Android application. Since the trigger modules in all defense nodes are in the dex, the tamper-proof protection of the dex file can be realized. Defense node triggers module protection.
D_Guard同样由触发模块、主功能模块、关键信息模块三部分组成。其中,触发模块由Java代码实现,负责触发主功能模块,与J_Guard和N_Guard中的不同,它是通过替换Java函数中的一个Java API的调用而非直接插入实现与该Java函数的绑定,它随该Java函数执行时被触发。主功能模块由C代码实现,负责执行防篡改功能,以及执行被触发模块替换的Java API的功能。作用对象为APK中dex可执行文件。关键信息模块记录本单元的关键信息,这些信息包括单元编号,绑定的Java函数的ID,dex文件的校验值。D_Guard is also composed of trigger module, main function module and key information module. Among them, the trigger module is implemented by Java code, which is responsible for triggering the main function module. Unlike J_Guard and N_Guard, it realizes the binding with the Java function by replacing a Java API call in the Java function instead of directly inserting it. Triggered when the Java function is executed. The main function module is implemented by C code, and is responsible for performing the anti-tampering function, as well as the function of executing the Java API replaced by the trigger module. The object of action is the dex executable file in the APK. The key information module records the key information of the unit, which includes the unit number, the ID of the bound Java function, and the check value of the dex file.
主功能模块具有两部分内容,一是针对dex的防篡改保护,基于对dex文件的完整性校验实现。二是实现Java层被替换(Hook)的函数,如图3所示,实现的主要思路为利用Android JNI机制提供的native调用Java函数的方式,完成类似Java方法Hook的过程。利用这个过程,可以有效防止通过直接删除或替换so文件实现攻击。The main function module has two parts, one is the anti-tampering protection for dex, which is realized based on the integrity check of the dex file. The second is to implement the function of the Java layer being replaced (Hook), as shown in Figure 3, the main idea of the implementation is to use the native method provided by the Android JNI mechanism to call the Java function, and complete the process similar to the Java method Hook. Using this process can effectively prevent attacks by directly deleting or replacing so files.
经过长期对Android应用中Java层函数Hook的研究与实验,大部分Java函数均可以被Hook,表2列举了本方案中涉及到的Java函数。After long-term research and experiments on the Java layer function Hook in Android applications, most Java functions can be hooked. Table 2 lists the Java functions involved in this solution.
表2可Hook的Java函数列表Table 2 List of Hookable Java functions
以第一个函数Java/io/FileWriter/<init>为例,D_Guard的实现代码如图7所示:Taking the first function Java/io/FileWriter/<init> as an example, the implementation code of D_Guard is shown in Figure 7:
步骤二,解析待保护的Android应用程序Step 2, analyzing the Android application program to be protected
将待保护的Android应用程序进行解析,生成该待保护的Android应用程序的函数调用图,并对函数调用图中每一个节点进行描述;具体过程为:Analyze the Android application to be protected, generate a function call graph of the Android application to be protected, and describe each node in the function call graph; the specific process is:
图4是防御网构造示意图,如图中步骤(1)所示,构造防御网,首先会对输入的APK或其中的DEX文件进行解析,生成该应用的函数调用图,该函数调用图存储为一个文本文件,文件内容为一个列表,列表的每一项对应函数调用图中的一个函数节点,通过四元组<函数名,函数ID,前驱函数ID,后继函数ID>进行描述。Figure 4 is a schematic diagram of the structure of the defense network, as shown in step (1) in the figure, to construct the defense network, the input APK or the DEX file in it will be parsed first, and the function call graph of the application will be generated, and the function call graph will be stored as A text file, the file content is a list, each item in the list corresponds to a function node in the function call graph, and is described by the quaternion <function name, function ID, predecessor function ID, successor function ID>.
步骤三,生成目标节点集合Step 3, generate target node set
在待保护的Android应用程序中,选取感兴趣的区域作为目标节点,并生成目标节点集合;In the Android application program to be protected, select the area of interest as the target node, and generate a target node set;
本方案中,目标节点指的是目标应用软件中需要防篡改保护的一段区域,一般是一个函数或代码段。如图4中所示,步骤(2)表示在生成函数调用图后,根据函数调用图和待保护函数集合,生成目标节点集合。其中,待保护函数集合由用户定义,集合的每一项为该应用待保护的关键函数的函数名。生成的目标节点集合的每一项为待保护函数对应的函数ID。In this solution, the target node refers to an area in the target application software that needs tamper-proof protection, generally a function or a code segment. As shown in FIG. 4 , step (2) means that after the function call graph is generated, a target node set is generated according to the function call graph and the function set to be protected. Wherein, the function set to be protected is defined by the user, and each item in the set is a function name of a key function to be protected in the application. Each item in the generated target node set is a function ID corresponding to the function to be protected.
步骤四,构造防御关联Step 4, Construct Defense Association
构造目标节点与防御节点之间、防御节点与防御节点之间的关联关系;Construct the association relationship between the target node and the defense node, and between the defense node and the defense node;
如图4所示,步骤(3)表示输入步骤(1)(2)生成的函数调用图和目标节点集合,利用防御网构造算法结合中的算法,构造防御网内各节点间的关联关系。算法包括两类,一是构造目标节点与防御节点间关联的算法;二是构造防御节点与防御节点间关联的算法。由于步骤(3)中节点间关联关系构造具有一定的随机性,因此重复步骤(3)即可得到一组互不相同的关系集合。关系集合每一项表示为三元组<节点ID,触发点所在函数ID,对应防御节点ID>,以文本的形式存储在XML文件中。As shown in Figure 4, step (3) means inputting the function call graph and target node set generated in steps (1) and (2), using the algorithm in the combination of defense network construction algorithms to construct the association relationship between nodes in the defense network. Algorithms include two types, one is the algorithm for constructing the association between the target node and the defense node; the other is the algorithm for constructing the association between the defense node and the defense node. Since the construction of the association relationship between nodes in step (3) has a certain degree of randomness, a set of different relationship sets can be obtained by repeating step (3). Each item of the relationship set is expressed as a triplet <node ID, function ID of the trigger point, corresponding defense node ID>, which is stored in the XML file in the form of text.
提高防御节点安全性,可以从两方面进行。一是提高节点自身的逆向和篡改难度。在步骤一中,本方案利用Android JNI机制,将防御节点的核心功能代码从安全性较低的Java层通过C重写的方式迁移到逆向和篡改难度较高的native层。另一方面,可以通过构造防御网,在防御节点之间建立一定的关联关系,使得防御节点之间互相保护。所谓关联,就是在应用中选择合适的位置(函数体)进行防御节点部署的过程,或指在应用中已有的防御节点间构建保护关系的过程。Improving the security of defense nodes can be done from two aspects. One is to increase the difficulty of reverse and tampering of the node itself. In step 1, this solution uses the Android JNI mechanism to migrate the core function code of the defense node from the Java layer with lower security to the native layer with higher difficulty in reverse engineering and tampering through C rewriting. On the other hand, by constructing a defense network, a certain association relationship can be established between the defense nodes, so that the defense nodes can protect each other. The so-called association refers to the process of selecting a suitable location (function body) in the application to deploy the defense node, or refers to the process of building a protection relationship between existing defense nodes in the application.
防御网由两种节点构成,一是程序中需要保护的目标节点,记为g;另一种是执行保护功能的防御节点。节点间的关联关系,是指两个节点间的单向的保护关系,通常包括两类,第一类是由防御节点指向对应的目标节点,记为G->g;第二类是指由防御节点指向需要保护的其他防御节点,记为G->G’;防御网实例如图5所示,图中G表示防御节点,g表示目标节点,节点间的单向连线表示保护关系。The defense network is composed of two kinds of nodes, one is the target node that needs to be protected in the program, denoted as g; the other is the defense node that performs the protection function. The association relationship between nodes refers to the one-way protection relationship between two nodes, and usually includes two types. The first type refers to the defense node pointing to the corresponding target node, which is recorded as G->g; the second type refers to the The defense node points to other defense nodes that need to be protected, which is recorded as G->G'; the defense network example is shown in Figure 5, in which G represents the defense node, g represents the target node, and the one-way connection between nodes represents the protection relationship.
构造关联关系时,需要满足以下约束条件a至c:When constructing an association relationship, the following constraints a to c need to be met:
a.每个目标节点至少被一个防御节点J_Guard进行保护;a. Each target node is protected by at least one defense node J_Guard;
b.每个防御节点至少被除自身以外的两个防御节点J_Guard和N_Guard保护;b. Each defense node is protected by at least two defense nodes J_Guard and N_Guard except itself;
c.Android应用程序执行时,执行保护功能的防御节点必须能够在被保护节点执行时间附近及时执行;c. When the Android application program is executed, the defense node that executes the protection function must be able to execute in time near the execution time of the protected node;
对于条件a,防御网内的目标节点一般为Android应用中的一个自定义Java函数,设置目标节点与至少一个具有函数保护功能的防御节点(即J_Guard)进行关联;For condition a, the target node in the defense network is generally a custom Java function in the Android application, and the target node is set to associate with at least one defense node (i.e. J_Guard) with a function protection function;
对于条件b,根据步骤一中防御节点构造过程可知,每个防御节点的代码部分包括java层的触发模块和native层的主功能模块,因此为了防止防御节点代码被篡改,对每个防御节点设置至少两个防御节点进行保护,其中一个为J_Guard,负责保护防御节点的触发模块,其中另一个为N_Guard,负责保护防御节点的主功能模块;For condition b, according to the defense node construction process in step 1, the code part of each defense node includes the trigger module of the java layer and the main function module of the native layer. Therefore, in order to prevent the code of the defense node from being tampered with, set At least two defense nodes are protected, one of which is J_Guard, which is responsible for protecting the trigger module of the defense node, and the other is N_Guard, which is responsible for protecting the main function module of the defense node;
对于条件c,每个目标节点或防御节点在选择保护自己的防御节点时,需要考虑保护功能的响应及时性。所谓响应及时性,是指当被保护节点发生篡改时,对应的防御节点能及时的监测到该攻击并作出响应。因此,应选择所述待保护的Android应用程序运行时与该目标节点或防御节点执行时间间隔前后较近的防御节点作为其防御节点。For condition c, each target node or defense node needs to consider the response timeliness of the protection function when selecting the defense node to protect itself. The so-called response timeliness means that when the protected node is tampered with, the corresponding defense node can detect the attack and respond in time. Therefore, the defense node whose execution time interval between the Android application program to be protected and the target node or defense node is relatively close should be selected as its defense node.
根据构造关联关系的3个约束条件,对防御网的构造算法进行设计,具体设计与实现如下:According to the three constraints of constructing the association relationship, the construction algorithm of the defense network is designed, and the specific design and implementation are as follows:
假设应用中有M个目标节点,则每个目标节点g的入度(In-degree)至少为1,记为gIN(i)≥1,i∈M;Assuming that there are M target nodes in the application, the In-degree of each target node g is at least 1, which is recorded as g IN (i)≥1, i∈M;
假设应用中N个防御节点,则每个防御节点G的入度(In-degree)至少为2,其中对于每个入度,至少一个终点为J_Guard节点,至少一个终点为N_Guard节点,记为GIN(i)=GIN-JGuard(i)+GIN-NGuard(i)≥2,i∈N,其中GIN-JGuard(i)≥1andGIN-NGuard(i)≥1。三种防御节点中,除了D_Guard外,对于J_Guard和N_Guard节点,每个节点的出度(Out-degree)至少为1,记为GOUT(i)≥1,其中 Assuming that there are N defense nodes in the application, the in-degree of each defense node G is at least 2, wherein for each in-degree, at least one end point is a J_Guard node, and at least one end point is an N_Guard node, denoted as G IN (i)= GIN-JGuard (i)+ GIN-NGuard (i)≥2, i∈N , where GIN-JGuard(i)≥1 and GIN -NGuard (i)≥1. Among the three defense nodes, except for D_Guard, for J_Guard and N_Guard nodes, the Out-degree of each node is at least 1, which is recorded as G OUT (i)≥1, where
根据步骤一可知,对于D_Guard节点,会执行一种Hook函数,根据节点内Hook的Java函数不同,D_Guard具有不同的类型。因此,D_Guard节点的具体类型和数量与实际的被保护应用有关,同时该数量也可根据具体情况进行人工调节,例如应用中Java函数Java/io/FileWriter/<init>的调用点数目为20,若设置对应该函数的D_Guard数量上限为5,则只对原程序中的任意5处调用点进行Hook处理。According to step 1, for the D_Guard node, a Hook function will be executed, and D_Guard has different types according to the different Java functions of the Hook in the node. Therefore, the specific type and number of D_Guard nodes are related to the actual protected application, and the number can also be manually adjusted according to the specific situation. For example, the number of call points of the Java function Java/io/FileWriter/<init> in the application is 20, If the upper limit of the number of D_Guards corresponding to this function is set to 5, only any 5 calling points in the original program will be hooked.
对于如何满足约束条件c,本文提出了一种基于函数调用链的解决方式,方法如下:For how to satisfy the constraint c, this paper proposes a solution based on the function call chain, the method is as follows:
Android应用程序的功能实现是由一个个函数构成的,当程序运行时,多个函数按照一定的时间顺序依次执行,这些函数组成了一个函数调用链,在同一个函数调用链中两个函数在执行时间上接近;记两个函数之间的函数个数称为跳数,则跳数越小,两个函数的执行间隔越短,因此每个目标节点或防御节点选择与其跳数最小的防御节点作为其防御节点。The function realization of an Android application is composed of functions. When the program is running, multiple functions are executed sequentially according to a certain time sequence. These functions form a function call chain. In the same function call chain, two functions are in The execution time is close; the number of functions between two functions is called the number of hops, the smaller the number of hops, the shorter the execution interval between the two functions, so each target node or defense node chooses the defense with the smallest hops node as its defense node.
根据以上对3个约束条件的具体分析,防御网构造时的主要算法如下:According to the specific analysis of the above three constraints, the main algorithm for the construction of the defense network is as follows:
防御节点D_Guard的部署算法如下:The deployment algorithm of the defense node D_Guard is as follows:
对于防御节点间保护关系的建立,其关联算法如下:For the establishment of the protection relationship between defense nodes, the association algorithm is as follows:
步骤五,根据用户输入,生成对应防御节点实例Step 5: Generate corresponding defense node instances according to user input
根据用户定义的防御节点种类和数据,在防御节点模板库中选择对应种类的防御节点的实现代码,生成对应的防御节点实例;According to the type and data of the defense node defined by the user, select the implementation code of the defense node of the corresponding type in the defense node template library, and generate the corresponding defense node instance;
为了保证防御网具有良好的可扩展性,本文防御网构造方案允许通过改变防御节点数量来调节防御网的规模。图4步骤(4)表示根据用户定义的防御节点种类和数目,在防御节点模板库选择对应种类的防御节点的实现代码,生成对应的防御节点实例,实例的触发模块实现存储在.smali代码文件中,主功能模块实现和关键信息模块实现存储在.c后缀的代码文件中。In order to ensure good scalability of the defense network, the construction scheme of the defense network in this paper allows the scale of the defense network to be adjusted by changing the number of defense nodes. Step (4) in Figure 4 shows that according to the type and number of defense nodes defined by the user, the implementation code of the corresponding type of defense node is selected in the defense node template library, and the corresponding defense node instance is generated. The trigger module implementation of the instance is stored in the .smali code file In , the implementation of the main function module and the implementation of the key information module are stored in the code file with the .c suffix.
步骤六,生成并初始化防御网Step 6, generate and initialize the defense network
根据步骤四中构造的防御关联,结合步骤五中生成的防御节点实例,进行防御网的初始化,该防御网包括防御节点和目标节点以及防御关联;According to the defense association constructed in step 4, combined with the defense node instance generated in step 5, the defense network is initialized, and the defense network includes defense nodes, target nodes and defense associations;
如图4,步骤(5)表示结合步骤(3)得到的防御网内节点间关联关系集和步骤(4)生成的防御节点实例,进行防御网的初始化。具体初始化过程包括:首先会解析步骤(3)得到的一组节点关联关系集合,获取各节点编号,对应触发模块绑定函数ID,然后计算各防御节点对应保护目标的hash值,最后根据以上信息对步骤5中生成的.c文件中各防御节点实例的关键信息模块进行修改,并编译生成so库文件。As shown in Figure 4, step (5) represents the initialization of the defense network by combining the association relationship set between nodes in the defense network obtained in step (3) and the defense node instance generated in step (4). The specific initialization process includes: first, it will analyze a set of node association relationships obtained in step (3), obtain the number of each node, and the corresponding trigger module binding function ID, then calculate the hash value of each defense node corresponding to the protection target, and finally according to the above information Modify the key information modules of each defense node instance in the .c file generated in step 5, and compile and generate the so library file.
步骤七,对待保护的Android应用程序进行反编译、文件重构和签名。Step seven, decompiling, file reconstruction and signing of the Android application program to be protected.
利用反编译引擎APKTool或Baksmali,反编译待保护APK的dex文件,得到对应的smali代码文件;如图6所示,将防御节点smali指令填充到步骤7得到的smali文件夹下对应smali指令文件中,同时将so库文件植入步骤7中反编译源APK得到的文件夹libs中(若libs文件夹不存在则新建libs文件夹,APK结构参见文献11)。利用APKTool进行重构生成保护后的APK并对其签名.本发明默认利用Android源码提供的testkey.py8和testkey.x509.pem文件进行APK签名。同时也允许加载开发者的keystore进行APK签名。Use the decompilation engine APKTool or Baksmali to decompile the dex file of the APK to be protected to obtain the corresponding smali code file; as shown in Figure 6, fill the defense node smali command into the corresponding smali command file under the smali folder obtained in step 7 , and at the same time, implant the so library file into the folder libs obtained by decompiling the source APK in step 7 (if the libs folder does not exist, create a new libs folder, and see the document 11 for the APK structure). Use APKTool to reconstruct and generate the protected APK and sign it. The present invention uses the testkey.py8 and testkey.x509.pem files provided by the Android source code to sign the APK by default. It also allows loading the developer's keystore for APK signing.
本发明还提供了一种用于实现上述方法的系统:The present invention also provides a system for realizing the above method:
一种基于防御网的Android应用程序防篡系统,该系统包括依次连接的构造防御节点模板库模块、Android应用程序解析模块、生成目标节点集合模块、构造防御关联模块、生成对应防御节点实例模块、生成并初始化防御网模块和反编译、文件重构和签名模块;其中:A kind of anti-tampering system of Android application program based on the defense network, the system includes sequentially connected structure defense node template library module, Android application program parsing module, generation target node collection module, construction defense association module, generation corresponding defense node instance module, Generate and initialize the defense network module and decompilation, file reconstruction and signature modules; where:
构造防御节点模板库模块用于实现以下功能:The construction defense node template library module is used to realize the following functions:
防御节点为嵌入到待保护的Android应用程序中的代码段,用于监测篡改威胁并进行响应;构建防御节点模板库,模板库中存放防御节点的实现代码;The defense node is a code segment embedded in the Android application to be protected, which is used to monitor and respond to tampering threats; build a defense node template library, and store the implementation code of the defense node in the template library;
Android应用程序解析模块用于实现以下功能:The Android application analysis module is used to realize the following functions:
将待保护的Android应用程序进行解析,生成该待保护的Android应用程序的函数调用图,并对函数调用图中每一个节点进行描述;Analyzing the Android application program to be protected, generating a function call graph of the Android application program to be protected, and describing each node in the function call graph;
生成目标节点集合模块用于实现以下功能:Generate target node set module is used to realize the following functions:
在待保护的Android应用程序中,选取感兴趣的区域作为目标节点,并生成目标节点集合;In the Android application program to be protected, select the area of interest as the target node, and generate a target node set;
构造防御关联模块用于实现以下功能:The construction defense association module is used to realize the following functions:
构造目标节点与防御节点之间、防御节点与防御节点之间的关联关系;Construct the association relationship between the target node and the defense node, and between the defense node and the defense node;
生成对应防御节点实例模块用于实现以下功能:Generate the corresponding defense node instance module to achieve the following functions:
根据用户定义的防御节点种类和数据,在防御节点模板库中选择对应种类的防御节点的实现代码,生成对应的防御节点实例;According to the type and data of the defense node defined by the user, select the implementation code of the defense node of the corresponding type in the defense node template library, and generate the corresponding defense node instance;
生成并初始化防御网模块用于实现以下功能:Generate and initialize the defense network module to achieve the following functions:
根据构造的防御关联,结合生成的防御节点实例,进行防御网的初始化,该防御网包括防御节点和目标节点以及防御关联;According to the constructed defense association, combined with the generated defense node instance, the defense network is initialized, the defense network includes the defense node, the target node and the defense association;
反编译、文件重构和签名模块用于实现以下功能:Decompilation, file reconstruction and signature modules are used to implement the following functions:
对待保护的Android应用程序进行反编译、文件重构和签名。Decompile, file reconstruct and sign the Android application to be protected.
二、实验验证与分析2. Experimental verification and analysis
本方案中,将从保护方案的有效性、效率、可行性三个方面进行验证。In this plan, the effectiveness, efficiency and feasibility of the protection plan will be verified from three aspects.
1.保护方案有效性分析与验证1. Analysis and verification of the effectiveness of the protection scheme
本部分将基于DREAD风险分析模型(参考文献10),对保护前后应用面对同一篡改攻击时所面临的风险大小进行分析量化,通过两个风险值的对比,验证保护方案的有效性,即应用软件经保护后风险值降低,则表明保护方案增强了应用软件的安全性。Based on the DREAD risk analysis model (reference 10), this part will analyze and quantify the risk faced by the application before and after protection when facing the same tampering attack, and verify the effectiveness of the protection scheme by comparing the two risk values, that is, the application After the software is protected, the risk value decreases, which indicates that the protection scheme enhances the security of the application software.
DREAD模型是一种经典的安全威胁分析框架,由微软提出,用来对应用威胁进行风险分析、评估、量化,例如web应用设计时的安全性考虑等。DREAD算法通常会计算一个风险值,作为风险排序的参考,这个风险值是五个属性的平均值,包括:潜在危害性(DamagePotential),可重用性(Reproducibility),可利用性(Exploitability),受影响用户规模(Affected Users),隐蔽性(Discoverability),分别用缩写D,R,E,A,D表示,基于DREAM的风险值RiskValue计算公式如下:The DREAD model is a classic security threat analysis framework proposed by Microsoft to conduct risk analysis, assessment, and quantification of application threats, such as security considerations in web application design. The DREAD algorithm usually calculates a risk value as a reference for risk ranking. This risk value is the average value of five attributes, including: Damage Potential, Reproducibility, Exploitability, and Affected Users and Discoverability are represented by the abbreviations D, R, E, A, and D respectively. The calculation formula of RiskValue based on DREAM is as follows:
RiskValue=(D+R+E+A+D)/5 (1)RiskValue=(D+R+E+A+D)/5 (1)
由上面公式可知,RiskValue是一个0~10之间的数值,RiskValue值越高,代表威胁的风险越大It can be seen from the above formula that RiskValue is a value between 0 and 10, and the higher the RiskValue, the greater the risk of the threat
(1)保护前风险分析(1) Risk analysis before protection
(1-1)Damage Potential(1-1) Damage Potential
Damage Potential表示该威胁的潜在危害性,即当漏洞被利用后可能造成的危害的程度,表现为对应用内资产或敏感信息的可访问程度,以及获取的系统特权级别。程度可用0~10进行衡量,例如0表示无危害,5表示个别资产会受到危害,10表示整个应用或资产面临威胁。Damage Potential indicates the potential harm of the threat, that is, the degree of damage that may be caused when the vulnerability is exploited, expressed as the degree of access to in-app assets or sensitive information, and the obtained system privilege level. The degree can be measured from 0 to 10. For example, 0 means no harm, 5 means that individual assets will be compromised, and 10 means that the entire application or asset is threatened.
由于Android应用处于白盒攻击环境下,因此通过逆向可以使得应用的大部分代码和数据暴露给攻击者,同时攻击者很容易获取非法操作应用内的代码和数据的权限,进而干预应用的执行流程和业务逻辑。因此对于一般的Android应用,其篡改威胁的潜在危害性比较高,即D=6~8。Since the Android application is in a white-box attack environment, most of the code and data of the application can be exposed to the attacker through reverse engineering. At the same time, the attacker can easily obtain the permission to illegally operate the code and data in the application, and then interfere with the execution process of the application. and business logic. Therefore, for general Android applications, the potential harm of tampering threats is relatively high, that is, D=6-8.
(1-2)Reproducibility(1-2) Reproducibility
Reproducibility即可重用性,用来描述攻击者基于某威胁,对目标发动重复攻击过程的难度。可重用性的程度可用0~10衡量,例如0表示基本不能或很难重复攻击,5表示攻击者能重复攻击,但受到限制,例如次数、时间等。10表示攻击者可以任意的发动攻击,甚至自动化。Reproducibility is reusability, which is used to describe the difficulty of the attacker to launch repeated attacks on the target based on a certain threat. The degree of reusability can be measured from 0 to 10. For example, 0 means that it is basically impossible or difficult to repeat the attack, and 5 means that the attacker can repeat the attack, but it is limited, such as times and time. 10 means that the attacker can launch the attack arbitrarily, even automatically.
对Android应用进行篡改攻击,由于其攻击面,攻击过程和攻击手段基本固定,符合一定的模式,同时Android应用结构规整,因此攻击者重复攻击过程的难度较低,对于同一应用不同版本,甚至对不同Android应用也能进行自动化的攻击。另外,对于一般的Android应用,简单的保护并不能有效阻止攻击者重复攻击过程并累积攻击知识,最终完成攻击。因此对于一般的Android应用,篡改威胁的可重复性R=8~10。Tampering attacks on Android applications, because the attack surface, attack process and attack methods are basically fixed and conform to a certain pattern, and the structure of Android applications is regular, so it is relatively difficult for attackers to repeat the attack process. For different versions of the same application, even for Different Android applications can also carry out automated attacks. In addition, for general Android applications, simple protection cannot effectively prevent attackers from repeating the attack process and accumulating attack knowledge to finally complete the attack. Therefore, for general Android applications, the repeatability of tampering threats is R=8-10.
(1-3)Exploitability(1-3) Exploitability
Exploitability表示威胁的可利用性,即利用该威胁发动攻击的难易程度。可利用性程度用0~10衡量,例如0表示该威胁的成功利用需要丰富的攻击知识、技巧、攻击经验进行复杂的分析,同时需要特定的攻击工具或环境辅助;5表示基于一般的攻击技术或攻击经验,辅以常规的工具即可完成攻击;10表示具备基础攻击知识和部分攻击技术的初学者,在常规的攻击工具辅助下短时间内即可完成攻击。Exploitability indicates the availability of a threat, that is, the difficulty of using the threat to launch an attack. The degree of exploitability is measured on a scale of 0 to 10. For example, 0 means that the successful exploitation of the threat requires extensive attack knowledge, skills, and attack experience for complex analysis, as well as specific attack tools or environmental assistance; 5 means that it is based on general attack techniques. Or attack experience, supplemented by conventional tools to complete the attack; 10 means that beginners with basic attack knowledge and some attack techniques can complete the attack in a short time with the assistance of conventional attack tools.
近几年Android系统逐渐普及,其遭受篡改攻击的Android应用数量却呈现了爆炸式的增长,发动攻击的攻击者中,不仅有许多经验丰富的高级攻击者,更有许多初学者。造成这种情况的重要原因之一是因为学习在当前缺乏保护的Android应用上发动篡改攻击的难度不高,同时已经出现了大量的攻击工具,对于初学者来讲,其在短时间内就能掌握攻击方法,足以对一般的Android应用进行篡改。因此对于Android应用篡改威胁,其可利用性E=8~10。In recent years, the Android system has gradually become popular, but the number of Android applications subjected to tampering attacks has shown an explosive growth. Among the attackers who launch attacks, there are not only many experienced advanced attackers, but also many beginners. One of the important reasons for this situation is that it is not difficult to learn to launch tampering attacks on Android applications that currently lack protection. At the same time, a large number of attack tools have appeared. For beginners, they can be used in a short period of time. Mastering the attack method is enough to tamper with general Android applications. Therefore, for the Android application tampering threat, its exploitability E=8-10.
(1-4)Affected Users(1-4) Affected Users
Affected Users也是威胁的风险分析时的重要属性之一,它表示该威胁下影响的用户的规模。通常也用0~10进行衡量,数字越低,表示受影响的用户规模越小。Affected Users is also one of the important attributes in threat risk analysis, which indicates the scale of users affected by the threat. It is also usually measured on a scale of 0 to 10, and the lower the number, the smaller the number of affected users.
Android平台应用发布渠道众多,除了Google Play,用户还可以从360助手,豌豆荚等第三方应用商店下载应用,近年来,Android应用用户不断增长,截至到2015年第一季,仅国内的第三方手机应用商店的活跃用户规模已达到4.2亿[x]。在这些下载的应用中,不乏被篡改的应用,特别是在第三方应用商店中,同时,大多数应用面临被篡改的威胁,直接影响到下载安装这些应用的用户。因此,本文中A可取为8~10.There are many channels for releasing applications on the Android platform. In addition to Google Play, users can also download applications from third-party application stores such as 360 Assistant and Pea Pod. In recent years, the number of Android application users has continued to grow. As of the first quarter of 2015, only domestic third-party The scale of active users of mobile application stores has reached 420 million[x]. Among these downloaded applications, there are many applications that have been tampered with, especially in third-party application stores. At the same time, most applications face the threat of tampering, which directly affects the users who download and install these applications. Therefore, in this paper, A can be taken as 8-10.
(1-5)Discoverability(1-5) Discoverability
Discoverability即隐蔽性,具体是指对于目标应用,分析并定位产生该威胁的漏洞的难易程度。本文仍以0~10作为初始衡量范围,例如0代表很难分析代码或定位攻击点,5表示借助部分推理或调试可以跟踪到有效攻击点,10表示可直接获取可分析的代码并定位到关键篡改点。Discoverability is concealment, specifically referring to the difficulty of analyzing and locating the vulnerability that generates the threat for the target application. This article still uses 0 to 10 as the initial measurement range. For example, 0 means that it is difficult to analyze the code or locate the attack point, 5 means that the effective attack point can be traced with the help of partial reasoning or debugging, and 10 means that the analyzable code can be directly obtained and the key point can be located. tamper point.
对于大多数Android应用而言,其主要由Java编译生成,利用逆向工具可以很容易的获取具有良好可读性的代码,例如Java代码或者smali代码。同时,利用现有的工具,例如DDMS,Android Studio等,可以很容易的实现Java层或者smali层的动态调试,因此,本文取D=6~8,表示可以较容易的获取程序代码并进行分析调试,从而定位篡改点。For most Android applications, which are mainly compiled and generated by Java, it is easy to obtain codes with good readability, such as Java codes or smali codes, by using reverse tools. At the same time, using existing tools, such as DDMS, Android Studio, etc., it is easy to implement dynamic debugging of the Java layer or smali layer. Therefore, this paper takes D=6~8, which means that the program code can be easily obtained and analyzed Debugging to locate the point of tampering.
(2)保护后风险分析(2) Risk analysis after protection
对于潜在危害性(Damage Potential)方面,虽然保护方案并不阻止攻击者针对Android APK的逆向分析,然而D_Guard节点的主功能模块对原程序中的部分Java调用进行了接管,因此对Java层的部分执行逻辑进行了隐藏,增大了攻击者的分析难度,降低了篡改威胁的潜在危害性。In terms of potential harm (Damage Potential), although the protection scheme does not prevent attackers from reverse-analyzing the Android APK, the main function module of the D_Guard node takes over some Java calls in the original program, so part of the Java layer The execution logic is hidden, which increases the difficulty of analysis for attackers and reduces the potential harm of tampering threats.
对于可重用性(Reproducibility)方面,由于每个节点受到多个且多类防御节点的保护,使得攻击者无法采用单一的攻击方法,对重复攻击的次数和效果进行了限制。In terms of reproducibility, because each node is protected by multiple and multi-type defense nodes, the attacker cannot use a single attack method, and the number and effect of repeated attacks are limited.
对于可利用性(Exploitability)方面,保护后的应用中防御网具有篡改感知和响应功能,且防御节点间相互保护,因此完成攻击需要首先分析出防御网的整体结构,这需要攻击者具备较高的逆向分析经验和花费较长的时间。Regarding the exploitability (Exploitability), the defense network in the protected application has the function of tamper perception and response, and the defense nodes protect each other. Therefore, to complete the attack, the overall structure of the defense network needs to be analyzed first, which requires the attacker to have advanced Experience in reverse analysis and takes a long time.
对于用户规模(Affected Users)方面,保护后的应用能有效防止攻击者篡改,因此从源头上避免了应用程序篡改版本的产生,因此降低了篡改威胁所造成的影响。In terms of the scale of users (Affected Users), the protected application can effectively prevent attackers from tampering, thus avoiding the generation of tampered versions of the application from the source, thus reducing the impact of tampering threats.
对于隐蔽性(Discoverability)方面,对于单个防御节点,构成节点的模块分散到不同运行空间,即java层和native层,增强了程序中关键信息和代码的定位难度,提高了隐蔽性。In terms of discoverability, for a single defense node, the modules that make up the node are scattered into different operating spaces, namely the java layer and the native layer, which increases the difficulty of locating key information and codes in the program and improves the concealment.
结合以上分析,保护前后应用的篡改威胁风险值如下表所示:Based on the above analysis, the tampering threat risk value of the application before and after protection is shown in the following table:
表3保护前后篡改威胁风险值列表Table 3 List of tampering threat risk values before and after protection
显然,保护后的应用的篡改威胁风险小于保护前应用的风险,验证了本发明中保护方案的有效性。Obviously, the tamper threat risk of the protected application is less than that of the unprotected application, which verifies the effectiveness of the protection scheme in the present invention.
2.保护方案效率实验验证2. Experimental verification of protection scheme efficiency
为了验证保护方案的效果,本文同时选择了当前两款主流的加固商对实验对象进行加固,并在软件大小,启动时间两个方面对加固后的应用进行测试和对比,软件大小对比如下:In order to verify the effect of the protection scheme, this article also selects two current mainstream hardening providers to harden the experimental objects, and tests and compares the hardened applications in terms of software size and startup time. The software size comparison is as follows:
表4保护前后应用软件大小对比数据(KB)Table 4 Comparison data of application software size before and after protection (KB)
从上表中可知,相较于成熟的商业加固商,本发明中的防御网保护方案,对待保护软件带来的大小开销较小,处于可接受的范围。It can be seen from the above table that, compared with mature commercial reinforcement providers, the defense network protection scheme in the present invention has less overhead for the software to be protected, which is within an acceptable range.
启动时间测试:本文对原始应用、防御网保护后的、Bangcle保护后的、360保护后的应用的启动时间进行测试,从启动速度方面验证保护方案对应用带来的性能开销大小,本文中每个样本应用测试100次并计算其平均启动时间,对比数据如下:Startup time test: This article tests the startup time of the original application, the application protected by the defense network, the application protected by Bangcle, and the application protected by 360, and verifies the performance overhead brought by the protection scheme to the application from the perspective of startup speed. A sample application is tested 100 times and its average startup time is calculated. The comparison data are as follows:
表5保护前后应用软件启动时间评测数据(ms)Table 5 Application software startup time evaluation data before and after protection (ms)
从上表可知,与成熟的商业加固商对比,本发明的基于防御网的保护方案对目标应用所造成的性能开销更小。It can be seen from the above table that compared with mature commercial reinforcement providers, the protection scheme based on the defense network of the present invention causes less performance overhead on the target application.
3.保护方案的可行性(兼容性)验证:3. Feasibility (compatibility) verification of the protection scheme:
由于Android系统版本较多,版本之间的差异对应用正常运行所造成的影响决定了保护方案可行性的高低,因此,为了验证保护方案的可行性,本文中选择了5种主流的Android系统版本用于测试应用是否兼容,测试结果如下表:Due to the large number of Android system versions, the impact of the difference between versions on the normal operation of the application determines the feasibility of the protection scheme. Therefore, in order to verify the feasibility of the protection scheme, five mainstream Android system versions are selected in this paper. It is used to test whether the application is compatible, and the test results are as follows:
表6保护后应用兼容性测试数据Table 6 Application compatibility test data after protection
从上表可知,经过本专利中保护方案保护后的应用在主流的Android系统版本上可以正常执行,因此基于防御网的保护方案具有良好的兼容性和可行性。It can be seen from the above table that the applications protected by the protection scheme in this patent can be executed normally on mainstream Android system versions, so the protection scheme based on the defense network has good compatibility and feasibility.
Claims (4)
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201510846522.8A CN105468970B (en) | 2015-11-27 | 2015-11-27 | A kind of Android application programs based on protection net are anti-to usurp method and system |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201510846522.8A CN105468970B (en) | 2015-11-27 | 2015-11-27 | A kind of Android application programs based on protection net are anti-to usurp method and system |
Publications (2)
| Publication Number | Publication Date |
|---|---|
| CN105468970A CN105468970A (en) | 2016-04-06 |
| CN105468970B true CN105468970B (en) | 2018-01-19 |
Family
ID=55606656
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN201510846522.8A Expired - Fee Related CN105468970B (en) | 2015-11-27 | 2015-11-27 | A kind of Android application programs based on protection net are anti-to usurp method and system |
Country Status (1)
| Country | Link |
|---|---|
| CN (1) | CN105468970B (en) |
Families Citing this family (5)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN106095667B (en) * | 2016-06-03 | 2018-08-10 | 西北大学 | A kind of corresponding method for driving document location of quick positioning Android sensitive functions |
| CN106648835B (en) * | 2016-12-26 | 2020-04-10 | 武汉斗鱼网络科技有限公司 | Method and system for detecting running of Android application program in Android simulator |
| CN111143853B (en) * | 2019-12-25 | 2023-03-07 | 支付宝(杭州)信息技术有限公司 | Application security assessment method and device |
| CN114301700B (en) * | 2021-12-31 | 2023-09-08 | 上海纽盾科技股份有限公司 | Method, device, system and storage medium for adjusting network security defense scheme |
| CN116522343B (en) * | 2023-07-05 | 2023-09-08 | 北京国御网络安全技术有限公司 | Native function attack defending method and device |
Citations (2)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN102779257A (en) * | 2012-06-28 | 2012-11-14 | 奇智软件(北京)有限公司 | Security detection method and system of Android application program |
| US8804608B1 (en) * | 2010-09-29 | 2014-08-12 | Lockheed Martin Corporation | Methods, apparatus, and systems for facilitating audio communications between disparate devices |
-
2015
- 2015-11-27 CN CN201510846522.8A patent/CN105468970B/en not_active Expired - Fee Related
Patent Citations (2)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US8804608B1 (en) * | 2010-09-29 | 2014-08-12 | Lockheed Martin Corporation | Methods, apparatus, and systems for facilitating audio communications between disparate devices |
| CN102779257A (en) * | 2012-06-28 | 2012-11-14 | 奇智软件(北京)有限公司 | Security detection method and system of Android application program |
Non-Patent Citations (1)
| Title |
|---|
| Protecting Software Code by Guards;Chang H, Atallah M J;《Lecture Notes in Computer Science》;20021231(第2320期);160-175 * |
Also Published As
| Publication number | Publication date |
|---|---|
| CN105468970A (en) | 2016-04-06 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| US10951647B1 (en) | Behavioral scanning of mobile applications | |
| Zhou et al. | AppInk: watermarking android apps for repackaging deterrence | |
| US12316656B2 (en) | Detecting repackaged applications based on file format fingerprints | |
| Canfora et al. | Leila: formal tool for identifying mobile malicious behaviour | |
| Schmidt et al. | Smartphone malware evolution revisited: Android next target? | |
| Han et al. | Comparing mobile privacy protection through cross-platform applications | |
| Neuner et al. | Enter sandbox: Android sandbox comparison | |
| Faruki et al. | Evaluation of android anti-malware techniques against dalvik bytecode obfuscation | |
| CN105468970B (en) | A kind of Android application programs based on protection net are anti-to usurp method and system | |
| Bai et al. | Towards model checking android applications | |
| Luo et al. | Repackage-proofing android apps | |
| CN103714292B (en) | A kind of detection method of vulnerability exploit code | |
| CN104537309A (en) | Application program bug detection method, application program bug detection device and server | |
| Cimitile et al. | Formal methods meet mobile code obfuscation identification of code reordering technique | |
| CN106326737A (en) | System and method for detecting harmful files executable on a virtual stack machine | |
| Faruki et al. | Droidanalyst: Synergic app framework for static and dynamic app analysis | |
| Song et al. | Appis: Protect android apps against runtime repackaging attacks | |
| Armando et al. | Enabling BYOD through secure meta-market | |
| CN117118661A (en) | Closed source attack contract automatic identification method, system and equipment based on fuzz testing | |
| Kandukuru et al. | Android malicious application detection using permission vector and network traffic analysis | |
| Hu et al. | Robust app clone detection based on similarity of ui structure | |
| Zhang et al. | Android malware detection combined with static and dynamic analysis | |
| Aysan et al. | Analysis of dynamic code updating in Android with security perspective | |
| Yuan et al. | Scalable and obfuscation-resilient android app repackaging detection based on behavior birthmark | |
| Niu et al. | Clone analysis and detection in android applications |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| C06 | Publication | ||
| PB01 | Publication | ||
| C10 | Entry into substantive examination | ||
| SE01 | Entry into force of request for substantive examination | ||
| GR01 | Patent grant | ||
| GR01 | Patent grant | ||
| CF01 | Termination of patent right due to non-payment of annual fee | ||
| CF01 | Termination of patent right due to non-payment of annual fee |
Granted publication date: 20180119 Termination date: 20201127 |