WO2023045744A1 - Reinforcement method, registration method, running method, electronic device and storage medium - Google Patents

Reinforcement method, registration method, running method, electronic device and storage medium Download PDF

Info

Publication number
WO2023045744A1
WO2023045744A1 PCT/CN2022/117070 CN2022117070W WO2023045744A1 WO 2023045744 A1 WO2023045744 A1 WO 2023045744A1 CN 2022117070 W CN2022117070 W CN 2022117070W WO 2023045744 A1 WO2023045744 A1 WO 2023045744A1
Authority
WO
WIPO (PCT)
Prior art keywords
hidden
protected application
application
smc
shell program
Prior art date
Application number
PCT/CN2022/117070
Other languages
French (fr)
Chinese (zh)
Inventor
李晖
陈明翔
刁亮
杨超锋
张文
许人杰
Original Assignee
中兴通讯股份有限公司
北京邮电大学
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by 中兴通讯股份有限公司, 北京邮电大学 filed Critical 中兴通讯股份有限公司
Publication of WO2023045744A1 publication Critical patent/WO2023045744A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/10Protecting distributed programs or content, e.g. vending or licensing of copyrighted material ; Digital rights management [DRM]
    • G06F21/12Protecting executable software
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/60Protecting data
    • G06F21/62Protecting access to data via a platform, e.g. using keys or access control rules

Definitions

  • the embodiments of the present disclosure relate to the field of computers, and in particular to a reinforcement method, a registration method, an operation method, electronic equipment, and a storage medium.
  • the third-generation shell represented by the virtual execution shell has greatly increased the difficulty of unpacking and cracking, but after a long period of research, the third-generation shell still cannot avoid the result of being unpacked. From this point of view, no matter how complex and tiny the software shell is designed, after a long period of research, it will still be cracked and become invalid, that is, the security of the shell program protection is low.
  • the main purpose of the embodiments of the present disclosure is to provide a reinforcement method, a registration method, an operation method, an electronic device and a storage medium, so that the security of the shell program protection can be improved.
  • the embodiment of the present disclosure provides a hardening method applied to the server, including: determining the object to be hidden in the first shell program of the protected application; determining the security monitoring mode call corresponding to the object to be hidden smc instruction; replace the object to be hidden with the smc instruction corresponding to the object to be hidden, and obtain the second shell program after reinforcement; according to the second shell program after reinforcement, the application package APK of the protected application is reinforced to obtain reinforcement After the APK.
  • an embodiment of the present disclosure also provides a registration method applied to a terminal, including: after detecting that an APK is installed, determining whether the protected application corresponding to the APK is in the trusted application TA of the secure world SW Registered; wherein, APK is the hardened APK obtained by any one of the above hardening methods; if the protected application is not registered in the trusted application TA of the secure world SW, register the protected application in the TA of the SW.
  • an embodiment of the present disclosure also provides an operation method for running the protected application registered by the above registration method.
  • the method includes: during the running of the protected application, when the TA in the secure world SW When receiving the smc instruction of the protected application, determine the object to be hidden corresponding to the smc instruction; execute the object to be hidden in the TA of the secure world SW according to the semantics represented by the object to be hidden.
  • an embodiment of the present disclosure further provides an electronic device, including: at least one processor; and a memory connected to the at least one processor in communication; wherein, when the electronic device is a server , the memory stores instructions executable by the at least one processor, the instructions are executed by the at least one processor, so that the at least one processor can execute the above-mentioned strengthening method; in the electronic device In the case of a terminal, the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor, so that the at least one processor can execute the above registration method, Or execute the above-mentioned running method.
  • an embodiment of the present disclosure also provides a computer-readable storage medium, which stores a computer program.
  • the computer program is executed by a processor, the above-mentioned hardening method is realized, or any of the above-mentioned registration methods is realized, or the above-mentioned method of operation.
  • Fig. 1 is a flowchart of a strengthening method according to an embodiment of the present disclosure.
  • Fig. 2 is a flow chart of calling an smc instruction in a hardening method according to an embodiment of the present disclosure.
  • Fig. 3 is a schematic diagram of a hiding method according to an embodiment of the present disclosure.
  • FIG. 4 is a schematic diagram of a server reinforcement process according to an embodiment of the present disclosure.
  • Fig. 5 is a schematic diagram of a terminal system structure in an embodiment of the present disclosure:
  • FIG. 6 is a flowchart of a registration method in another embodiment of the present disclosure.
  • FIG. 7 is a flow chart of an operating method in another embodiment of the present disclosure.
  • FIG. 8 is a schematic diagram of an electronic device in another embodiment of the present disclosure.
  • TrustZone proposed by ARM divides processor resources into Normal World (NW) and Secure World (SW).
  • NW Normal World
  • SW Secure World
  • This hardware isolation mechanism provides a solid hardware foundation for the development of Trust Execution Environment (TEE).
  • TEE Trust Execution Environment
  • the shell program of TEE Under the situation that pure software protection faces the threat of attack, it is necessary to protect the shell program of TEE, and the main target of protection is the original code (native code) of the shell program, that is, the so file (also known as shell.so file).
  • An embodiment of the present disclosure provides a hardening method, which is applied to the server.
  • the implementation details of the hardening method in this embodiment are described in detail below. The following content is only the implementation details provided for easy understanding, and is not the implementation of this solution. must.
  • the application scenarios of the embodiments of the present disclosure may include but not limited to the software shell program protection of TEE, and the strengthening method includes: determining the object to be hidden in the first shell program of the protected application; determining the security monitoring mode call corresponding to the object to be hidden smc instruction; replace the object to be hidden with the smc instruction corresponding to the object to be hidden, and obtain the second shell program after reinforcement; according to the second shell program after reinforcement, the application package APK of the protected application is reinforced to obtain reinforcement After the APK.
  • the first shell program can be understood as the original shell program
  • the second shell program can be understood as the shell program after strengthening the original shell program.
  • the specific flow of the reinforcement method in this embodiment may be shown in FIG. 1 .
  • Step 101 Determine the object to be hidden in the first shell program of the protected application
  • all logic hidden objects in the first shell program may be determined according to the user's expected security and performance consumption evaluation.
  • the object to be hidden can be a logic hidden object in the first shell program shell.so file of the protected application, and the object to be hidden can be understood as: when the first shell program attacker attacks the first shell program, if these If all objects to be hidden are cracked and analyzed clearly, the first shell program may be completely cracked, that is, the object to be hidden is an object that is crucial to the first shell program and can be protected from being cracked by hiding protection.
  • the object to be hidden includes any one or combination of the following, for example, key instructions, key code fragments, and key functions in the first shell program.
  • the key instructions include memory read and write instructions, control flow transfer instructions, general register operation instructions and other instructions with relatively clear semantics
  • the key code fragment can be a small piece of assembly code, for example, a few lines of code, a few instructions, this A small piece of assembly code can make the CPU register conversion more clear, that is, the key code segment can be understood as a code segment with clear semantics
  • the key function is relatively the largest, and can include thousands of instruction code segments.
  • the object to be hidden may also be an instruction, a code segment, a function, etc. in a shell program preset by those skilled in the art and desired to be protected according to actual needs.
  • the preset instructions, code fragments, and functions in the shell program to be protected can be respectively used as the above-mentioned key instructions, key code fragments, and key functions.
  • Step 102 determine the security monitoring mode corresponding to the object to be hidden and call the smc command
  • the server can obtain the correspondence between the object to be hidden in the first shell program of the protected application according to the mapping relationship between the pre-stored object to be hidden and the call command of the security monitoring mode (Secure Monitor Call, referred to as smc for short).
  • the smc command can obtain the correspondence between the object to be hidden in the first shell program of the protected application according to the mapping relationship between the pre-stored object to be hidden and the call command of the security monitoring mode (Secure Monitor Call, referred to as smc for short).
  • the smc command can obtain the correspondence between the object to be hidden in the first shell program of the protected application according to the mapping relationship between the pre-stored object to be hidden and the call command of the security monitoring mode (Secure Monitor Call, referred to as smc for short).
  • determining the security monitoring mode corresponding to the object to be hidden and calling the smc instruction can be implemented by the sub-steps shown in Figure 2, specifically including:
  • Step 1021 Obtain the feature information of the protected application and the identity of the object to be hidden;
  • the characteristic information of the protected application may be a package name pkg_name, an application version number, and the like.
  • the server can calculate the hash value for the object to be hidden according to the type and offset information of all objects to be hidden, and convert it into hexadecimal as the hidden point label, and each hidden point label is the hash value of each object to be hidden A unique identifier, wherein the offset information of the object to be hidden is an offset relative to the first line of native code of the shell program.
  • the type of object to be hidden can include: key instructions, key code fragments and key functions.
  • key instructions in Figure 4 include: str x1, x2, ldr x3, x4; key code fragments include: mov x0, x7str x1, [x0 ]ldr x2, x3 key functions include: key_func().
  • Step 1022 According to the feature information, generate a first mapping relationship between the identity of the object to be hidden and the confusion parameter;
  • the server can input the characteristic information of the protected application (such as the package name pkg_name, the application version number) into the random algorithm as a random factor, and generate a random obfuscation parameter a for each object to be hidden to cover up the real label.
  • the set of obfuscation parameters corresponding to the identities of all objects to be hidden is mapping A.
  • This set is an injective set, that is, the identity of an object to be hidden corresponds to only one obfuscation parameter.
  • the mapping between the identity of an object to be hidden and the obfuscation parameter is A mapping relationship.
  • the identity of the object to be hidden that is, the labels of each hidden point are Ox3D456F7B, 0x2AB35732, 0x3F5F7AOCD, 0x80848EAF, 0Xea206721
  • the confusion parameter set A is ⁇ 76, 24, 12, 33, 89 ⁇
  • the mapping between each hidden point label and the elements of the confusion parameter set A is a one-to-one correspondence
  • one hidden point label corresponds to one confusion parameter, for example, the mapping of Ox3D456F7B is 76.
  • a second mapping relationship may also be generated according to the first mapping relationship; wherein, the second mapping relationship is the same as the first mapping relationship
  • the first mapping relationship is a reverse mapping to each other; the trusted application TA is generated to simulate and execute the logic code of the object to be hidden, that is, the handler code;
  • the hash value and logic code generate the trusted application TA image corresponding to the protected application, and compile the TA image into the terminal operating system.
  • An input for generating the TA image can be regarded as the second mapping relationship.
  • the generated TA image will be compiled into the terminal operating system, which will help prevent the TA image corresponding to the protected application from being attacked and ensure that the relevant information contained in the TA image (Part 1) Two-mapping relationship, hash value of non-hidden code interval and logic code) security.
  • the TA image in the operating system facilitates subsequent registration of protected applications or running protected applications in TA to obtain relevant information. For example, the hash value of the non-hidden code interval (shared information ), verify that the hardened second shell program shell.so has not been tampered with.
  • the second mapping relationship is used in the process of running the protected application to obtain the object to be hidden corresponding to the obfuscation parameter.
  • Step 1023 According to the first mapping relationship, determine the smc instruction corresponding to the obfuscation parameter mapped from the identity of the object to be hidden.
  • step 1022 obtains the mapping relationship between hidden point labels and confusing parameters
  • the selected objects to be hidden in the shell.so are replaced with smc instructions respectively, and the replaced smc instruction format is: [smc hash(pkg_name) , a].
  • hash (pkg_name) is the hash value of the characteristic information of the protected application, that is, the hash value of the package name, and a segment of the general register size (such as the first 64 bits of the arm64-v8a architecture processor) is used as a parameter of the smc command
  • a is a confusing parameter, which is another parameter of the smc command.
  • the parameters of the smc command are fixed at 64 bits. If the hash value is not calculated, an app package name may be very long, which does not match the parameter length of the smc command. Therefore, it is necessary to take a fragment of the size of a general register (such as the first 64bit for an arm64-v8a architecture processor), and use the hash value to convert the app package name of different lengths into a fixed length, for example, take 64 bits from the fixed length as a hash (pkg_name).
  • the smc instruction corresponding to the object to be hidden can be determined in the manner shown in Fig. , so the obfuscation parameters of each output must be different theoretically. Therefore, it is beneficial to increase the difficulty of cracking the corresponding relationship between the object to be hidden and the smc instruction, and improve the security of the second shell program after reinforcement.
  • Step 103 replacing the object to be hidden with the smc command corresponding to the object to be hidden, to obtain the second shell program after reinforcement;
  • the object to be hidden is the key instruction in the first shell program shell.so file, and the key instruction in the original shell.so file is [str x1, x2], then the replaced The smc command is [smc app, 76]; if the object to be hidden is the key code segment in the first shell program shell.so file, the key code segment in the original shell.so file is [mov x0, x7str x1, [x0]ldr x2x3], then the replaced smc command is [smc app, 31]; if the object to be hidden is the key function in the first shell program shell.so file, the key function in the original shell.so file is [key_fun1()], Then the replaced smc instruction is [smc app, 35].
  • the instructions in the original shell.so file are executed in NW, and the replaced smc instructions are executed in SW.
  • Step 104 According to the second hardened shell program, harden the application package APK of the protected application to obtain the hardened APK.
  • the server carries out subsequent shelling and hardening processes according to the hardened second shell program shell.so file, and finally outputs a hardened Android application package (Android application package, referred to as APK).
  • APK is the installation package of the Android application
  • the shell program is the software used to protect the APK. In this embodiment, it mainly protects the shell program.
  • the protection shell program can also be understood as a reinforced shell program, so that the reinforced second shell can be reused. The program then hardens the APK of the protected application.
  • the non-hidden code interval between adjacent objects to be hidden in the first shell program of the protected application calculates the hash value of the non-hidden code interval, and use the hash value as the server and the shared information between terminals registering the protected application; when compiling the trusted application (Trust Application, TA for short) of the secure world SW, the shared information is compiled into the operating system of the terminal, wherein the shared information is used for The terminal verifies the security of the protected application when registering the protected application. That is to say, the non-hidden code intervals in the object to be hidden are all unsubstituted code intervals in the shell.so file. As shown in FIG.
  • all unsubstituted code intervals in the shell.so file are the blank spaces, that is, all unsubstituted code intervals in the shell.so file, that is, non-hidden code intervals. Calculate the hash value of each non-hidden code interval, and use the hash value as the shared information between the server and the registered protected app. When the server compiles the TA in the SW, it compiles the shared information into the operating system.
  • the attacker After the logical hidden object in the first shell program shell.so file is replaced, except for the part replaced with the smc command, the rest of the first shell program shell.so file will no longer change. Therefore, after determining the smc instruction of shell.so, count the code intervals of all unchanged parts (that is, non-hidden code intervals) and calculate the hash value of each interval, and input the hash value data of these unchanged intervals during compiling TA As the shared information of the server and the terminal, the attacker cannot obtain this secret. Utilizing the shared information allows the protected app to perform an initial integrity check during the registration phase, which is beneficial to prevent the attacker's shell program shell.so from spoofing attacks.
  • the reinforcement method provided by the embodiment of the present disclosure first determines the object to be hidden in the first shell program of the protected application; determines the smc command corresponding to the object to be hidden; replaces the object to be hidden with the smc command corresponding to the object to be hidden, The hardened second shell program; the object to be hidden in the first shell program is replaced, that is, the object to be hidden in the first shell program is hidden, and there is no complete semantic information, which can completely prevent the static analysis of the shell program by the attacker .
  • the embodiments of the present disclosure can also greatly increase the difficulty of the attacker's dynamic analysis of the shell program, because the attacker can only debug the shell program in the NW, and analyze the changes of the entire processor state and memory space before and after the smc command. Under the premise of the current terminal's processor complexity and large memory space, this search space is very large, and subsequent logical analysis is even more difficult. Therefore, the hardened second shell program obtained in the embodiment of the present disclosure is extremely difficult to be attacked, which can improve the security of the shell program protection.
  • the APK of the protected application is reinforced by using the reinforced second shell program to obtain the reinforced APK, thereby improving the security of using the reinforced second shell program to protect the APK.
  • An embodiment of the present disclosure also provides a registration method, which is applied to a terminal, and specifically includes: after detecting that an APK is installed, determining whether the protected application corresponding to the APK is registered in the trusted application TA of the secure world SW; , the APK is a hardened APK obtained based on the hardening method of the above embodiment; if the protected application is not registered in the trusted application TA of the secure world SW, register the protected application in the TA of the SW.
  • the terminal system has two states: normal world (Normal Word, NW for short) and secure world (Secure Word, SW for short), both of which have their own independent registers, that is, the environment of the CPU.
  • the CPU can only be in one state at a time. For example, when running in the NW state, the NW register is used, and when the CPU is running in the SW state, the SW register is used.
  • the NW register and the SW register are independent and isolated from each other.
  • Both the reinforcement agent and the reinforcement TA in FIG. 5 may be software modules.
  • the hardened agent in the terminal system runs in the EL1 kernel state of the NW, and is responsible for detecting whether the common application is a protected application, collecting the characteristic information of the protected application, implementing the sys_call_enforce() system call logic, communicating with the hardened TA in the SW, and according to The return information of the hardening TA controls the running status of the protected application app.
  • the hardening agent detects whether the application is protected. By hooking the Android system PackageManager class, it detects whether the application is protected when the application is installed. If the protected application has been hardened, continue. The registration process is also detected when the application is uninstalled. If it has already been registered, the hardened TA of the SW will be notified to cancel the registration.
  • the hardened agent is consistent with the server when collecting application feature information.
  • the parameter accepted by the sys_call_enforce() system call is the package name of the application, and then notifies the hardened TA to register the application through the smc command.
  • the reinforcement agent may receive various return values from the reinforcement TA. For example, the reinforcement TA returns false after the integrity verification fails. At this time, the reinforcement agent is responsible for immediately stopping the application whose integrity is damaged.
  • the reinforcement TA running in the EL0 user state in the TEE is responsible for responding to the registration process at startup of the protected application and receiving the smc command request at runtime.
  • the registration process mainly includes initial integrity verification and generation of dynamic integrity benchmark values.
  • the reinforcement agent can be regarded as a transmission medium between NW and SW.
  • the shell.so file of the shell program when it is detected that the APK is installed, the shell.so file of the shell program is loaded, enters the JNI_onLoad() function, executes the system call sys_call_enforce(pkg_name), and the reinforcement agent in the NW responds.
  • the reinforcement agent receives the pkg_name parameter , calculate the hash(pkg_name), and then call [smc hash(pkg_name), 0] to enter the SW to let the hardened TA query whether the protected application app is registered in the trusted application TA of the safe world SW, if the protected application is not in the safe world If registered in the trusted application TA of the SW, the protected application is registered in the TA of the SW.
  • the server when the server compiles the trusted application TA of the secure world SW, it compiles the shared information between the server and the terminal into the operating system of the terminal, and then registers the protected application in the TA of the SW, as shown in the figure 6, the specific steps are:
  • Step 201 in the normal world NW, find the start address and end address of the hardened second shell program in memory;
  • the hardening agent will collect the start address and end address (addr_start, addr_end) mapped in the memory of the protected application shell program shell.so file.
  • Step 202 in the TA of the secure world SW, according to the target smc command from the normal world NW, obtain the start address and the end address carried by the target smc command;
  • the target smc command of NW in the ordinary world can be [smc hash(pkg_name), 1, addr_start, addr_end] command, and the hardened TA obtains the start address and end address through the target smc command of NW.
  • [smc hash(pkg_name), 0] and [smc hash(pkg_name), 1, addr_start, addr_end] the second parameters 0 and 1 of the two smc instructions are exclusively used by this system call, and are specially used in the registration phase Information exchange is performed with the hardened TA, so the two elements 0 and 1 cannot be used in the value field of the server-side hardened creation map A.
  • the second parameter of the two smc commands specially used for information exchange with the TA during the registration phase may also use other values, so as to ensure that the value range of creating the mapping A is different from the other values.
  • Step 203 in the TA of the secure world SW, according to the start address and the end address, determine the non-hidden code interval in the hardened second shell program, and calculate the hash value of the non-hidden code interval;
  • SW hardening TA locates all non-hidden code intervals of the shell.so file of the protected app according to the start address and end address (addr_start, addr_end), and calculates the hash values of all non-hidden code intervals, among which, non- The code-behind section is an invariant section of shell.so.
  • the invariant interval of shell.so is divided into many blocks after excluding the smc command.
  • the server calculates the hash value for the invariant interval of each block, and there are as many hash values as there are invariant intervals.
  • another hash value may be calculated as the hash value of all the constant intervals according to the hash values of all the constant intervals.
  • an smc instruction for triggering dynamic integrity verification is inserted into a preset position of the hardened second shell program, and a non-hidden key in the hardened second shell program is determined according to the start address and end address
  • the hash value of the hardened second shell program can also be calculated and stored according to the start address and end address; wherein, the hash value of the hardened second shell program is used for running the protected application.
  • the hardened TA in SW records the shell.so address range (addr_start, addr_end) of the protected application, and calculates the hash value of shell.so to record as subsequent dynamic integrity Validated baseline value.
  • the app information saved by the SW hardened TA during the registration phase includes: (pkg_name, addr_start, addr_end, hash(mem[addr_start, addr_end])). These information are stored in the secure memory of TEE through HashMap, called Map_enforce, which cannot be obtained by attackers.
  • Map_enforce the shell.so in the shell program will no longer change (the constant interval plus all smc commands cannot be changed), and this hash value calculation is based on the entire content of the shell program shell.so.
  • Hash value can verify whether the shell program shell.so has been tampered with during the running process of the protected application, and register the protected application in the TA of the SW if it has not been tampered with, ensuring the security during the running process .
  • Step 204 if the hash value of the non-concealed code interval is the same as the shared information, register the protected application in the TA of the SW.
  • the registration failure information will be returned to the reinforcement agent immediately, and the NW reinforcement agent will terminate the operation of the protected app. If all invariant intervals pass the verification, the protected application is registered in the TA of the SW.
  • the protected application in the TA of the SW after registering the protected application in the TA of the SW, it further includes: querying the second mapping relationship corresponding to the name identifier of the protected application in the TA of the SW, and combining the name identifier of the protected application with the The second mapping relationship is bound.
  • the TA image corresponding to the protected application is generated, and after the TA image is compiled into the operating system of the terminal, the TA image contains the second mapping corresponding to the name identifier of the protected application
  • the name identifier of the protected application is bound to the second mapping relationship, so that when the subsequent protected application is running, the second mapping relationship can be obtained according to the name identifier of the protected application carried by the smc command, Therefore, the object to be hidden corresponding to the obfuscation parameter carried by the smc instruction is obtained based on the second mapping relationship.
  • An embodiment of the present disclosure also provides an operation method for running the protected application registered by the registration method of the above embodiment, including: during the process of running the protected application, when the protected application is received in the TA of the secure world SW When applying the smc instruction, determine the object to be hidden corresponding to the smc instruction; execute the object to be hidden in the TA of the secure world SW according to the semantics represented by the object to be hidden.
  • the smc command of the protected application carries the confusion parameter and the name identifier of the protected application, and according to the name identifier of the protected application, determines the second mapping relationship bound to the name identifier of the protected application; according to the bound first
  • the second mapping relationship is to determine the object to be hidden corresponding to the obfuscation parameter carried by the smc command, and execute the object to be hidden in the TA of the safe world SW according to the semantics represented by the object to be hidden.
  • Step 301 receiving the smc instruction of the protected application
  • the TA of the safe world SW receives the smc command of the protected application, for example, the smc command is [smc hash(pkg_name), a], and hash(pkg_name) is the package name parameter , a is the confusion parameter.
  • Step 302 determining the object to be hidden corresponding to the smc instruction
  • the second mapping relationship bound to the name identifier of the protected application determines the second mapping relationship bound to the name identifier of the protected application; according to the bound second mapping relationship, determine the object to be hidden corresponding to the confusion parameter carried by the smc instruction , so as to obtain the semantics represented by the object to be hidden.
  • Step 303 according to the semantics represented by the object to be hidden, execute the semantics represented by the object to be hidden in the TA of the secure world SW;
  • the semantics represented by the object to be hidden are: the semantics represented by key instructions, the semantics represented by key code fragments, or the semantics represented by key functions.
  • the TA of Safe World SW can modify the register or memory of NW according to the semantics of key instructions and key code fragments, and after completion, point the pc pointer of NW to the next instruction of smc and then directly return to NW to continue execution.
  • the simulation execution of key functions is basically the same as the execution of key instructions and key code fragments.
  • the parameters carried by the smc instruction are obtained from the NW stack and then executed, and the results are fed back to the NW stack and then returned to NW to continue execution.
  • the logic code that generates the trusted application TA to simulate and execute the object to be hidden is executed in the hardened TA.
  • the hardened TA needs to process various logical hidden objects.
  • Each hidden logic requires the hardened TA to set up a processing module to be responsible for execution.
  • This processing module is handler0, for example, the key instruction simulation execution handler, the key code fragment simulation execution handler, the key function simulation execution handler, and the dynamic integrity verification handler.
  • the SW when the semantics represented by the object to be hidden is switched in the TA of the safe world SW, the SW needs to use the NW register, which involves the issue of register transfer, and the relevant state of the SW register can be transferred by stack Set to the relevant state of the NW register.
  • the smc instruction is smc(app_name, 76), and only the two parts of app_name and 76 can be set in the relevant state.
  • the smc(app_name, 76) two parameters can be passed, one is app_name, and the other is 76. These two parameters can occupy two registers and are saved through the stack.
  • Step 304 whether the dynamic integrity check is passed
  • the current running The current hash value of the hardened second shell program; determine whether the current hash value is the same as the stored shared information for dynamic integrity verification.
  • Step 305 return to NW to continue execution
  • the hardened TA calculates the hash value of the non-hidden interval of shell. The known value of the information is compared, and if the interval is found to be consistent, the shell.so of NW is returned to continue execution.
  • Step 306 return to the NW hardening agent to stop the process.
  • the hardened TA calculates the hash value of the non-hidden interval of shell.so based on the addr_start and addr_end information registered by the protected application at startup, and compares it with the known value of the shared information. If an inconsistent interval is found, it dynamically If the integrity check fails, immediately return the information that the dynamic integrity check fails to the hardening agent, and the NW hardening agent stops the running of the protected app.
  • the operation method provided by this embodiment can completely prevent an attacker from statically analyzing shell.so in NW, because the shell.so after logic hiding does not have any complete semantic information at all; in addition, this disclosure can greatly increase dynamic analysis
  • the difficulty is because the security assumption is that the attacker cannot break through the TEE to obtain the handler for processing the smc request.
  • the attacker can only debug shell.so in the NW, and analyze the changes of the entire processor state and memory space before and after the smc command.
  • the search space is very large, and the subsequent logical analysis is more difficult.
  • the embodiments of the present disclosure can provide very high shell program protection security.
  • step division of the above various methods is only for the sake of clarity of description. During implementation, it can be combined into one step or some steps can be split and decomposed into multiple steps. As long as they include the same logical relationship, they are all within the scope of protection of this patent. ; Adding insignificant modifications or introducing insignificant designs to the algorithm or process, but not changing the core design of the algorithm and process are all within the scope of protection of this patent.
  • An embodiment of the present disclosure also provides an electronic device, as shown in FIG. 8 , including: at least one processor 701; and a memory 702 communicatively connected to at least one processor; wherein, when the electronic device is a server, The memory 702 stores instructions that can be executed by at least one processor 701, and the instructions are executed by the at least one processor 701, so that the at least one processor 701 can perform the above-mentioned strengthening method; In the case of a terminal, the memory 702 stores instructions executable by the at least one processor 701, and the instructions are executed by the at least one processor 701, so that the at least one processor 701 can execute the above-mentioned Register method, or execute the run method above.
  • the memory and the processor are connected by a bus
  • the bus may include any number of interconnected buses and bridges, and the bus connects one or more processors and various circuits of the memory together.
  • the bus may also connect together various other circuits such as peripherals, voltage regulators, and power management circuits, all of which are well known in the art and therefore will not be further described herein.
  • the bus interface provides an interface between the bus and the transceivers.
  • a transceiver may be a single element or multiple elements, such as multiple receivers and transmitters, providing means for communicating with various other devices over a transmission medium.
  • the data processed by the processor is transmitted on the wireless medium through the antenna, further, the antenna also receives the data and transmits the data to the processor.
  • the processor is responsible for managing the bus and general processing, and can also provide various functions, including timing, peripheral interface, voltage regulation, power management, and other control functions. Instead, memory can be used to store data that the processor uses when performing operations.
  • an embodiment of the present disclosure also provides a computer-readable storage medium, which stores a computer program.
  • the computer program is executed by a processor, the above-mentioned hardening method is realized, or any of the above-mentioned registration methods is realized, or the above-mentioned method of operation.
  • the program is stored in a storage medium, and includes several instructions to make a device ( It may be a single chip microcomputer, a chip, etc.) or a processor (processor) to execute all or part of the steps in the methods of the various embodiments of the present disclosure.
  • the aforementioned storage media include: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), magnetic disk or optical disc, etc., which can store program codes. .

Abstract

The embodiments of the present disclosure relate to the field of computer software, and in particular to a reinforcement method, a registration method, a running method, an electronic device and a storage medium. The reinforcement method comprises: determining an object to be hidden in a first shell program of a protected application; determining a secure monitor call (SMC) instruction corresponding to said object; replacing said object with the SMC instruction corresponding to said object, so as to obtain a reinforced second shell program; and reinforcing an application package (APK) of the protected application according to the reinforced second shell program, so as to obtain a reinforced APK. The reinforcement method provided in the embodiments of the present disclosure aims to improve the security of shell program protection.

Description

加固方法、注册方法、运行方法、电子设备和存储介质Reinforcement method, registration method, operation method, electronic device and storage medium
相关申请的交叉引用Cross References to Related Applications
本公开基于2021年09月23日提交的发明名称为“加固方法、注册方法、运行方法、电子设备和存储介质”的中国专利申请CN202111115444.6,并且要求该专利申请的优先权,通过引用将其所公开的内容全部并入本公开。This disclosure is based on the Chinese patent application CN202111115444.6 filed on September 23, 2021 with the title of "reinforcement method, registration method, operation method, electronic equipment and storage medium", and claims the priority of this patent application, which is incorporated by reference The contents disclosed therein are fully incorporated into the present disclosure.
技术领域technical field
本公开实施例涉及计算机领域,特别涉及一种加固方法、注册方法、运行方法、电子设备和存储介质。The embodiments of the present disclosure relate to the field of computers, and in particular to a reinforcement method, a registration method, an operation method, electronic equipment, and a storage medium.
背景技术Background technique
随着移动互联网的高速发展以及手机移动终端设备数量的大量增长,市场中涌现出无数应用,极大地丰富了人们的生活。在移动应用愈发重要的趋势下,催生了大量对应用加固保护的方法,这其中以软件加壳技术为典型代表,例如加密壳、压缩壳、虚拟执行壳等。然而,与加壳保护相对应的出现了各种脱壳攻击手段,如针对加密壳和压缩壳的内存重组脱壳法、Hook脱壳法以及系统定制脱壳法。以虚拟执行壳为代表的第三代壳极大地增加了脱壳破解的难度,但经过较长时间的研究后,三代壳还是无法避免被脱壳的结果。由此看来,无论软件壳设计得多么复杂精巧,经过长时间的研究,还是会被破解而失效,即壳程序保护的安全性较低。With the rapid development of the mobile Internet and the massive increase in the number of mobile terminal devices, countless applications have emerged in the market, greatly enriching people's lives. With the trend of mobile applications becoming more and more important, a large number of methods for application reinforcement and protection have been spawned, among which software packing technology is a typical representative, such as encrypted shell, compressed shell, virtual execution shell, etc. However, corresponding to the packing protection, there have been various unpacking attack methods, such as the memory reorganization unpacking method for encrypted shells and compressed shells, the Hook unpacking method, and the system customization unpacking method. The third-generation shell represented by the virtual execution shell has greatly increased the difficulty of unpacking and cracking, but after a long period of research, the third-generation shell still cannot avoid the result of being unpacked. From this point of view, no matter how complex and exquisite the software shell is designed, after a long period of research, it will still be cracked and become invalid, that is, the security of the shell program protection is low.
发明内容Contents of the invention
本公开实施例的主要目的在于提出一种加固方法、注册方法、运行方法、电子设备和存储介质,使得可以提高壳程序保护的安全性。The main purpose of the embodiments of the present disclosure is to provide a reinforcement method, a registration method, an operation method, an electronic device and a storage medium, so that the security of the shell program protection can be improved.
为至少实现上述目的,本公开实施例提供了一种加固方法,应用于服务端,包括:确定受保护应用的第一壳程序中的待隐藏对象;确定与待隐藏对象对应的安全监控模式调用smc指令;将待隐藏对象替换为与待隐藏对象对应的smc指令,得到加固后的第二壳程序;根据加固后的第二壳程序,对受保护应用的应用程序包APK进行加固,得到加固后的APK。In order to at least achieve the above purpose, the embodiment of the present disclosure provides a hardening method applied to the server, including: determining the object to be hidden in the first shell program of the protected application; determining the security monitoring mode call corresponding to the object to be hidden smc instruction; replace the object to be hidden with the smc instruction corresponding to the object to be hidden, and obtain the second shell program after reinforcement; according to the second shell program after reinforcement, the application package APK of the protected application is reinforced to obtain reinforcement After the APK.
为实现上述目的,本公开实施例还提供了一种注册方法,应用于终端,包括:当检测到一APK被安装后,确定APK对应的受保护应用是否在安全世界SW的可信应用TA中被注册;其中,APK为上述任一项的加固方法得到的加固后的APK;若受保护应用未在安全世界SW的可信应用TA中被注册,在SW的TA中注册受保护应用。In order to achieve the above purpose, an embodiment of the present disclosure also provides a registration method applied to a terminal, including: after detecting that an APK is installed, determining whether the protected application corresponding to the APK is in the trusted application TA of the secure world SW Registered; wherein, APK is the hardened APK obtained by any one of the above hardening methods; if the protected application is not registered in the trusted application TA of the secure world SW, register the protected application in the TA of the SW.
为至少实现上述目的,本公开实施例还提供了一种运行方法,用于运行上述的注册方法注册的受保护应用,方法包括:在运行受保护应用的过程中,当在安全世界SW的TA中接收到受保护应用的smc指令时,确定smc指令对应的待隐藏对象;根据待隐藏对象所表征的语义,在安全世界SW的TA中执行待隐藏对象。In order to achieve at least the above purpose, an embodiment of the present disclosure also provides an operation method for running the protected application registered by the above registration method. The method includes: during the running of the protected application, when the TA in the secure world SW When receiving the smc instruction of the protected application, determine the object to be hidden corresponding to the smc instruction; execute the object to be hidden in the TA of the secure world SW according to the semantics represented by the object to be hidden.
为实现上述目的,本公开实施例还提供了一种电子设备,包括:至少一个处理器;以及,与所述至少一个处理器通信连接的存储器;其中,在所述电子设备为服务器的情况下,所述存储器存储有可被所述至少一个处理器执行的指令,所述指令被所述至少一个处理器执行,以使所述至少一个处理器能够执行上述的加固方法;在所述电子设备为终端的情况下,所述 存储器存储有可被所述至少一个处理器执行的指令,所述指令被所述至少一个处理器执行,以使所述至少一个处理器能够执行上述的注册方法,或者执行上述的运行方法。In order to achieve the above purpose, an embodiment of the present disclosure further provides an electronic device, including: at least one processor; and a memory connected to the at least one processor in communication; wherein, when the electronic device is a server , the memory stores instructions executable by the at least one processor, the instructions are executed by the at least one processor, so that the at least one processor can execute the above-mentioned strengthening method; in the electronic device In the case of a terminal, the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor, so that the at least one processor can execute the above registration method, Or execute the above-mentioned running method.
为实现上述目的,本公开实施例还提供了一种计算机可读存储介质,存储有计算机程序,计算机程序被处理器执行时实现上述的加固方法,或者实现上述任一的注册方法,或者实现上述的运行方法。In order to achieve the above purpose, an embodiment of the present disclosure also provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the above-mentioned hardening method is realized, or any of the above-mentioned registration methods is realized, or the above-mentioned method of operation.
附图说明Description of drawings
图1是本公开一个实施例的加固方法流程图。Fig. 1 is a flowchart of a strengthening method according to an embodiment of the present disclosure.
图2是本公开一个实施例的加固方法中调用smc指令流程图。Fig. 2 is a flow chart of calling an smc instruction in a hardening method according to an embodiment of the present disclosure.
图3是本公开一个实施例隐藏方式示意图;Fig. 3 is a schematic diagram of a hiding method according to an embodiment of the present disclosure;
图4是本公开一个实施例服务端加固过程示意图;FIG. 4 is a schematic diagram of a server reinforcement process according to an embodiment of the present disclosure;
图5是本公开一个实施例中终端系统结构的示意图:Fig. 5 is a schematic diagram of a terminal system structure in an embodiment of the present disclosure:
图6是本公开另一个实施例中注册方法流程图;FIG. 6 is a flowchart of a registration method in another embodiment of the present disclosure;
图7是本公开另一个实施例中运行方法流程图;FIG. 7 is a flow chart of an operating method in another embodiment of the present disclosure;
图8是本公开另一个实施例中电子设备的示意图。FIG. 8 is a schematic diagram of an electronic device in another embodiment of the present disclosure.
具体实施方式Detailed ways
为使本公开实施例的目的、技术方案和优点更加清楚,下面将结合附图对本公开的各实施例进行详细的阐述。然而,本领域的普通技术人员可以理解,在本公开各实施例中,为了使读者更好地理解本公开而提出了许多技术细节。但是,即使没有这些技术细节和基于以下各实施例的种种变化和修改,也可以实现本公开所要求保护的技术方案。以下各个实施例的划分是为了描述方便,不应对本公开的具体实现方式构成任何限定,各个实施例在不矛盾的前提下可以相互结合相互引用。In order to make the purpose, technical solutions, and advantages of the embodiments of the present disclosure clearer, various embodiments of the present disclosure will be described in detail below in conjunction with the accompanying drawings. However, those skilled in the art can understand that in various embodiments of the present disclosure, many technical details are provided for readers to better understand the present disclosure. However, even without these technical details and various changes and modifications based on the following embodiments, the technical solutions claimed in the present disclosure can be realized. The division of the following embodiments is for the convenience of description, and should not constitute any limitation to the specific implementation of the present disclosure, and the embodiments can be combined and referenced to each other on the premise of no contradiction.
为便于对本公开实施例的理解,下面首先对本公开中所涉及的相关技术进行简要说明:In order to facilitate the understanding of the embodiments of the present disclosure, the related technologies involved in the present disclosure are briefly described below:
移动终端设备大量使用高级精简指令集(Advanced RISC Machines,简称为ARM)处理器,ARM提出的TrustZone将处理器资源分为普通世界(Normal World,NW)与安全世界(Secure World,简称为SW)两部分,这种硬件隔离机制为可信执行环境(Trust Execution Environment,简称为TEE)的开发提供了坚实的硬件基础。在纯软件保护面临攻击威胁的情况下,有必要对TEE的壳程序进行保护,主要保护的目标是壳程序的原生代码(native代码),即so文件(也称shell.so文件)。Mobile terminal devices use a large number of Advanced RISC Machines (ARM) processors. TrustZone proposed by ARM divides processor resources into Normal World (NW) and Secure World (SW). This hardware isolation mechanism provides a solid hardware foundation for the development of Trust Execution Environment (TEE). Under the situation that pure software protection faces the threat of attack, it is necessary to protect the shell program of TEE, and the main target of protection is the original code (native code) of the shell program, that is, the so file (also known as shell.so file).
本公开的一个实施例中提供了一种加固方法,应用于服务端,下面对本实施例的加固方法的实现细节进行具体的说明,以下内容仅为方便理解提供的实现细节,并非实施本方案的必须。本公开的实施例的应用场景可以包括但不限于TEE的软件壳程序保护,加固方法包括:确定受保护应用的第一壳程序中的待隐藏对象;确定与待隐藏对象对应的安全监控模式调用smc指令;将待隐藏对象替换为与待隐藏对象对应的smc指令,得到加固后的第二壳程序;根据加固后的第二壳程序,对受保护应用的应用程序包APK进行加固,得到加固后的APK。其中,第一壳程序可以理解为原始的壳程序,第二壳程序可以理解为对原始的壳程序加固后的壳程序。An embodiment of the present disclosure provides a hardening method, which is applied to the server. The implementation details of the hardening method in this embodiment are described in detail below. The following content is only the implementation details provided for easy understanding, and is not the implementation of this solution. must. The application scenarios of the embodiments of the present disclosure may include but not limited to the software shell program protection of TEE, and the strengthening method includes: determining the object to be hidden in the first shell program of the protected application; determining the security monitoring mode call corresponding to the object to be hidden smc instruction; replace the object to be hidden with the smc instruction corresponding to the object to be hidden, and obtain the second shell program after reinforcement; according to the second shell program after reinforcement, the application package APK of the protected application is reinforced to obtain reinforcement After the APK. Wherein, the first shell program can be understood as the original shell program, and the second shell program can be understood as the shell program after strengthening the original shell program.
本实施例的加固方法的具体流程可以如图1所示。The specific flow of the reinforcement method in this embodiment may be shown in FIG. 1 .
步骤101:确定受保护应用的第一壳程序中的待隐藏对象;Step 101: Determine the object to be hidden in the first shell program of the protected application;
具体而言,可以根据用户期望的安全性以及性能消耗评估,确定第一壳程序中所有逻辑隐藏对象。用户期望的安全性越高,确定的待隐藏对象的数量就越多,对应的性能消耗也就越大。因此,可以结合用户期望的安全性以及性能消耗评估,合理的确定出待隐藏对象的数量。Specifically, all logic hidden objects in the first shell program may be determined according to the user's expected security and performance consumption evaluation. The higher the security expected by the user, the greater the number of determined objects to be hidden, and the greater the corresponding performance consumption. Therefore, the number of objects to be hidden can be reasonably determined in combination with the security expected by the user and the evaluation of performance consumption.
其中,待隐藏对象可以为受保护应用的第一壳程序shell.so文件中的逻辑隐藏对象,待隐藏对象可以理解为:第一壳程序攻击者在攻击第一壳程序的时候,如果把这些待隐藏对象都破解分析清楚的话,第一壳程序就可能被完全破解,即待隐藏对象为对第一壳程序至关重要的且可以通过隐藏保护避免被破解的对象。Wherein, the object to be hidden can be a logic hidden object in the first shell program shell.so file of the protected application, and the object to be hidden can be understood as: when the first shell program attacker attacks the first shell program, if these If all objects to be hidden are cracked and analyzed clearly, the first shell program may be completely cracked, that is, the object to be hidden is an object that is crucial to the first shell program and can be protected from being cracked by hiding protection.
在一个例子中,待隐藏对象包括以下任意之一或其组合,比如说第一壳程序中的关键指令、关键代码片段、关键函数。其中,关键指令包括内存读写指令、控制流转移指令、通用寄存器操作指令等具有较为明确语义的指令;关键代码片段可以是一小段汇编代码,比如说是几行代码,几条指令,这一小段汇编代码可以让CPU寄存器变换较为明确,即关键代码片段可以理解为具有明确语义的代码片段;关键函数相对规模最大,可以包括上千条指令代码片段。In an example, the object to be hidden includes any one or combination of the following, for example, key instructions, key code fragments, and key functions in the first shell program. Among them, the key instructions include memory read and write instructions, control flow transfer instructions, general register operation instructions and other instructions with relatively clear semantics; the key code fragment can be a small piece of assembly code, for example, a few lines of code, a few instructions, this A small piece of assembly code can make the CPU register conversion more clear, that is, the key code segment can be understood as a code segment with clear semantics; the key function is relatively the largest, and can include thousands of instruction code segments.
在一个例子中,待隐藏对象也可以为本领域技术人员根据实际需要预设的希望保护的壳程序中的指令、代码片段、函数等。其中,预设的希望保护的壳程序中的指令、代码片段、函数可以分别作为上述的关键指令、关键代码片段、关键函数。In an example, the object to be hidden may also be an instruction, a code segment, a function, etc. in a shell program preset by those skilled in the art and desired to be protected according to actual needs. Wherein, the preset instructions, code fragments, and functions in the shell program to be protected can be respectively used as the above-mentioned key instructions, key code fragments, and key functions.
步骤102:确定与待隐藏对象对应的安全监控模式调用smc指令;Step 102: determine the security monitoring mode corresponding to the object to be hidden and call the smc command;
在一个例子中,服务端可以根据预存的待隐藏对象与安全监控模式调用指令(Secure Monitor Call,简称为smc)之间的映射关系,得到受保护应用的第一壳程序中的待隐藏对象对应的smc指令。In one example, the server can obtain the correspondence between the object to be hidden in the first shell program of the protected application according to the mapping relationship between the pre-stored object to be hidden and the call command of the security monitoring mode (Secure Monitor Call, referred to as smc for short). The smc command.
在另一个例子中,确定与待隐藏对象对应的安全监控模式调用smc指令可以由如图2所示的各子步骤实现,具体包括:In another example, determining the security monitoring mode corresponding to the object to be hidden and calling the smc instruction can be implemented by the sub-steps shown in Figure 2, specifically including:
步骤1021:获取受保护应用的特征信息和待隐藏对象的身份标识;Step 1021: Obtain the feature information of the protected application and the identity of the object to be hidden;
具体而言,受保护应用的特征信息可以是包名pkg_name、应用版本号等。选定受保护应用的第一壳程序shell.so文件中的所有待隐藏对象。服务端可根据所有待隐藏对象的类型以及偏移信息,为待隐藏对象计算哈希值,并将其转化为十六进制作为隐藏点标号,各隐藏点标号即为每个待隐藏对象的唯一身份标识,其中,待隐藏对象的偏移信息是相对于壳程序首行原生代码的偏移量。待隐藏对象的类型可以包括:关键指令、关键代码片段和关键函数,比如,图4中关键指令包括:str x1,x2、ldr x3,x4;关键代码片段包括:mov x0,x7str x1,[x0]ldr x2,x3关键函数包括:key_func()。Specifically, the characteristic information of the protected application may be a package name pkg_name, an application version number, and the like. Select all objects to be hidden in the first shell program shell.so file of the protected application. The server can calculate the hash value for the object to be hidden according to the type and offset information of all objects to be hidden, and convert it into hexadecimal as the hidden point label, and each hidden point label is the hash value of each object to be hidden A unique identifier, wherein the offset information of the object to be hidden is an offset relative to the first line of native code of the shell program. The type of object to be hidden can include: key instructions, key code fragments and key functions. For example, key instructions in Figure 4 include: str x1, x2, ldr x3, x4; key code fragments include: mov x0, x7str x1, [x0 ]ldr x2, x3 key functions include: key_func().
步骤1022:根据特征信息,生成待隐藏对象的身份标识与混淆参数的第一映射关系;Step 1022: According to the feature information, generate a first mapping relationship between the identity of the object to be hidden and the confusion parameter;
具体而言,服务端可以将受保护应用的特征信息(如包名pkg_name、应用版本号)作为随机因子输入随机算法,对每个待隐藏对象分别生成一个随机的混淆参数a,用来掩盖真实的标号。所有待隐藏对象的身份标识对应的混淆参数集合为映射A,这个集合为单射集合,即一个待隐藏对象的身份标识唯一对应一个混淆参数,待隐藏对象的身份标识与混淆参数的映射为第一映射关系。举例来说,如图4所示,在受保护应用的特征信息输入随机算法后,待隐藏对象的身份标识即各隐藏点标号为Ox3D456F7B、0x2AB35732、0x3F5F7AOCD, 0x80848EAF、0Xea206721,混淆参数集合A为{76,24,12,33,89},各隐藏点标号与混淆参数集合A的元素的映射为一一对应关系,一个隐藏点标号对应一个混淆参数,比如说Ox3D456F7B的映射为76。Specifically, the server can input the characteristic information of the protected application (such as the package name pkg_name, the application version number) into the random algorithm as a random factor, and generate a random obfuscation parameter a for each object to be hidden to cover up the real label. The set of obfuscation parameters corresponding to the identities of all objects to be hidden is mapping A. This set is an injective set, that is, the identity of an object to be hidden corresponds to only one obfuscation parameter. The mapping between the identity of an object to be hidden and the obfuscation parameter is A mapping relationship. For example, as shown in Figure 4, after the feature information of the protected application is input into the random algorithm, the identity of the object to be hidden, that is, the labels of each hidden point are Ox3D456F7B, 0x2AB35732, 0x3F5F7AOCD, 0x80848EAF, 0Xea206721, and the confusion parameter set A is { 76, 24, 12, 33, 89}, the mapping between each hidden point label and the elements of the confusion parameter set A is a one-to-one correspondence, one hidden point label corresponds to one confusion parameter, for example, the mapping of Ox3D456F7B is 76.
可选的,在步骤1022之后,根据特征信息生成待隐藏对象的身份标识与混淆参数的第一映射关系之后,还可以根据第一映射关系生成第二映射关系;其中,第二映射关系与第一映射关系互为反向映射;生成可信应用TA模拟执行待隐藏对象的逻辑代码即handler代码;当编译安全世界SW的可信应用TA时,根据第二映射关系、非隐藏代码区间的哈希值和逻辑代码,生成受保护应用对应的可信应用TA镜像,并将TA镜像编译到终端的操作系统中。生成TA镜像的一个输入可以当作是第二映射关系。Optionally, after step 1022, after generating the first mapping relationship between the identity of the object to be hidden and the confusion parameter according to the feature information, a second mapping relationship may also be generated according to the first mapping relationship; wherein, the second mapping relationship is the same as the first mapping relationship The first mapping relationship is a reverse mapping to each other; the trusted application TA is generated to simulate and execute the logic code of the object to be hidden, that is, the handler code; The hash value and logic code generate the trusted application TA image corresponding to the protected application, and compile the TA image into the terminal operating system. An input for generating the TA image can be regarded as the second mapping relationship.
在安全世界SW中编译可信应用TA后,生成的TA镜像,将TA镜像编译到终端操作系统中,有利于避免受保护应用对应的TA镜像被攻击,保证TA镜像中包含的相关信息(第二映射关系、非隐藏代码区间的哈希值和逻辑代码)的安全性。操作系统中的TA镜像方便了后续在TA中注册受保护应用或是运行受保护应用时,得到需要的相关信息,比如:注册受保护应用会用到非隐藏代码区间的哈希值(共享信息),验证加固后的第二壳程序shell.so未被篡改。运行受保护应用的过程中会用到第二映射关系,得到混淆参数对应的待隐藏对象。After the trusted application TA is compiled in the secure world SW, the generated TA image will be compiled into the terminal operating system, which will help prevent the TA image corresponding to the protected application from being attacked and ensure that the relevant information contained in the TA image (Part 1) Two-mapping relationship, hash value of non-hidden code interval and logic code) security. The TA image in the operating system facilitates subsequent registration of protected applications or running protected applications in TA to obtain relevant information. For example, the hash value of the non-hidden code interval (shared information ), verify that the hardened second shell program shell.so has not been tampered with. The second mapping relationship is used in the process of running the protected application to obtain the object to be hidden corresponding to the obfuscation parameter.
步骤1023:根据第一映射关系,确定待隐藏对象的身份标识映射出的混淆参数对应的smc指令。Step 1023: According to the first mapping relationship, determine the smc instruction corresponding to the obfuscation parameter mapped from the identity of the object to be hidden.
具体而言,在步骤1022得到隐藏点标号和混淆参数的映射关系后,将shell.so中选定的待隐藏对象分别使用smc指令进行替换,替换的smc指令格式为:[smc hash(pkg_name),a]。其中,hash(pkg_name)为受保护应用的特征信息的哈希值,也就是包名哈希值,取通用寄存器大小的片段(如arm64-v8a架构处理器取前64bit)作为smc指令的一个参数,a是混淆参数,作为smc指令另一个参数。这两个参数在运行时让TA能够确定smc指令对应的逻辑隐藏对象。通过生成混淆参数,使得待隐藏对象与smc指令之间的对应关系并不唯一,有利于增加待隐藏对象与smc指令之间的对应关系被破解的难度,提高加固后的第二壳程序的安全性。Specifically, after step 1022 obtains the mapping relationship between hidden point labels and confusing parameters, the selected objects to be hidden in the shell.so are replaced with smc instructions respectively, and the replaced smc instruction format is: [smc hash(pkg_name) , a]. Among them, hash (pkg_name) is the hash value of the characteristic information of the protected application, that is, the hash value of the package name, and a segment of the general register size (such as the first 64 bits of the arm64-v8a architecture processor) is used as a parameter of the smc command , a is a confusing parameter, which is another parameter of the smc command. These two parameters allow TA to determine the logical hidden object corresponding to the smc instruction at runtime. By generating obfuscation parameters, the corresponding relationship between the object to be hidden and the smc command is not unique, which is conducive to increasing the difficulty of cracking the corresponding relationship between the object to be hidden and the smc command, and improving the security of the second shell program after reinforcement sex.
需要说明的是,由于包名长度不同、长短不一,但smc指令的参数是固定的64位,如果不计算哈希值可能一个app包名特别长,和smc指令的参数长度不匹配。因此需要取通用寄存器大小的片段(如arm64-v8a架构处理器取前64bit),应用哈希值把长短不一的app包名转换为固定长度,比如说从固定长度里取64位,作为hash(pkg_name)。It should be noted that due to the different lengths of package names, the parameters of the smc command are fixed at 64 bits. If the hash value is not calculated, an app package name may be very long, which does not match the parameter length of the smc command. Therefore, it is necessary to take a fragment of the size of a general register (such as the first 64bit for an arm64-v8a architecture processor), and use the hash value to convert the app package name of different lengths into a fixed length, for example, take 64 bits from the fixed length as a hash (pkg_name).
在具体实现中,如果受保护应用升级,可以采用图2中的方式确定与待隐藏对象对应的smc指令,可以理解的是,APP升级一定会导致受保护应用的特征信息变化,至少版本号变了,所以每次输出的混淆参数理论上一定不同。因此,有利于增加待隐藏对象与smc指令之间的对应关系被破解的难度,提高加固后的第二壳程序的安全性。In the specific implementation, if the protected application is upgraded, the smc instruction corresponding to the object to be hidden can be determined in the manner shown in Fig. , so the obfuscation parameters of each output must be different theoretically. Therefore, it is beneficial to increase the difficulty of cracking the corresponding relationship between the object to be hidden and the smc instruction, and improve the security of the second shell program after reinforcement.
步骤103:将待隐藏对象替换为与待隐藏对象对应的smc指令,得到加固后的第二壳程序;Step 103: replacing the object to be hidden with the smc command corresponding to the object to be hidden, to obtain the second shell program after reinforcement;
在一个例子中,如图3所示,若待隐藏对象为第一壳程序shell.so文件中的关键指令,原始shell.so文件中的关键指令为[str x1,x2],则替换后的smc指令为[smc app,76];若待隐藏对象为第一壳程序shell.so文件中关键代码片段,原始shell.so文件中的关键代码片段为[mov x0,x7str x1,[x0]ldr x2x3],则替换后的smc指令为[smc app,31];若待隐藏对象为第一壳程序shell.so文件中关键函数,原始shell.so文件中的关键函数为[key_fun1()],则替换后的smc指 令为[smc app,35]。原始shell.so文件中的指令在NW执行,替换后的smc指令在SW中执行。In one example, as shown in Figure 3, if the object to be hidden is the key instruction in the first shell program shell.so file, and the key instruction in the original shell.so file is [str x1, x2], then the replaced The smc command is [smc app, 76]; if the object to be hidden is the key code segment in the first shell program shell.so file, the key code segment in the original shell.so file is [mov x0, x7str x1, [x0]ldr x2x3], then the replaced smc command is [smc app, 31]; if the object to be hidden is the key function in the first shell program shell.so file, the key function in the original shell.so file is [key_fun1()], Then the replaced smc instruction is [smc app, 35]. The instructions in the original shell.so file are executed in NW, and the replaced smc instructions are executed in SW.
步骤104:根据加固后的第二壳程序,对受保护应用的应用程序包APK进行加固,得到加固后的APK。Step 104: According to the second hardened shell program, harden the application package APK of the protected application to obtain the hardened APK.
也就是说,服务器端根据加固后的第二壳程序shell.so文件,进行后续的加壳加固流程,最终输出加固后的Android应用程序包(Android application package,简称为APK)。APK是安卓应用的安装包,壳程序是用来保护APK的软件,本实施例中主要是保护壳程序的,保护壳程序也可以理解为加固壳程序,从而再利用的加固后的第二壳程序再去加固受保护应用的APK。That is to say, the server carries out subsequent shelling and hardening processes according to the hardened second shell program shell.so file, and finally outputs a hardened Android application package (Android application package, referred to as APK). APK is the installation package of the Android application, and the shell program is the software used to protect the APK. In this embodiment, it mainly protects the shell program. The protection shell program can also be understood as a reinforced shell program, so that the reinforced second shell can be reused. The program then hardens the APK of the protected application.
在上述步骤101之后,还可以确定受保护应用的第一壳程序中相邻的待隐藏对象之间的非隐藏代码区间;计算非隐藏代码区间的哈希值,并将哈希值作为服务端和注册受保护应用的终端之间的共享信息;当编译安全世界SW的可信应用(Trust Application,简称为TA)时,将共享信息编译到终端的操作系统中,其中,共享信息用于供终端在注册受保护应用时验证受保护应用的安全性。也就是说,待隐藏对象中的非隐藏代码区间为shell.so文件中所有未被替换的代码区间。如图3所示,shell.so文件中所有未被替换的代码区间为空白格所在区域即就是shell.so文件中所有未被替换的代码区间,也就是是非隐藏代码区间。计算各个非隐藏代码区间的哈希值,并将哈希值作为服务端和注册受保护app之间的共享信息,服务器端在编译SW中的TA时,将共享信息编译到操作系统中。After the above step 101, it is also possible to determine the non-hidden code interval between adjacent objects to be hidden in the first shell program of the protected application; calculate the hash value of the non-hidden code interval, and use the hash value as the server and the shared information between terminals registering the protected application; when compiling the trusted application (Trust Application, TA for short) of the secure world SW, the shared information is compiled into the operating system of the terminal, wherein the shared information is used for The terminal verifies the security of the protected application when registering the protected application. That is to say, the non-hidden code intervals in the object to be hidden are all unsubstituted code intervals in the shell.so file. As shown in FIG. 3 , all unsubstituted code intervals in the shell.so file are the blank spaces, that is, all unsubstituted code intervals in the shell.so file, that is, non-hidden code intervals. Calculate the hash value of each non-hidden code interval, and use the hash value as the shared information between the server and the registered protected app. When the server compiles the TA in the SW, it compiles the shared information into the operating system.
由于对第一壳程序shell.so文件中的逻辑隐藏对象进行替换后,除了替换为smc指令的部分会有变化外,第一壳程序shell.so文件中的其余部分都不再发生变化。因此,确定shell.so的smc指令后,统计所有不变化部分的代码区间(即非隐藏代码区间)并计算每个区间的哈希值,在编译TA时期输入这些不变区间的哈希值数据成为服务端和终端的共享信息,攻击者无法获取这个秘密。利用共享信息可以让受保护app在注册阶段进行一次初始的完整性校验,有利于防止攻击者壳程序shell.so进行欺骗攻击。在注册时只要非隐藏代码区间发生变化,如攻击者恶意注入shell.so或构造了假的shell.so,都会被终端根据共享信息判断出来从而拒绝注册,防止攻击者进行欺骗攻击。After the logical hidden object in the first shell program shell.so file is replaced, except for the part replaced with the smc command, the rest of the first shell program shell.so file will no longer change. Therefore, after determining the smc instruction of shell.so, count the code intervals of all unchanged parts (that is, non-hidden code intervals) and calculate the hash value of each interval, and input the hash value data of these unchanged intervals during compiling TA As the shared information of the server and the terminal, the attacker cannot obtain this secret. Utilizing the shared information allows the protected app to perform an initial integrity check during the registration phase, which is beneficial to prevent the attacker's shell program shell.so from spoofing attacks. During registration, as long as the non-hidden code range changes, such as an attacker maliciously injecting shell.so or constructing a fake shell.so, it will be judged by the terminal based on the shared information and the registration will be refused to prevent the attacker from spoofing attacks.
本公开实施例提供的加固方法,先确定受保护应用的第一壳程序中的待隐藏对象;确定与待隐藏对象对应的smc指令;将待隐藏对象替换为与待隐藏对象对应的smc指令,得到加固后的第二壳程序;第一壳程序中待隐藏对象被替换,即第一壳程序中待隐藏对象被隐藏,不存在完整的语义信息,可以完全阻止攻击者对壳程序的静态分析。而且,本公开实施例还可以极大地增加攻击者对壳程序的动态分析的难度,由于攻击者只能在NW中调试壳程序,在smc指令前后分析整个处理器状态以及内存空间的变化,在当前终端的处理器复杂度以及超大内存空间的前提下,这个搜索空间是非常大的,后续的逻辑分析则更加艰难。因此,本公开实施例中得到的加固后的第二壳程序被攻击的难度极大,可以提高壳程序保护的安全性。采用加固后的第二壳程序,对受保护应用的APK进行加固,得到加固后的APK,从而可以提高利用该加固后的第二壳程序保护APK的安全性。The reinforcement method provided by the embodiment of the present disclosure first determines the object to be hidden in the first shell program of the protected application; determines the smc command corresponding to the object to be hidden; replaces the object to be hidden with the smc command corresponding to the object to be hidden, The hardened second shell program; the object to be hidden in the first shell program is replaced, that is, the object to be hidden in the first shell program is hidden, and there is no complete semantic information, which can completely prevent the static analysis of the shell program by the attacker . Moreover, the embodiments of the present disclosure can also greatly increase the difficulty of the attacker's dynamic analysis of the shell program, because the attacker can only debug the shell program in the NW, and analyze the changes of the entire processor state and memory space before and after the smc command. Under the premise of the current terminal's processor complexity and large memory space, this search space is very large, and subsequent logical analysis is even more difficult. Therefore, the hardened second shell program obtained in the embodiment of the present disclosure is extremely difficult to be attacked, which can improve the security of the shell program protection. The APK of the protected application is reinforced by using the reinforced second shell program to obtain the reinforced APK, thereby improving the security of using the reinforced second shell program to protect the APK.
需要说明的是,本公开实施例中的上述各示例均为为方便理解进行的举例说明,并不对本公开的技术方案构成限定。It should be noted that, the above examples in the embodiments of the present disclosure are illustrations for the convenience of understanding, and do not limit the technical solution of the present disclosure.
本公开实施例还提供了一种注册方法,应用于终端,具体包括:当检测到一APK被安装 后,确定APK对应的受保护应用是否在安全世界SW的可信应用TA中被注册;其中,APK为基于上述实施例加固方法得到的加固后的APK;若受保护应用未在安全世界SW的可信应用TA中被注册,在SW的TA中注册受保护应用。An embodiment of the present disclosure also provides a registration method, which is applied to a terminal, and specifically includes: after detecting that an APK is installed, determining whether the protected application corresponding to the APK is registered in the trusted application TA of the secure world SW; , the APK is a hardened APK obtained based on the hardening method of the above embodiment; if the protected application is not registered in the trusted application TA of the secure world SW, register the protected application in the TA of the SW.
如图5所示,终端系统有普通世界(Normal Word,简称为NW)和安全世界(Secure Word,简称为SW)两种状态,两种状态下均有自己独立的寄存器即CPU的环境。CPU在一个时刻只能处于一种状态,比如在NW状态运行,使用的就是NW寄存器,在SW状态运行,使用的就是SW寄存器,NW寄存器、SW寄存器是相互独立,互相隔离的。图5中的加固代理和加固TA均可以为软件模块。终端系统中的加固代理运行在NW中的EL1内核态,负责检测普通应用是否为受保护应用、收集受保护应用的特征信息、实现sys_call_enforce()系统调用逻辑、与SW中的加固TA通信并根据加固TA的返回信息控制受保护应用app的运行状态,其中,加固代理检测应用是否受到保护,通过hookAndroid系统PackageManager类,在应用安装时检测应用是否受到保护,如果受保护应用加固过,则继续进行注册流程,在应用卸载时同样进行检测,如果已经注册过,则通知SW的加固TA取消注册,加固代理在收集应用特征信息时与服务器端保持一致。sys_call_enforce()系统调用接受的参数为应用的包名,然后通过smc指令通知加固TA注册此应用。加固代理可能会收到加固TA的各种返回值,例如完整性验证失败后加固TA返回false,此时加固代理负责立即停止整性受损的应用。其中,加固TA运行在TEE中的EL0用户态,负责响应受保护应用的启动时的注册流程以及接收运行时的smc指令请求,注册流程主要包括初始完整性验证、生成动态完整性基准值。加固代理可看成是NW和SW的一个传输媒介。As shown in Figure 5, the terminal system has two states: normal world (Normal Word, NW for short) and secure world (Secure Word, SW for short), both of which have their own independent registers, that is, the environment of the CPU. The CPU can only be in one state at a time. For example, when running in the NW state, the NW register is used, and when the CPU is running in the SW state, the SW register is used. The NW register and the SW register are independent and isolated from each other. Both the reinforcement agent and the reinforcement TA in FIG. 5 may be software modules. The hardened agent in the terminal system runs in the EL1 kernel state of the NW, and is responsible for detecting whether the common application is a protected application, collecting the characteristic information of the protected application, implementing the sys_call_enforce() system call logic, communicating with the hardened TA in the SW, and according to The return information of the hardening TA controls the running status of the protected application app. Among them, the hardening agent detects whether the application is protected. By hooking the Android system PackageManager class, it detects whether the application is protected when the application is installed. If the protected application has been hardened, continue. The registration process is also detected when the application is uninstalled. If it has already been registered, the hardened TA of the SW will be notified to cancel the registration. The hardened agent is consistent with the server when collecting application feature information. The parameter accepted by the sys_call_enforce() system call is the package name of the application, and then notifies the hardened TA to register the application through the smc command. The reinforcement agent may receive various return values from the reinforcement TA. For example, the reinforcement TA returns false after the integrity verification fails. At this time, the reinforcement agent is responsible for immediately stopping the application whose integrity is damaged. Among them, the reinforcement TA running in the EL0 user state in the TEE is responsible for responding to the registration process at startup of the protected application and receiving the smc command request at runtime. The registration process mainly includes initial integrity verification and generation of dynamic integrity benchmark values. The reinforcement agent can be regarded as a transmission medium between NW and SW.
在具体实施中,当检测到APK被安装后,壳程序的shell.so文件加载,进入JNI_onLoad()函数,执行系统调用sys_call_enforce(pkg_name),NW中的加固代理响应,加固代理收到pkg_name参数后,计算hash(pkg_name),然后调用[smc hash(pkg_name),0]进入SW让加固TA查询受保护应用app是否在安全世界SW的可信应用TA中已经注册,若受保护应用未在安全世界SW的可信应用TA中被注册,则在SW的TA中注册受保护应用。In the specific implementation, when it is detected that the APK is installed, the shell.so file of the shell program is loaded, enters the JNI_onLoad() function, executes the system call sys_call_enforce(pkg_name), and the reinforcement agent in the NW responds. After the reinforcement agent receives the pkg_name parameter , calculate the hash(pkg_name), and then call [smc hash(pkg_name), 0] to enter the SW to let the hardened TA query whether the protected application app is registered in the trusted application TA of the safe world SW, if the protected application is not in the safe world If registered in the trusted application TA of the SW, the protected application is registered in the TA of the SW.
在一个例子中,服务端在编译安全世界SW的可信应用TA时,将服务端和终端之间的共享信息编译到终端的操作系统中,则在SW的TA中注册受保护应用,如图6所示,具体步骤为:In one example, when the server compiles the trusted application TA of the secure world SW, it compiles the shared information between the server and the terminal into the operating system of the terminal, and then registers the protected application in the TA of the SW, as shown in the figure 6, the specific steps are:
步骤201,在普通世界NW中,查找加固后的第二壳程序在内存中的起始地址和结束地址; Step 201, in the normal world NW, find the start address and end address of the hardened second shell program in memory;
具体而言,在普通世界NW中,加固代理会收集受保护应用壳程序shell.so文件内存中映射的起始地址与结束地址(addr_start,addr_end)。Specifically, in the normal world NW, the hardening agent will collect the start address and end address (addr_start, addr_end) mapped in the memory of the protected application shell program shell.so file.
步骤202,在安全世界SW的TA中,根据来自普通世界NW的目标smc指令,获取目标smc指令携带的起始地址和结束地址; Step 202, in the TA of the secure world SW, according to the target smc command from the normal world NW, obtain the start address and the end address carried by the target smc command;
具体而言,普通世界NW的目标smc指令可以是[smc hash(pkg_name),1,addr_start,addr_end]指令,加固TA通过NW的目标smc指令得到起始地址与结束地址。其中,[smc hash(pkg_name),0]和[smc hash(pkg_name),1,addr_start,addr_end]这两个smc指令的第二个参数0和1由此系统调用独占,专门用来在注册阶段与加固TA进行信息交互,因此服务器端加固创建映射A的值域不能使用0和1这两个元素。然而在具体实现中,专门用来在注册阶段与TA进行信息交互的两个smc指令的第二个参数也可以采用其他数值,保证创建映射A 的值域与所述其他数值不同即可。Specifically, the target smc command of NW in the ordinary world can be [smc hash(pkg_name), 1, addr_start, addr_end] command, and the hardened TA obtains the start address and end address through the target smc command of NW. Among them, [smc hash(pkg_name), 0] and [smc hash(pkg_name), 1, addr_start, addr_end], the second parameters 0 and 1 of the two smc instructions are exclusively used by this system call, and are specially used in the registration phase Information exchange is performed with the hardened TA, so the two elements 0 and 1 cannot be used in the value field of the server-side hardened creation map A. However, in a specific implementation, the second parameter of the two smc commands specially used for information exchange with the TA during the registration phase may also use other values, so as to ensure that the value range of creating the mapping A is different from the other values.
步骤203,在安全世界SW的TA中,根据起始地址和结束地址,确定加固后的第二壳程序中的非隐藏代码区间,并计算非隐藏代码区间的哈希值; Step 203, in the TA of the secure world SW, according to the start address and the end address, determine the non-hidden code interval in the hardened second shell program, and calculate the hash value of the non-hidden code interval;
具体而言,SW加固TA根据起始地址和结束地址(addr_start,addr_end)定位受保护app的shell.so文件的所有非隐藏代码区间,分别计算所有非隐藏代码区间的哈希值,其中,非隐藏代码区间是shell.so的不变区间。shell.so的不变区间是除smc指令后分成很多块的,服务器给每一块的不变区间计算哈希值,有多少个不变区间就有多少个哈希值。可选的,也可以根据所有不变区间的哈希值再计算一个哈希值作为所有不变区间的哈希值。Specifically, SW hardening TA locates all non-hidden code intervals of the shell.so file of the protected app according to the start address and end address (addr_start, addr_end), and calculates the hash values of all non-hidden code intervals, among which, non- The code-behind section is an invariant section of shell.so. The invariant interval of shell.so is divided into many blocks after excluding the smc command. The server calculates the hash value for the invariant interval of each block, and there are as many hash values as there are invariant intervals. Optionally, another hash value may be calculated as the hash value of all the constant intervals according to the hash values of all the constant intervals.
在一个例子中,在加固后的第二壳程序的预设位置插入有用于触发动态完整性验证的smc指令,在根据起始地址和结束地址,确定加固后的第二壳程序中的非隐藏代码区间之后,还可以根据起始地址和结束地址,计算并存储加固后的第二壳程序的哈希值;其中,加固后的第二壳程序的哈希值用于在受保护应用运行的过程中作为动态完整性验证的基准值,也就是说SW中的加固TA记录受保护应用的shell.so地址区间(addr_start,addr_end),计算shell.so的哈希值进行记录为后续动态完整性验证的基准值。In one example, an smc instruction for triggering dynamic integrity verification is inserted into a preset position of the hardened second shell program, and a non-hidden key in the hardened second shell program is determined according to the start address and end address After the code section, the hash value of the hardened second shell program can also be calculated and stored according to the start address and end address; wherein, the hash value of the hardened second shell program is used for running the protected application. In the process, it is used as the benchmark value of dynamic integrity verification, that is to say, the hardened TA in SW records the shell.so address range (addr_start, addr_end) of the protected application, and calculates the hash value of shell.so to record as subsequent dynamic integrity Validated baseline value.
需要注意的是,SW加固TA在注册阶段保存的app信息有:(pkg_name,addr_start,addr_end,hash(mem[addr_start,addr_end]))。这些信息通过HashMap存储在TEE的安全内存中,称为Map_enforce,攻击者无法获取。在终端运行时,壳程序中的shell.so不再发生变化(不变区间加上所有smc指令都不能变了),本次哈希值计算是基于壳程序shell.so的全部内容计算的哈希值,可以在受保护应用运行过程中验证壳程序shell.so是否被篡改过,在未被篡改的情况下在所述SW的TA中注册所述受保护应用,保证运行过程中的安全性。It should be noted that the app information saved by the SW hardened TA during the registration phase includes: (pkg_name, addr_start, addr_end, hash(mem[addr_start, addr_end])). These information are stored in the secure memory of TEE through HashMap, called Map_enforce, which cannot be obtained by attackers. When the terminal is running, the shell.so in the shell program will no longer change (the constant interval plus all smc commands cannot be changed), and this hash value calculation is based on the entire content of the shell program shell.so. Hash value, can verify whether the shell program shell.so has been tampered with during the running process of the protected application, and register the protected application in the TA of the SW if it has not been tampered with, ensuring the security during the running process .
步骤204,若非隐藏代码区间的哈希值与共享信息相同,则在SW的TA中注册受保护应用。 Step 204, if the hash value of the non-concealed code interval is the same as the shared information, register the protected application in the TA of the SW.
具体而言,计算非隐藏代码区间的哈希值后,与共享信息中进行比较。如果发现存在不一致的区间,立即向加固代理返回注册失败信息,由NW的加固代理终止受保护app的运行。如果所有不变区间验证通过则在SW的TA中注册受保护应用。Specifically, after calculating the hash value of the non-hidden code interval, it is compared with the shared information. If an inconsistent interval is found, the registration failure information will be returned to the reinforcement agent immediately, and the NW reinforcement agent will terminate the operation of the protected app. If all invariant intervals pass the verification, the protected application is registered in the TA of the SW.
在一个例子中,在SW的TA中注册受保护应用之后,还包括:在SW的TA中查询与所述受保护应用的名称标识对应的第二映射关系,并将受保护应用的名称标识与第二映射关系绑定。具体而言,在上一个实施例加固方法中,生成受保护应用对应的TA镜像,将TA镜像编译到终端的操作系统中后,TA镜像中包含了受保护应用的名称标识对应的第二映射关系,在注册阶段将受保护应用的名称标识与所述第二映射关系绑定,方便了后续受保护应用运行时,可以根据smc指令携带的受保护应用的名称标识得到该第二映射关系,从而基于该第二映射关系得到smc指令携带的混淆参数对应的待隐藏对象。In an example, after registering the protected application in the TA of the SW, it further includes: querying the second mapping relationship corresponding to the name identifier of the protected application in the TA of the SW, and combining the name identifier of the protected application with the The second mapping relationship is bound. Specifically, in the hardening method in the previous embodiment, the TA image corresponding to the protected application is generated, and after the TA image is compiled into the operating system of the terminal, the TA image contains the second mapping corresponding to the name identifier of the protected application In the registration phase, the name identifier of the protected application is bound to the second mapping relationship, so that when the subsequent protected application is running, the second mapping relationship can be obtained according to the name identifier of the protected application carried by the smc command, Therefore, the object to be hidden corresponding to the obfuscation parameter carried by the smc instruction is obtained based on the second mapping relationship.
本公开实施例还提供了一种运行方法,用于运行上述实施例的注册方法注册的受保护应用,包括:在运行受保护应用的过程中,当在安全世界SW的TA中接收到受保护应用的smc指令时,确定smc指令对应的待隐藏对象;根据待隐藏对象所表征的语义,在安全世界SW的TA中执行待隐藏对象。其中,受保护应用的smc指令携带混淆参数和所述受保护应用的名称标识,根据受保护应用的名称标识,确定与受保护应用的名称标识绑定的第二映射关系;根据绑定的第二映射关系,确定与smc指令携带的混淆参数对应的待隐藏对象,根据待隐藏 对象所表征的语义,在安全世界SW的TA中执行待隐藏对象。在具体实施中,如图7所示:An embodiment of the present disclosure also provides an operation method for running the protected application registered by the registration method of the above embodiment, including: during the process of running the protected application, when the protected application is received in the TA of the secure world SW When applying the smc instruction, determine the object to be hidden corresponding to the smc instruction; execute the object to be hidden in the TA of the secure world SW according to the semantics represented by the object to be hidden. Wherein, the smc command of the protected application carries the confusion parameter and the name identifier of the protected application, and according to the name identifier of the protected application, determines the second mapping relationship bound to the name identifier of the protected application; according to the bound first The second mapping relationship is to determine the object to be hidden corresponding to the obfuscation parameter carried by the smc command, and execute the object to be hidden in the TA of the safe world SW according to the semantics represented by the object to be hidden. In the specific implementation, as shown in Figure 7:
步骤301,收到受保护应用的smc指令; Step 301, receiving the smc instruction of the protected application;
具体而言,在运行受保护应用的过程中,安全世界SW的TA中接收到受保护应用的smc指令,例如smc指令为[smc hash(pkg_name),a],hash(pkg_name)为包名参数,a为混淆参数。Specifically, in the process of running the protected application, the TA of the safe world SW receives the smc command of the protected application, for example, the smc command is [smc hash(pkg_name), a], and hash(pkg_name) is the package name parameter , a is the confusion parameter.
步骤302,确定smc指令对应的待隐藏对象; Step 302, determining the object to be hidden corresponding to the smc instruction;
具体而言,根据受保护应用的名称标识,确定与受保护应用的名称标识绑定的第二映射关系;根据绑定的第二映射关系,确定与smc指令携带的混淆参数对应的待隐藏对象,从而得到待隐藏对象所表征的语义。Specifically, according to the name identifier of the protected application, determine the second mapping relationship bound to the name identifier of the protected application; according to the bound second mapping relationship, determine the object to be hidden corresponding to the confusion parameter carried by the smc instruction , so as to obtain the semantics represented by the object to be hidden.
步骤303,根据待隐藏对象所表征的语义,在安全世界SW的TA中执行待隐藏对象所表征的语义; Step 303, according to the semantics represented by the object to be hidden, execute the semantics represented by the object to be hidden in the TA of the secure world SW;
其中,待隐藏对象所表征的语义即为:关键指令所表征的语义、关键代码片段所表征的语义或是关键函数所表征的语义。安全世界SW的TA可以根据关键指令以及关键代码片段的语义,修改NW的寄存器或者内存,完成后将NW的pc指针指向smc的下一条指令然后直接返回NW继续执行。同理,关键函数的模拟执行与关键指令以及关键代码片段执行过程基本相同,从NW堆栈中获取到smc指令携带的参数后执行,将结果反馈到NW堆栈后返回NW继续执行。其中,生成可信应用TA模拟执行待隐藏对象的逻辑代码是在加固TA里执行,加固TA需要处理各种各样的逻辑隐藏对象,每种隐藏逻辑需要加固TA设置一个处理模块来负责执行,这个处理模块为就是handler0,比如说是关键指令模拟执行handler、关键代码片段模拟执行handler,关键函数模拟执行handler,动态完整性校验handler。The semantics represented by the object to be hidden are: the semantics represented by key instructions, the semantics represented by key code fragments, or the semantics represented by key functions. The TA of Safe World SW can modify the register or memory of NW according to the semantics of key instructions and key code fragments, and after completion, point the pc pointer of NW to the next instruction of smc and then directly return to NW to continue execution. Similarly, the simulation execution of key functions is basically the same as the execution of key instructions and key code fragments. The parameters carried by the smc instruction are obtained from the NW stack and then executed, and the results are fed back to the NW stack and then returned to NW to continue execution. Among them, the logic code that generates the trusted application TA to simulate and execute the object to be hidden is executed in the hardened TA. The hardened TA needs to process various logical hidden objects. Each hidden logic requires the hardened TA to set up a processing module to be responsible for execution. This processing module is handler0, for example, the key instruction simulation execution handler, the key code fragment simulation execution handler, the key function simulation execution handler, and the dynamic integrity verification handler.
在一个例子中,在安全世界SW的TA中执行待隐藏对象所表征的语义时要切换的时候,SW需要用到NW寄存器,就涉及寄存器传递的问题,可以用堆栈传递把SW寄存器的相关状态设置成NW寄存器的相关状态。比如,smc指令为smc(app_name,76),相关状态即可以只设置app_name、76那两个部分。比如,要执行smc(app_name,76)这个指令对应的待隐藏对象所表征的语义,可以传递两个参数,一个是app_name,一个是76,这两个参数可以占两个寄存器,通过堆栈保存的方式,从NW传递到SW,然后在SW里将这两个参数拷贝到对应的比如X1、X2寄存器上,让SW模拟执行smc(app_name,76)这个指令对应的待隐藏对象所表征的语义。In one example, when the semantics represented by the object to be hidden is switched in the TA of the safe world SW, the SW needs to use the NW register, which involves the issue of register transfer, and the relevant state of the SW register can be transferred by stack Set to the relevant state of the NW register. For example, the smc instruction is smc(app_name, 76), and only the two parts of app_name and 76 can be set in the relevant state. For example, to execute the semantics represented by the object to be hidden corresponding to the instruction smc(app_name, 76), two parameters can be passed, one is app_name, and the other is 76. These two parameters can occupy two registers and are saved through the stack. The way is to transfer from NW to SW, and then copy these two parameters to the corresponding registers such as X1 and X2 in SW, and let SW simulate and execute the semantics represented by the object to be hidden corresponding to the instruction smc(app_name, 76).
步骤304,动态完整性校验是否通过; Step 304, whether the dynamic integrity check is passed;
具体而言,在运行受保护应用的过程中,当执行到用于触发动态完整性验证的smc指令时,根据加固后的第二壳程序在内存中的起始地址和结束地址,计算当前运行的加固后的第二壳程序的当前哈希值;判断当前哈希值与存储的动态完整性验证的共享信息是否相同。Specifically, in the process of running the protected application, when the smc instruction for triggering dynamic integrity verification is executed, the current running The current hash value of the hardened second shell program; determine whether the current hash value is the same as the stored shared information for dynamic integrity verification.
步骤305,返回NW继续执行; Step 305, return to NW to continue execution;
若当前哈希值与存储的动态完整性验证的基准值相同,也就是说,加固TA根据受保护应用在启动时注册的addr_start与addr_end信息计算shell.so非隐藏区间的哈希值,与共享信息的已知值进行比较,若发现区间一致,则返回NW的shell.so继续执行。If the current hash value is the same as the stored benchmark value of dynamic integrity verification, that is, the hardened TA calculates the hash value of the non-hidden interval of shell. The known value of the information is compared, and if the interval is found to be consistent, the shell.so of NW is returned to continue execution.
步骤306,返回NW加固代理停止进程。 Step 306, return to the NW hardening agent to stop the process.
具体而言,加固TA根据受保护应用在启动时注册的addr_start与addr_end信息计算shell.so非隐藏区间的哈希值,与共享信息的已知值进行比较,若发现存在不一致的区间,则动态完整性校验未通过,立即向加固代理返回动态完整性校验未通过的信息,由NW加固代 理停止此受保护app的运行。Specifically, the hardened TA calculates the hash value of the non-hidden interval of shell.so based on the addr_start and addr_end information registered by the protected application at startup, and compares it with the known value of the shared information. If an inconsistent interval is found, it dynamically If the integrity check fails, immediately return the information that the dynamic integrity check fails to the hardening agent, and the NW hardening agent stops the running of the protected app.
本实施例提供的运行方法,能够完全阻止攻击者对NW中shell.so的静态分析,因为逻辑隐藏后的shell.so完全不存在任何完整的语义信息;此外,本公开能够极大地增加动态分析的难度,因为安全假设为攻击者无法攻破TEE从中获取处理smc请求的handler,攻击者只能在NW中调试shell.so,在smc指令前后分析整个处理器状态以及内存空间的变化,在当前设备的处理器复杂度以及超大内存空间的前提下,这个搜索空间是非常大的,后续的逻辑分析则更加艰难,本公开实施例能够提供非常高的壳程序保护安全性。The operation method provided by this embodiment can completely prevent an attacker from statically analyzing shell.so in NW, because the shell.so after logic hiding does not have any complete semantic information at all; in addition, this disclosure can greatly increase dynamic analysis The difficulty is because the security assumption is that the attacker cannot break through the TEE to obtain the handler for processing the smc request. The attacker can only debug shell.so in the NW, and analyze the changes of the entire processor state and memory space before and after the smc command. In the current device Under the premise of the complexity of the processor and the large memory space, the search space is very large, and the subsequent logical analysis is more difficult. The embodiments of the present disclosure can provide very high shell program protection security.
上面各种方法的步骤划分,只是为了描述清楚,实现时可以合并为一个步骤或者对某些步骤进行拆分,分解为多个步骤,只要包括相同的逻辑关系,都在本专利的保护范围内;对算法中或者流程中添加无关紧要的修改或者引入无关紧要的设计,但不改变其算法和流程的核心设计都在该专利的保护范围内。The step division of the above various methods is only for the sake of clarity of description. During implementation, it can be combined into one step or some steps can be split and decomposed into multiple steps. As long as they include the same logical relationship, they are all within the scope of protection of this patent. ; Adding insignificant modifications or introducing insignificant designs to the algorithm or process, but not changing the core design of the algorithm and process are all within the scope of protection of this patent.
本公开实施例还提供了一种电子设备,如图8所示,包括:至少一个处理器701;以及,与至少一个处理器通信连接的存储器702;其中,在电子设备为服务器的情况下,存储器702存储有可被至少一个处理器701执行的指令,所述指令被所述至少一个处理器701执行,以使所述至少一个处理器701能够执行上述的加固方法;在所述电子设备为终端的情况下,所述存储器702存储有可被所述至少一个处理器701执行的指令,所述指令被所述至少一个处理器701执行,以使所述至少一个处理器701能够执行上述的注册方法,或者执行上述的运行方法。An embodiment of the present disclosure also provides an electronic device, as shown in FIG. 8 , including: at least one processor 701; and a memory 702 communicatively connected to at least one processor; wherein, when the electronic device is a server, The memory 702 stores instructions that can be executed by at least one processor 701, and the instructions are executed by the at least one processor 701, so that the at least one processor 701 can perform the above-mentioned strengthening method; In the case of a terminal, the memory 702 stores instructions executable by the at least one processor 701, and the instructions are executed by the at least one processor 701, so that the at least one processor 701 can execute the above-mentioned Register method, or execute the run method above.
其中,存储器和处理器采用总线方式连接,总线可以包括任意数量的互联的总线和桥,总线将一个或多个处理器和存储器的各种电路连接在一起。总线还可以将诸如外围设备、稳压器和功率管理电路等之类的各种其他电路连接在一起,这些都是本领域所公知的,因此,本文不再对其进行进一步描述。总线接口在总线和收发机之间提供接口。收发机可以是一个元件,也可以是多个元件,比如多个接收器和发送器,提供用于在传输介质上与各种其他装置通信的单元。经处理器处理的数据通过天线在无线介质上进行传输,进一步,天线还接收数据并将数据传送给处理器。Wherein, the memory and the processor are connected by a bus, and the bus may include any number of interconnected buses and bridges, and the bus connects one or more processors and various circuits of the memory together. The bus may also connect together various other circuits such as peripherals, voltage regulators, and power management circuits, all of which are well known in the art and therefore will not be further described herein. The bus interface provides an interface between the bus and the transceivers. A transceiver may be a single element or multiple elements, such as multiple receivers and transmitters, providing means for communicating with various other devices over a transmission medium. The data processed by the processor is transmitted on the wireless medium through the antenna, further, the antenna also receives the data and transmits the data to the processor.
处理器负责管理总线和通常的处理,还可以提供各种功能,包括定时,外围接口,电压调节、电源管理以及其他控制功能。而存储器可以被用于存储处理器在执行操作时所使用的数据。The processor is responsible for managing the bus and general processing, and can also provide various functions, including timing, peripheral interface, voltage regulation, power management, and other control functions. Instead, memory can be used to store data that the processor uses when performing operations.
为实现上述目的,本公开实施例还提供了一种计算机可读存储介质,存储有计算机程序,计算机程序被处理器执行时实现上述的加固方法,或者实现上述任一的注册方法,或者实现上述的运行方法。In order to achieve the above purpose, an embodiment of the present disclosure also provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the above-mentioned hardening method is realized, or any of the above-mentioned registration methods is realized, or the above-mentioned method of operation.
即,本领域技术人员可以理解,实现上述实施例方法中的全部或部分步骤是可以通过程序来指令相关的硬件来完成,该程序存储在一个存储介质中,包括若干指令用以使得一个设备(可以是单片机,芯片等)或处理器(processor)执行本公开各个实施例方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(ROM,Read-Only Memory)、随机存取存储器(RAM,Random Access Memory)、磁碟或者光盘等各种可以存储程序代码的介质。That is, those skilled in the art can understand that all or part of the steps in the method of the above-mentioned embodiments can be completed by instructing related hardware through a program, the program is stored in a storage medium, and includes several instructions to make a device ( It may be a single chip microcomputer, a chip, etc.) or a processor (processor) to execute all or part of the steps in the methods of the various embodiments of the present disclosure. The aforementioned storage media include: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), magnetic disk or optical disc, etc., which can store program codes. .
本领域的普通技术人员可以理解,上述各实施方式是实现本公开的具体实施例,而在实 际应用中,可以在形式上和细节上对其作各种改变,而不偏离本公开的精神和范围。Those of ordinary skill in the art can understand that the above-mentioned embodiments are specific examples for realizing the present disclosure, and in practical applications, various changes can be made in form and details without departing from the spirit and spirit of the present disclosure. scope.

Claims (14)

  1. 一种加固方法,应用于服务端,包括:A reinforcement method applied to the server, including:
    确定受保护应用的第一壳程序中的各待隐藏对象;determining objects to be hidden in the first shell of the protected application;
    确定与所述待隐藏对象对应的安全监控模式调用smc指令;Determining that the security monitoring mode corresponding to the object to be hidden calls the smc command;
    将所述待隐藏对象替换为与所述待隐藏对象对应的smc指令,得到加固后的第二壳程序;The object to be hidden is replaced with the smc instruction corresponding to the object to be hidden to obtain the second shell program after reinforcement;
    根据所述加固后的第二壳程序,对所述受保护应用的应用程序包APK进行加固,得到加固后的APK。According to the second hardened shell program, the application package APK of the protected application is hardened to obtain the hardened APK.
  2. 根据权利要求1所述的加固方法,其中,所述确定与所述待隐藏对象对应的安全监控模式调用smc指令,包括:The reinforcement method according to claim 1, wherein the determining that the security monitoring mode corresponding to the object to be hidden calls an smc instruction includes:
    获取所述受保护应用的特征信息和所述待隐藏对象的身份标识;Obtaining the feature information of the protected application and the identity of the object to be hidden;
    根据所述特征信息,生成所述待隐藏对象的身份标识与混淆参数的第一映射关系;Generate a first mapping relationship between the identity of the object to be hidden and the confusion parameter according to the characteristic information;
    根据所述第一映射关系,确定所述待隐藏对象的身份标识映射出的混淆参数对应的smc指令。According to the first mapping relationship, determine the smc instruction corresponding to the obfuscation parameter mapped from the identity of the object to be hidden.
  3. 根据权利要求1所述的加固方法,其中,所述待隐藏对象包括以下任意之一或其组合:The reinforcement method according to claim 1, wherein the object to be hidden comprises any one of the following or a combination thereof:
    所述第一壳程序中的关键指令、关键代码片段、关键函数。Key instructions, key code fragments, and key functions in the first shell program.
  4. 根据权利要求1至3任一项所述的加固方法,其中,在所述确定受保护应用的第一壳程序中的待隐藏对象之后,还包括:The strengthening method according to any one of claims 1 to 3, wherein, after determining the object to be hidden in the first shell program of the protected application, further comprising:
    确定所述受保护应用的第一壳程序中相邻的所述待隐藏对象之间的非隐藏代码区间;determining a non-hidden code interval between adjacent objects to be hidden in the first shell program of the protected application;
    计算所述非隐藏代码区间的哈希值,并将所述哈希值作为所述服务端和注册所述受保护应用的终端之间的共享信息;calculating a hash value of the non-hidden code interval, and using the hash value as shared information between the server and the terminal registering the protected application;
    当编译安全世界SW的可信应用TA时,将所述共享信息编译到所述终端的操作系统中;其中,所述共享信息用于供所述终端在注册所述受保护应用时验证所述受保护应用的安全性。When compiling the trusted application TA of the secure world SW, compile the shared information into the operating system of the terminal; wherein, the shared information is used for the terminal to verify the Security of protected apps.
  5. 根据权利要求4所述的加固方法,其中,在所述根据所述特征信息,生成所述待隐藏对象的身份标识与混淆参数的第一映射关系之后,还包括:The strengthening method according to claim 4, wherein, after generating the first mapping relationship between the identity of the object to be hidden and the confusion parameter according to the feature information, further comprising:
    根据所述第一映射关系生成第二映射关系;其中,所述第二映射关系与所述第一映射关系互为反向映射;generating a second mapping relationship according to the first mapping relationship; wherein, the second mapping relationship and the first mapping relationship are reverse mappings;
    生成可信应用TA模拟执行所述待隐藏对象的逻辑代码;Generate a trusted application TA to simulate and execute the logic code of the object to be hidden;
    当编译安全世界SW的可信应用TA时,根据所述第二映射关系、所述非隐藏代码区间的哈希值和所述逻辑代码,生成所述受保护应用对应的可信应用TA镜像,并将所述TA镜像编译到所述终端的操作系统中。When compiling the trusted application TA of the secure world SW, according to the second mapping relationship, the hash value of the non-hidden code interval and the logic code, generate the trusted application TA image corresponding to the protected application, and compiling the TA image into the operating system of the terminal.
  6. 一种注册方法,应用于终端,包括:A registration method applied to a terminal, including:
    当检测到一APK被安装后,确定所述APK对应的受保护应用是否在安全世界SW的可信应用TA中被注册;其中,所述APK为基于权利要求1至5任一项所述的加固方法得到的加固后的APK;After detecting that an APK is installed, determine whether the protected application corresponding to the APK is registered in the trusted application TA of the secure world SW; wherein the APK is based on any one of claims 1 to 5 The hardened APK obtained by the hardening method;
    若所述受保护应用未在安全世界SW的可信应用TA中被注册,在所述SW的TA中注册所述受保护应用。If the protected application is not registered in the trusted application TA of the secure world SW, register the protected application in the TA of the SW.
  7. 根据权利要求6所述的注册方法,其中,服务端在编译安全世界SW的可信应用TA 时,将服务端和所述终端之间的共享信息编译到所述终端的操作系统中;The registration method according to claim 6, wherein, when compiling the trusted application TA of the secure world SW, the server compiles the shared information between the server and the terminal into the operating system of the terminal;
    所述在所述SW的TA中注册所述受保护应用,包括:The registering the protected application in the TA of the SW includes:
    在普通世界NW中,查找加固后的第二壳程序在内存中的起始地址和结束地址;In the normal world NW, find the start address and end address of the hardened second shell program in memory;
    在安全世界SW的TA中,根据来自所述普通世界NW的目标smc指令,获取所述目标smc指令携带的所述起始地址和所述结束地址;In the TA of the secure world SW, according to the target smc command from the normal world NW, obtain the start address and the end address carried by the target smc command;
    在安全世界SW的TA中,根据所述起始地址和所述结束地址,确定所述加固后的第二壳程序中的非隐藏代码区间,并计算所述非隐藏代码区间的哈希值;In the TA of the secure world SW, according to the start address and the end address, determine the non-hidden code interval in the second hardened shell program, and calculate the hash value of the non-hidden code interval;
    若所述非隐藏代码区间的哈希值与所述共享信息相同,则在所述SW的TA中注册所述受保护应用。If the hash value of the non-hidden code interval is the same as the shared information, register the protected application in the TA of the SW.
  8. 根据权利要求7所述的注册方法,其中,所述加固后的第二壳程序的预设位置插入有用于触发动态完整性验证的smc指令,在所述根据所述起始地址和所述结束地址,确定所述加固后的第二壳程序中的非隐藏代码区间之后,还包括:The registration method according to claim 7, wherein an smc command for triggering dynamic integrity verification is inserted into the preset position of the second shell program after hardening, and in the The address, after determining the non-hidden code section in the second hardened shell program, further includes:
    根据所述起始地址和所述结束地址,计算并存储所述加固后的第二壳程序的哈希值;其中,所述加固后的第二壳程序的哈希值用于在所述受保护应用运行的过程中作为动态完整性验证的基准值。According to the start address and the end address, calculate and store the hash value of the second shell program after hardening; wherein, the hash value of the second shell program after hardening is used in the During the running of the protection application, it is used as a benchmark value for dynamic integrity verification.
  9. 根据权利要求6-8任一项所述的注册方法,其中,在所述SW的TA中注册所述受保护应用之后,还包括:The registration method according to any one of claims 6-8, wherein, after registering the protected application in the TA of the SW, further comprising:
    在所述SW的TA中查询与所述受保护应用的名称标识对应的第二映射关系,并将所述受保护应用的名称标识与所述第二映射关系绑定。Querying the second mapping relationship corresponding to the name identifier of the protected application in the TA of the SW, and binding the name identifier of the protected application to the second mapping relationship.
  10. 一种运行方法,用于运行基于权利要求6至9任一项所述的注册方法注册的受保护应用,所述方法包括:An operating method for operating a protected application registered based on the registration method described in any one of claims 6 to 9, the method comprising:
    在运行所述受保护应用的过程中,当在安全世界SW的TA中接收到所述受保护应用的smc指令时,确定所述smc指令对应的待隐藏对象;During the process of running the protected application, when the smc instruction of the protected application is received in the TA of the secure world SW, determine the object to be hidden corresponding to the smc instruction;
    根据所述待隐藏对象所表征的语义,在安全世界SW的TA中执行所述待隐藏对象。According to the semantics represented by the object to be hidden, the object to be hidden is executed in the TA of the secure world SW.
  11. 根据权利要求10所述的运行方法,其中,所述受保护应用的smc指令携带混淆参数和所述受保护应用的名称标识;The running method according to claim 10, wherein, the smc instruction of the protected application carries an obfuscation parameter and the name identifier of the protected application;
    所述确定所述smc指令对应的待隐藏对象,包括:Said determining the object to be hidden corresponding to said smc instruction includes:
    根据所述受保护应用的名称标识,确定与所述受保护应用的名称标识绑定的第二映射关系;Determine a second mapping relationship bound to the name identifier of the protected application according to the name identifier of the protected application;
    根据所述绑定的第二映射关系,确定与所述smc指令携带的混淆参数对应的待隐藏对象。An object to be hidden corresponding to the obfuscation parameter carried by the smc instruction is determined according to the bound second mapping relationship.
  12. 根据权利要求10所述的运行方法,其中,所述方法还包括:The operating method according to claim 10, wherein said method further comprises:
    在运行所述受保护应用的过程中,当执行到用于触发动态完整性验证的smc指令时,根据加固后的第二壳程序在内存中的起始地址和结束地址,计算当前运行的所述加固后的第二壳程序的当前哈希值;During the process of running the protected application, when the smc instruction for triggering the dynamic integrity verification is executed, according to the start address and end address of the hardened second shell program in the memory, calculate all currently running programs. The current hash value of the hardened second shell program;
    当所述当前哈希值与存储的动态完整性验证的基准值相同,则继续运行所述受保护应用。When the current hash value is the same as the stored reference value for dynamic integrity verification, continue to run the protected application.
  13. 一种电子设备,包括:至少一个处理器;以及,An electronic device comprising: at least one processor; and,
    与所述至少一个处理器通信连接的存储器;其中,a memory communicatively coupled to the at least one processor; wherein,
    在所述电子设备为服务器的情况下,所述存储器存储有可被所述至少一个处理器执行的指令,所述指令被所述至少一个处理器执行,以使所述至少一个处理器能够执行如权利要求 1至5中任一所述的加固方法;When the electronic device is a server, the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute The reinforcing method according to any one of claims 1 to 5;
    在所述电子设备为终端的情况下,所述存储器存储有可被所述至少一个处理器执行的指令,所述指令被所述至少一个处理器执行,以使所述至少一个处理器能够执行如权利要求6至9中任一所述的注册方法,或者执行如权利要求10至12中任一所述的运行方法。In the case where the electronic device is a terminal, the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute The registration method according to any one of claims 6 to 9, or execute the operation method according to any one of claims 10 to 12.
  14. 一种计算机可读存储介质,存储有计算机程序,所述计算机程序被处理器执行时实现权利要求1至5中任一所述的加固方法,或者实现如权利要求6至9中任一所述的注册方法,或者实现如权利要求10至12中任一所述的运行方法。A computer-readable storage medium, storing a computer program, when the computer program is executed by a processor, implements the strengthening method described in any one of claims 1 to 5, or implements the method described in any one of claims 6 to 9 registration method, or implement the operation method as described in any one of claims 10 to 12.
PCT/CN2022/117070 2021-09-23 2022-09-05 Reinforcement method, registration method, running method, electronic device and storage medium WO2023045744A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202111115444.6 2021-09-23
CN202111115444.6A CN115859225A (en) 2021-09-23 2021-09-23 Reinforcement method, registration method, operation method, electronic device, and storage medium

Publications (1)

Publication Number Publication Date
WO2023045744A1 true WO2023045744A1 (en) 2023-03-30

Family

ID=85653003

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/117070 WO2023045744A1 (en) 2021-09-23 2022-09-05 Reinforcement method, registration method, running method, electronic device and storage medium

Country Status (2)

Country Link
CN (1) CN115859225A (en)
WO (1) WO2023045744A1 (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2016188134A1 (en) * 2015-05-22 2016-12-01 中兴通讯股份有限公司 Application reinforcing implementation method and apparatus
CN106897587A (en) * 2017-02-27 2017-06-27 百度在线网络技术(北京)有限公司 The method and apparatus of reinforcement application, loading reinforcement application
CN109784057A (en) * 2019-01-04 2019-05-21 国家计算机网络与信息安全管理中心 Recognition methods, controller and medium are reinforced in Android application
US20190163450A1 (en) * 2017-11-30 2019-05-30 Google Llc Systems and methds of developments, testing, and distribution of applications in a computer network
CN110008693A (en) * 2019-04-12 2019-07-12 深圳市趣创科技有限公司 Security application encrypts ensuring method and device and system and storage medium

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2016188134A1 (en) * 2015-05-22 2016-12-01 中兴通讯股份有限公司 Application reinforcing implementation method and apparatus
CN106897587A (en) * 2017-02-27 2017-06-27 百度在线网络技术(北京)有限公司 The method and apparatus of reinforcement application, loading reinforcement application
US20190163450A1 (en) * 2017-11-30 2019-05-30 Google Llc Systems and methds of developments, testing, and distribution of applications in a computer network
CN109784057A (en) * 2019-01-04 2019-05-21 国家计算机网络与信息安全管理中心 Recognition methods, controller and medium are reinforced in Android application
CN110008693A (en) * 2019-04-12 2019-07-12 深圳市趣创科技有限公司 Security application encrypts ensuring method and device and system and storage medium

Also Published As

Publication number Publication date
CN115859225A (en) 2023-03-28

Similar Documents

Publication Publication Date Title
US11520611B2 (en) Secure public cloud using extended paging and memory integrity
Weiser et al. TIMBER-V: Tag-isolated memory bringing fine-grained enclaves to RISC-V
KR102255767B1 (en) Systems and methods for virtual machine auditing
US11093601B2 (en) Dynamic switching between pointer authentication regimes
CN109918919B (en) Management of authentication variables
US6978018B2 (en) Technique to support co-location and certification of executable content from a pre-boot space into an operating system runtime environment
US8375221B1 (en) Firmware-based trusted platform module for arm processor architectures and trustzone security extensions
US6941458B1 (en) Managing a secure platform using a hierarchical executive architecture in isolated execution mode
US20060179308A1 (en) System and method for providing a secure boot architecture
CN101297280B (en) Configuration of isolated extensions and device drivers
US7194634B2 (en) Attestation key memory device and bus
JP5410445B2 (en) Know-Gut code for on-chip device management
US20100031370A1 (en) Software enhanced trusted platform module
CN105205401A (en) Trusted computer system based on safe password chip and trusted guiding method thereof
US10218508B2 (en) Methods and apparatus to provide isolated execution environments
US20110016463A1 (en) Computer-hardware, life-extension apparatus and method
WO2022017242A1 (en) Method and apparatus for running second system application in first system, device, and medium
WO2023045744A1 (en) Reinforcement method, registration method, running method, electronic device and storage medium
CN112685101A (en) Trusted execution environment-oriented system call processing method and device
US20240119139A1 (en) Securing critical data in a storage device of a computer system
Nunes et al. A verified architecture for proofs of execution on remote devices under full software compromise
Dettenborn Open virtual trusted execution environment
dos Santos TrustFrame, a Software Development Framework for TrustZone-enabled Hardware
Iooss et al. Ghost in the Wireless, iwlwifi edition

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 22871793

Country of ref document: EP

Kind code of ref document: A1