Code reinforcement method, device and equipment and readable storage medium
By injecting dynamic libraries on the client, extracting and storing application code naming, and strengthening the code to be reinforced based on the database, the problem of lack of semantics in code naming in the existing technology is solved, improving the effect and security of code reinforcement, and ensuring compliance sex.
Patent Information
- Application Number
- CN202410981102.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-19
- Publication Date
- 2024-11-12
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Among the existing code reinforcement methods, the reinforcement method of randomized renaming causes code naming to lack semantics, difficult to identify, and does not conform to programming habits, reduces the reinforcement effect, and may be detected by the application store as illegal junk code, resulting in listing problems.
By injecting dynamic libraries in advance on the client, obtaining installation response, extracting application installation packages, extracting code names and storing them to the database, strengthening the code to be reinforced based on the database, replacing it with code naming with certain semantics, ensuring that the reinforced code conforms to the Programming habits.
Improve the effectiveness and security of code reinforcement, avoiding the reinforced code being detected as a violation, and improving the compliance and difficulty of identification of application code.
Smart Images

Figure CN118939240A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a code reinforcement method, device, equipment and readable storage medium. Background Art
[0002] In order to prevent attackers from illegally obtaining source code through reverse engineering, code hardening methods can be used to convert the source code of the program, increase the complexity of the source code of the program, and make it difficult to understand, analyze and reverse engineer without changing the function of the program, thereby preventing the application from being pirated, attacked or maliciously modified.
[0003] Currently, the source code is usually obfuscated by replacing the variable names, function names, class names and other elements of the source code with meaningless random strings to achieve code reinforcement.
[0004] However, in the above scheme, random strings usually lack semantics and do not conform to programming habits, resulting in poor effect of simulating artificial obfuscation of the hardened code. Experienced attackers can relatively easily identify code segments that have no actual functions, thereby reducing the effect of code hardening. Summary of the invention
[0005] This specification provides a code hardening method, device, equipment and readable storage medium to partially solve the above-mentioned problems existing in the prior art.
[0006] This manual adopts the following technical solutions:
[0007] This manual provides a code reinforcement method, including:
[0008] Injecting a dynamic library into the client in advance, and obtaining the installation response received by the client through the dynamic library;
[0009] Receiving an installation response sent after the dynamic library is acquired, and extracting each installation package acquisition address from the installation response;
[0010] Acquire each application installation package according to the address of each installation package, and extract the executable file of each application from each application installation package;
[0011] Extracting each code name from the executable file of each application, and storing each code name in a database;
[0012] In response to the code reinforcement request, the application code to be reinforced is obtained, and reinforcement processing is performed on the application code to be reinforced according to the code names stored in the database to obtain the reinforced application code.
[0013] Optionally, the acquiring, through the dynamic library, the installation response received by the client specifically includes:
[0014] Sending an installation package acquisition signal to the client, so that the client generates an installation package acquisition request in response to the installation package acquisition signal, and sends the installation package acquisition request to the backend server;
[0015] When the backend server sends an installation response to the client in response to the installation package acquisition request, the installation response is acquired through the dynamic library.
[0016] Optionally, acquiring each application installation package according to each installation package acquisition address specifically includes:
[0017] Distribute the installation package acquisition addresses to each sub-server;
[0018] Receive each application installation package returned by each sub-server, wherein each application installation package is obtained by each sub-server according to received installation package obtaining addresses.
[0019] Optionally, extracting the executable file of each application from each application installation package specifically includes:
[0020] Re-signing each of the application installation packages respectively, and sending each of the re-signed application installation packages to the client, so that the client installs each application according to each of the re-signed application installation packages;
[0021] Sending a shell removal instruction to the client, and receiving executable files of each application returned by the client, wherein the executable files of each application are obtained by the client performing shell removal processing on each application installed on the client in response to the shell removal instruction.
[0022] Optionally, extracting each code name from the executable file of each application and storing each code name in a database specifically includes:
[0023] Determine application types corresponding to the applications;
[0024] Extracting each code name of each naming type from the executable file of each application corresponding to the application type, wherein the naming type at least includes a class name, a method name, and a protocol name;
[0025] According to extracting each code name of each naming type from the executable file of each application corresponding to the application type, a corresponding relationship among the application type, each naming type and each code name is constructed, and each code name and the corresponding relationship are stored in a database.
[0026] Optionally, the step of performing reinforcement processing on the application code to be reinforced according to each code name stored in the database to obtain the reinforced application code specifically includes:
[0027] Determine the naming types corresponding to the names of the codes to be reinforced in the application code to be reinforced, wherein the names of the codes to be reinforced include class names, method names, and protocol names;
[0028] For each code name to be reinforced, according to the code name to be reinforced and the corresponding relationship, search for a code name that matches the naming type of the code name to be reinforced from the code names stored in the database as each first target code name corresponding to the code name to be reinforced;
[0029] According to the first target code names corresponding to the code names to be reinforced, the application code to be reinforced is reinforced to obtain the reinforced code.
[0030] Optionally, the step of performing reinforcement processing on the application code to be reinforced according to each first target code name corresponding to each code name to be reinforced to obtain the reinforced code specifically includes:
[0031] Determine the target application type corresponding to the application code to be reinforced;
[0032] For each code name to be reinforced, according to the corresponding relationship, determine the application types corresponding to each first target code name corresponding to the code name to be reinforced;
[0033] Matching the application types corresponding to the first target code names corresponding to the code name to be reinforced with the target application type, and filtering out the second target code names corresponding to the code name to be reinforced from the first target code names corresponding to the code name to be reinforced;
[0034] Each code name to be reinforced contained in the application code to be reinforced is replaced with a second target code name corresponding to each code name to be reinforced, so as to obtain a reinforced application code.
[0035] This specification provides a code reinforcement device, including:
[0036] An installation response acquisition module is used to pre-inject a dynamic library into the client and acquire the installation response received by the client through the dynamic library;
[0037] An address acquisition module, used to receive an installation response sent after the dynamic library is acquired, and extract each installation package acquisition address from the installation response;
[0038] An executable file acquisition module, used to acquire each application installation package according to the address of each installation package, and extract the executable file of each application from each application installation package;
[0039] A code naming determination module, used to extract each code name from the executable file of each application, and store each code name in a database;
[0040] The reinforcement module is used to obtain the application code to be reinforced in response to the code reinforcement request, and reinforce the application code to be reinforced according to the code names stored in the database to obtain the reinforced application code.
[0041] This specification provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the above-mentioned code hardening method is implemented.
[0042] This specification provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the above-mentioned code reinforcement method when executing the program.
[0043] At least one of the above technical solutions adopted in this specification can achieve the following beneficial effects:
[0044] In the code reinforcement method provided in this specification, the installation response sent to the client is obtained in advance by inputting the client's dynamic library, and the installation package acquisition address is extracted from it, and each application installation package is obtained in this way, so as to extract the executable file of each application from it, and each code name is extracted from the executable file of each application and stored in the database. When a code reinforcement request is received, the application code to be reinforced is reinforced based on the code names stored in the database to obtain the reinforced application code. It can be seen that through the above method, the application code to be reinforced is reinforced with the code names in the executable file of the installable application, so that the code names in the reinforced application code still have certain semantics and conform to programming habits, and the recognition difficulty is large, thereby improving the effect of code reinforcement and the security of the application code. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] The drawings described herein are used to provide a further understanding of this specification and constitute a part of this specification. The exemplary embodiments and descriptions of this specification are used to explain this specification and do not constitute an improper limitation on this specification.
[0046] In the figure:
[0047] Figure 1 This is a flowchart of a code reinforcement method in this manual;
[0048] Figure 2is a schematic diagram of a code hardening system applicable to the code hardening method in this specification;
[0049] Figure 3 is a schematic diagram of a code hardening system applicable to the code hardening method in this specification;
[0050] Figure 4 This is a flowchart of a code reinforcement method in this manual;
[0051] Figure 5 This is a flowchart of a code reinforcement method in this manual;
[0052] Figure 6 A schematic diagram of a code reinforcement device provided in this specification;
[0053] Figure 7 The corresponding Figure 1 Schematic diagram of electronic equipment. DETAILED DESCRIPTION
[0054] In order to make the purpose, technical solutions and advantages of this specification more clear, the technical solutions of this specification will be clearly and completely described below in combination with the specific embodiments of this specification and the corresponding drawings. Obviously, the described embodiments are only part of the embodiments of this specification, not all of them. Based on the embodiments in this specification, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this specification.
[0055] In addition, it should be noted that all actions of acquiring signals, information or data in this manual are performed in compliance with the relevant local data protection laws and policies and with the authorization given by the owner of the corresponding device.
[0056] It should be noted that, in the absence of conflict, the features in the following embodiments and implementations may be combined with each other.
[0057] With the rapid development of computing technology, different applications have emerged on the market to achieve different functions. As a result, problems such as piracy, malicious tampering and hacker attacks of applications have become increasingly serious. The security of core code is directly related to the economic interests of enterprises and the security of user data. At present, traditional code encryption technology is not capable of preventing reverse engineering and code analysis. To this end, code hardening methods such as code obfuscation can be used to transform the source code or compiled program code so that the hardened code becomes difficult to read and understand without changing the original function. In the existing code hardening methods, the code names in the code can be changed to meaningless names by randomizing and renaming the code names such as variable and function names, making it difficult for attackers to understand the functions of these codes from the names, increasing the difficulty of cracking the code, bypassing security mechanisms or finding vulnerabilities.
[0058] However, in order to improve the reinforcement effect, the randomized renaming reinforcement method will cause the original meaningful variable names, function names and other code names in the application code to be lost, greatly increasing the difficulty of developers in subsequent maintenance and code debugging. When it is necessary to locate the problem or understand the logic of a specific part, the meaningless code naming may cause developers to confuse and misunderstand the application. In addition, random strings usually lack semantics and do not conform to programming habits, resulting in a relatively poor effect of simulated artificial obfuscation of the reinforced code. Experienced attackers can relatively easily identify code segments that do not have actual functions, thereby reducing the effect of code reinforcement. In addition, in actual applications, applications are usually exposed to users by listing them on app stores to increase downloads. As a provider of application download services, app stores will review the application code before the application is listed to prevent applications containing illegal code from being provided to users. The application code that has been reinforced by the randomized renaming method may be detected as illegal junk code and thus rejected by the app store.
[0059] Based on this, this specification provides a code hardening method, which uses the code names contained in the installable application to harden the application code to be hardened, so that the code names in the hardened application code still have certain semantics and conform to programming habits, while improving the hardening effect and ensuring the compliance of the hardened application code.
[0060] The technical solutions provided by the embodiments of this specification are described in detail below in conjunction with the accompanying drawings.
[0061] Figure 1 A flowchart of a code reinforcement method provided in this manual.
[0062] S100: Injecting a dynamic library into the client in advance, and obtaining an installation response received by the client through the dynamic library.
[0063] A code reinforcement method provided in the embodiments of this specification can be executed by an electronic device such as a server or server cluster for code reinforcement. For the convenience of explanation, this specification takes the execution subject of the code reinforcement method as a business server to explain the specific technical solution.
[0064] like Figure 2 The diagram shows the architecture of a code hardening system applicable to the code hardening method provided in this specification, wherein the code hardening system may include a backend server, a client, and a business server. The client may be an electronic device such as a smart phone, a tablet computer, a laptop computer, or a desktop computer. Both the backend server and the business server may be independent physical servers, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides cloud computing services. The backend server, the client, and the business server communicate through a communication link to receive or send messages and data, such as a wired communication link or a wireless communication link. The wireless communication link may include Bluetooth, Wi-Fi, near-field communication, a cellular mobile communication network, etc., which is not limited in this specification.
[0065] In this specification, in order to improve the effect of code reinforcement and ensure the compliance of the reinforced application code, the application code is reinforced through the naming code contained in the installable application. To this end, you can first obtain the application installation package corresponding to the installable application. In actual applications, in order to ensure the installability of the application and avoid introducing code naming that poses compliance risks into the reinforced application code, an installation request can be sent to the background server through the client, and the background server allocates an installable application to the client. In this process, the business server can obtain the corresponding application installation package or download address by obtaining the installation response received by the client. As a result, the business server can pre-set an injection point in the process or program code received by the client when executing the installation response, and deploy a dynamic library at the injection point to achieve the acquisition of the installation response.
[0066] The dynamic library used in this specification is in the form of an executable file, which contains pre-compiled functions, methods and other program components. By setting an injection point in the process or program code that executes a specific function (receiving an installation response) on the client and deploying the dynamic library at the injection point, the dynamic library can change the original execution process of the client (receiving an installation response). For example, the original execution process is that the client will directly parse the installation response after receiving the installation response and obtain the installation package acquisition address of the application. The dynamic library can change the original execution process to that the client sends the received installation response to the business server after receiving the installation response. After that, the client can still parse the installation response and obtain the installation package acquisition address of the application. It can be seen that the injection of the dynamic library will not change the inherent execution logic of the original program, but will only change the execution process, so as to obtain the installation response for the business server without destroying the original function of the client.
[0067] Optionally, since the request to the backend server for the installation package acquisition address is sent by the client, in order to improve the efficiency of obtaining the installation response, the business server may send an installation package acquisition signal to the client, instructing the client to request the backend server for the installation package acquisition address. The specific interaction process may be as follows:
[0068] First, the business server sends an installation package acquisition signal to the client. The installation package acquisition signal carries at least a first identifier of the application, so that the client determines the application for which the installation package needs to be obtained based on the first identifier, and may also carry a second identifier of the background server, so as to instruct the client to send an installation package acquisition request to the background server corresponding to the second identifier.
[0069] Secondly, the client generates an installation package acquisition request in response to the installation package acquisition signal, and sends the installation package acquisition request to the background server, wherein the installation package acquisition request carries at least the identification of the application.
[0070] Afterwards, the backend server responds to the installation package acquisition request and sends an installation response to the client. The backend server can parse the received installation package acquisition request to obtain the application identifier, and according to the application identifier, find the installation package acquisition address (such as the download address) of the application stored in itself, and then generate an installation response according to the found installation package acquisition address of the application.
[0071] Then, when the client receives the installation response, the dynamic library injected into the client can obtain the installation response, so that in the subsequent steps, the dynamic library forwards the obtained installation response to the service server.
[0072] It can be seen that through the above process, the business server can quickly obtain the installation package acquisition addresses corresponding to a large number of installable applications by automatically operating the client, which is convenient for subsequent code reinforcement by naming the code contained in the installable application, thereby improving the reinforcement effect.
[0073] In addition, in this specification, the application corresponding to the application installation package that the business server requests to obtain from the background server through the automatic operation client can be any existing type of application that implements any function, and can be an installable application that can be normally installed on the terminal (client). It can belong to the same user (code developer) as the application code to be reinforced in subsequent steps, or it can not belong to the same user, and this specification does not limit this.
[0074] S102: receiving an installation response sent after the dynamic library is acquired, and extracting acquisition addresses of each installation package from the installation response.
[0075] As described above, the business server receives the installation response forwarded by the dynamic library, and can obtain the installation package acquisition address contained in the installation response by parsing the installation response.
[0076] In actual applications, if the installation package acquisition address in the installation response sent by the backend server to the client is encrypted, the business server can decrypt the encrypted installation package acquisition address by any existing decryption method. Alternatively, the installation package acquisition address can be obtained by parsing the assignment of the NSString type.
[0077] In short, the business server obtains the installation package acquisition addresses by injecting dynamic libraries into the client and automatically operating the client. In this way, in subsequent steps, the installation packages of various applications can be obtained based on the installation package acquisition addresses.
[0078] S104: Acquire each application installation package according to the addresses of each installation package, and extract the executable file of each application from each application installation package.
[0079] Afterwards, the business server obtains the addresses of each installation package and obtains each application installation package respectively. The application installation package usually contains core contents such as executable files, resource files, configuration files, and certificate signatures. The application installation package is essentially a compressed package. By decompressing and installing it, the application can be correctly deployed and run on the electronic device. Among them, the executable file of the application in the application installation package contains executable code, that is, compiled program code. The source code of the application can be obtained by decompiling the executable code in the executable file.
[0080] S106: extracting each code name from the executable file of each application, and storing each code name in a database.
[0081] Furthermore, based on the executable files of each application obtained in step S104, the source code of each application is obtained through decompilation and other methods. After that, each code name is extracted from the source code of each application through existing code naming extraction schemes such as regular expression search matching and code analysis tools. The extracted code names can be any existing type of code names such as class names, method names, protocol names, variable names, etc. This manual does not limit the naming type and number of the extracted code names.
[0082] Afterwards, the extracted code names are stored in a database, thereby constructing a code name library for code reinforcement.
[0083] In addition, in addition to storing each code name itself, the database can also store the naming type corresponding to each code name, or the application type of the application to which each code name belongs, so as to strengthen the application code that needs to be strengthened in a targeted manner and improve the reinforcement effect.
[0084] S108: In response to the code reinforcement request, the application code to be reinforced is obtained, and reinforcement processing is performed on the application code to be reinforced according to each code name stored in the database to obtain a reinforced application code.
[0085] After receiving the code reinforcement request, the business server will obtain the application code for reinforcement from the code reinforcement request. The application code for reinforcement is generally the source code of an application that is not on the shelf or not put into use. The application corresponding to the application code to be reinforced can support any type of existing mobile operating system, such as Android, iOS, etc., and can also support other types of terminal operating systems, such as Windows, macOS, Linux, etc., which is not limited in this manual.
[0086] After the application code to be hardened is hardened, it can effectively prevent attackers from analyzing the internal logic of the application through reverse engineering, discovering vulnerabilities or extracting sensitive information, thereby effectively hiding the implementation details and algorithm logic of the application. Even if the application is illegally distributed or analyzed, it can reduce the risk of core technology being copied.
[0087] Furthermore, since in this manual, the code names stored in the database are all derived from installable applications, even if the application display platform (app store) reviews the reinforced application code, it will not identify junk code from the reinforced application code, thereby reducing the probability of the app store refusing to list the application corresponding to the reinforced application code. This is an effect that cannot be achieved by the current code reinforcement using random strings and code names in open source codes.
[0088] In addition, in one or more embodiments of the present specification, a database containing the names of various codes is constructed in step S106, and the naming codes stored in the database can be updated regularly. For example, the aforementioned steps S100 to S106 are used as a scheduled task, and the aforementioned steps S100 to S106 are automatically executed at intervals to obtain more recent code names of installable applications and update the database, thereby improving the reinforcement effect and ensuring compliance.
[0089] It should be noted that in one or more embodiments of this specification, the process of constructing a code naming library for code reinforcement based on the code naming of the installable application is before the reinforcement processing of the application code to be reinforced in step S108, but it does not mean that the business server will first perform code naming extraction and code naming library construction every time it responds to the code reinforcement request to perform reinforcement processing. That is, the two processes of building the code naming library and responding to the code reinforcement request are independent of each other, but it can be understood that before the business server responds to the code reinforcement request, at least a number of code names are saved in the database.
[0090] In the code hardening method provided in this specification, an installation response sent to the client is obtained in advance by inputting the client's dynamic library, and the installation package acquisition address is extracted therefrom, and each application installation package is obtained thereby, so as to extract the executable file of each application therefrom, and each code name is extracted from the executable file of each application and stored in a database. When a code hardening request is received, the application code to be hardened is hardened based on the code names stored in the database to obtain the hardened application code.
[0091] It can be seen that through the above method, the application code to be hardened is hardened by the code naming in the executable file of the installable application, so that the code naming in the hardened application code still has certain semantics and conforms to programming habits, and is difficult to identify, thereby improving the effect of code hardening and the security of the application code.
[0092] In an optional embodiment of this specification, Figure 1 In step S104, when more installation responses are obtained through the dynamic library, more installation package acquisition addresses are obtained accordingly, resulting in a larger number of application installation packages that need to be downloaded and obtained. Since the sizes of the installation packages are different, it is difficult to quickly obtain a large number of application installation packages using only the computing resources of the business server. For this reason, the business server can communicate with multiple sub-servers to form a server cluster with one master and multiple slaves, and the multiple sub-servers share the download pressure of the application installation package, thereby improving the efficiency of obtaining the application installation package. Figure 3The figure shows an architecture diagram of a method for hardening the execution code based on a server cluster. The business server, as the main server, can distribute the installation package acquisition addresses to each sub-server after obtaining the installation package acquisition addresses through the dynamic library. After each sub-server responds to the installation package acquisition addresses distributed by the business server, it can obtain each application installation package according to the received installation package acquisition addresses and return each application installation package to the business server. Since the process of each sub-server obtaining the application installation package is parallel and independent, the acquisition speed of the application installation package is greatly improved.
[0093] In the above process, the business server can adjust the number of installation package acquisition addresses allocated to each sub-server by obtaining the total amount of hardware resources possessed by each sub-server and the load of each sub-server, so as to achieve load balancing and improve the efficiency of obtaining application installation packages. The number of installation package acquisition addresses received by each sub-server can be the same or different, and this manual does not limit this.
[0094] After each sub-server obtains each application installation package according to the received installation package acquisition address, it returns each application installation package to the business server, and the business server aggregates each application installation package.
[0095] In an optional embodiment of this specification, Figure 1 The step S104 of extracting the executable files of each application from the application installation packages can be implemented by the following steps:
[0096] Step 1: The service server re-signs each application installation package respectively, and sends each re-signed application installation package to the client, so that the client installs each application according to each re-signed application installation package.
[0097] Specifically, the existing re-signing tool can be used to decompress each application installation package, modify the signature certificate and related information of each application installation package, and then repackage each application installation package so that the re-signed application installation package can be installed on the client and run normally.
[0098] Step 2: The business server sends an unpacking instruction to the client, and receives executable files of each application returned by the client, wherein the executable files of each application are obtained by the client responding to the unpacking instruction and unpacking each application installed on the client.
[0099] Generally, before the installable application is released, the application installation package will use the shelling technology to add a protection code to protect the application source code from being decompiled. In order to obtain the executable file of the application, it is usually necessary to deshell, that is, to remove the added protection code. To this end, the business server can send a shelling instruction to the client, wherein the shelling instruction may include the identification of the application that needs to be shelled. In this way, when the client responds to the shelling instruction, it will locate the location of the application that needs to be shelled according to the identification of the application contained in the shelling instruction. Based on the located location, the application installation package of the application is shelled using an existing shelling tool or any other existing shelling method, thereby obtaining the executable files of each application. Afterwards, the client will return the executable files of each application obtained by the shelling process to the business server so that the business server can perform subsequent steps.
[0100] In one or more embodiments of this specification, Figure 1 When storing the code names in the database in step S106, in order to improve the reinforcement effect, the naming type corresponding to each code name and the application type corresponding to the application to which each code name belongs can be stored at the same time, which can be implemented by the following scheme: Figure 4 As shown:
[0101] S200: Determine application types corresponding to the applications.
[0102] In this specification, the business server can obtain the installation package acquisition addresses of multiple different types of applications through the dynamic library, thereby obtaining multiple application installation packages corresponding to different types of applications. In actual applications, there may be situations where the application programs contained in different types of applications use the same or different code names. Therefore, when storing the extracted code names in the database, the application types corresponding to the applications described in each code name can also be stored in the database, so that when using the code names stored in the database for code reinforcement, the code names with the same application code type as the application to be reinforced can be used for targeted reinforcement to improve the reinforcement effect.
[0103] The application type corresponding to each application can be any existing type, such as games, shopping, productivity tools, multimedia entertainment, education, social networking, etc. This specification does not limit the specific type and quantity of each application type corresponding to each application.
[0104] S202: extracting code names of various naming types from executable files of various applications corresponding to the application type, wherein the naming types at least include class names, method names, and protocol names.
[0105] Afterwards, for each application type, multiple code names of named types are extracted from the executable files of each application corresponding to the application type, and the code names of multiple named types under the application type can be obtained. The code name extraction method in this step can refer to the code name extraction method described in the aforementioned step S106, which will not be repeated here.
[0106] S204: extracting the code names of each naming type from the executable files of each application corresponding to the application type, constructing a correspondence between the application type, the naming types and the code names, and storing the code names and the correspondence in a database.
[0107] Afterwards, the data may be stored in the repository in the form of a triplet with one-to-one correspondence between the application type, the naming type, and the code naming. For example, if the method name extracted from the application code of game application A is calculateBattleDamage, the corresponding relationship between the method name, game application A, and the method name may be stored in the repository, such as (calculateBattleDamage, game application A, method name) in the database.
[0108] By storing each code name, the naming type of each code name, and the application type of the application to which each code name belongs in a database, the type and source of each code name can be clearly characterized. In this way, when executing code reinforcement for the application code to be reinforced, you can specifically select the code name with the same application type as the application code to be reinforced, or select the code name with the same naming type as the code name to be reinforced that needs to be reinforced in the application code to be reinforced to execute the reinforcement process, thereby improving the reinforcement effect and ensuring compliance.
[0109] Therefore, further, based on Figure 4 After the database is constructed according to the scheme shown, Figure 1 After the application code to be reinforced is reinforced in step S108, the application code to be reinforced can be reinforced based on the application type of the application code to be reinforced and the naming type of the code to be reinforced in the code to be reinforced, so as to improve the reinforcement effect. The specific scheme is as follows: Figure 5 As shown:
[0110] S300: Determine the naming types corresponding to the names of the codes to be reinforced in the application code to be reinforced, wherein the names of the codes to be reinforced include class names, method names, and protocol names.
[0111] In actual applications, the code segments that need to be reinforced in the application code to be reinforced can be determined based on the actual situation and the code reinforcement requirements. After that, the code analysis tools can be used to analyze the code names contained in the code segments that need to be reinforced and use them as the code names to be reinforced. Generally, the code names to be reinforced contained in the code segments to be reinforced can be determined according to the naming types of the code names stored in the database. If the code names to be reinforced of the target naming type are determined from the code segments to be reinforced, but the code names corresponding to the target naming type cannot be found in the database, the business server can repeat the aforementioned steps S100 to S106 according to the target naming type to obtain the code names of the target naming type, thereby reinforcing the code names to be reinforced of the target naming type in the application code to be reinforced.
[0112] S302: for each code name to be reinforced, according to the code name to be reinforced and the corresponding relationship, search for a code name matching the naming type of the code name to be reinforced from the code names stored in the database as each first target code name corresponding to the code name to be reinforced.
[0113] Specifically, the naming type corresponding to each code name to be reinforced is first determined, and then, according to the naming type of the code name to be reinforced, a code name with the same or similar naming type as the code name to be reinforced is searched from the database as the code name matching the naming type of the code name to be reinforced. Thus, the code name matching the naming type of the code name to be reinforced is used as each first target code name corresponding to the code name to be reinforced.
[0114] S304: According to the first target code names corresponding to the code names to be reinforced, the application code to be reinforced is reinforced to obtain reinforced code.
[0115] Furthermore, for each code name to be reinforced, the code name to be reinforced is reinforced according to each first target code name corresponding to the code name to be reinforced. The reinforcement process may be to replace the code name to be reinforced with one or more first target code names among the first target code names. Thus, in fact, the code names contained in the source code of other installable applications are used to replace the code names to be reinforced contained in the application code to be reinforced, and the code names of the original application code to be reinforced are converted into other code names that are functionally equivalent but cannot be intuitively understood and analyzed. While the code to be reinforced is complicated, it will not introduce random and highly repetitive junk code, ensuring the compliance of the code.
[0116] In S304, a code name with the same or similar application type as the application code to be reinforced may be selected from each first target code name, and the application code to be reinforced may be reinforced. Specifically:
[0117] The first step: determining the target application type corresponding to the application code to be reinforced.
[0118] Step 2: for each code name to be reinforced, according to the corresponding relationship, determine the application types corresponding to each first target code name corresponding to the code name to be reinforced.
[0119] Step 3: Match the application types corresponding to the first target code names corresponding to the code name to be reinforced with the target application type, and filter out the second target code names corresponding to the code name to be reinforced from the first target code names corresponding to the code name to be reinforced.
[0120] In this specification, the first target code name corresponding to the same application type as the target application type in each first target code name can be used as the second target code name corresponding to the code name to be reinforced. In this way, the reinforced application code is obtained by replacing the code name to be reinforced with the code name of the same application type and the same naming type, which reduces the probability that the reinforced application code is difficult to maintain, has functional deviations, or is not compliant, thereby further improving the reinforcement effect.
[0121] Step 4: Replace each to-be-reinforced code name contained in the to-be-reinforced application code with a second target code name corresponding to each to-be-reinforced code name, to obtain a reinforced application code.
[0122] This step is similar to the aforementioned step S304 and will not be described again here.
[0123] The above is a code reinforcement method provided in one or more embodiments of this specification. Based on the same idea, this specification also provides a corresponding code reinforcement device, such as Figure 6 shown.
[0124] Figure 6 A schematic diagram of a code reinforcement device provided in this specification specifically includes:
[0125] The installation response acquisition module 400 is used to pre-inject the dynamic library into the client and acquire the installation response received by the client through the dynamic library;
[0126] The address acquisition module 402 is used to receive the installation response sent after the dynamic library is acquired, and extract the acquisition address of each installation package from the installation response;
[0127] The executable file acquisition module 404 is used to acquire each application installation package according to the address of each installation package, and extract the executable file of each application from each application installation package;
[0128] A code naming determination module 406, configured to extract each code naming from the executable files of each application and store the each code naming in a database;
[0129] The reinforcement module 408 is used to obtain the application code to be reinforced in response to the code reinforcement request, and reinforce the application code to be reinforced according to the code names stored in the database to obtain the reinforced application code.
[0130] Optionally, the installation response acquisition module 400 is specifically used to send an installation package acquisition signal to the client, so that the client generates an installation package acquisition request in response to the installation package acquisition signal, and sends the installation package acquisition request to the background server; when the background server responds to the installation package acquisition request and sends an installation response to the client, the installation response is acquired through the dynamic library.
[0131] Optionally, the executable file acquisition module 404 is specifically used to distribute the installation package acquisition addresses to each sub-server; receive each application installation package returned by each sub-server, wherein each application installation package is obtained by each sub-server according to the received installation package acquisition addresses.
[0132] Optionally, the executable file acquisition module 404 is specifically used to re-sign each application installation package respectively, and send each re-signed application installation package to the client, so that the client installs each application according to the re-signed application installation package; send an unpacking instruction to the client, and receive the executable files of each application returned by the client, wherein the executable files of each application are obtained by the client responding to the unpacking instruction and unpacking each application installed on the client.
[0133] Optionally, the code naming determination module 406 is specifically used to determine the application types corresponding to the applications; extract the code names of the named types from the executable files of the applications corresponding to the application types, the naming types including at least class names, method names, and protocol names; based on the code names of the named types extracted from the executable files of the applications corresponding to the application types, construct a correspondence between the application types, the named types and the code names, and store the code names and the correspondence in a database.
[0134] Optionally, the reinforcement module 408 is specifically used to determine the naming types corresponding to each code name to be reinforced in the application code to be reinforced, and the code name to be reinforced includes a class name, a method name, and a protocol name; for each code name to be reinforced, according to the code name to be reinforced and the corresponding relationship, search from the code names stored in the database for a code name that matches the naming type of the code name to be reinforced, as each first target code name corresponding to the code name to be reinforced; according to each first target code name corresponding to each code name to be reinforced, the application code to be reinforced is reinforced to obtain the reinforced code.
[0135] Optionally, the reinforcement module 408 is specifically used to determine the target application type corresponding to the application code to be reinforced; for each code name to be reinforced, determine the application types corresponding to each first target code name corresponding to the code name to be reinforced according to the corresponding relationship; match the application types corresponding to each first target code name corresponding to the code name to be reinforced with the target application type, and filter out the second target code name corresponding to the code name to be reinforced from the first target code names corresponding to the code name to be reinforced; replace each code name to be reinforced contained in the application code to be processed with the second target code name corresponding to the each code name to be reinforced, to obtain the reinforced application code.
[0136] This specification also provides a computer-readable storage medium, which stores a computer program, which can be used to execute the above Figure 1 The code hardening method shown.
[0137] This manual also provides Figure 7 The schematic structure diagram of the electronic device shown in FIG. Figure 7 As mentioned above, at the hardware level, the electronic device includes a processor, an internal bus, a network interface, a memory, and a non-volatile memory, and may also include other hardware required for the business. The processor reads the corresponding computer program from the non-volatile memory into the memory and then runs it to achieve the above Figure 1 Of course, in addition to the software implementation, this specification does not exclude other implementations, such as logic devices or a combination of software and hardware, etc., that is, the execution subject of the following processing flow is not limited to each logic unit, but can also be hardware or logic devices.
[0138] In the 1990s, improvements to a technology could be clearly distinguished as hardware improvements (for example, improvements to the circuit structure of diodes, transistors, switches, etc.) or software improvements (improvements to the method flow). However, with the development of technology, many improvements to the method flow today can be regarded as direct improvements to the hardware circuit structure. Designers almost always obtain the corresponding hardware circuit structure by programming the improved method flow into the hardware circuit. Therefore, it cannot be said that an improvement in a method flow cannot be implemented using a hardware entity module. For example, a programmable logic device (PLD) (such as a field programmable gate array (FPGA)) is such an integrated circuit whose logical function is determined by the user's programming of the device. Designers can "integrate" a digital system on a PLD by programming it themselves, without having to ask a chip manufacturer to design and produce a dedicated integrated circuit chip. Moreover, nowadays, instead of manually making integrated circuit chips, this kind of programming is mostly implemented by "logic compiler" software, which is similar to the software compiler used when developing and writing programs, and the original code before compilation must also be written in a specific programming language, which is called hardware description language (HDL). There is not only one HDL, but many kinds, such as ABEL (Advanced Boolean Expression Language), AHDL (Altera Hardware Description Language), Confluence, CUPL (Cornell University Programming Language), HDCal, JHDL (Java Hardware Description Language), Lava, Lola, MyHDL, PALASM, RHDL (Ruby Hardware Description Language), etc. The most commonly used ones are VHDL (Very-High-Speed Integrated Circuit Hardware Description Language) and Verilog. Those skilled in the art should also know that it is only necessary to program the method flow slightly in the above-mentioned hardware description languages and program it into the integrated circuit, and then it is easy to obtain the hardware circuit that implements the logic method flow.
[0139] The controller can be implemented in any appropriate manner, for example, the controller can take the form of a microprocessor or processor and a computer-readable medium storing a computer-readable program code (such as software or firmware) that can be executed by the (micro)processor, a logic gate, a switch, an application-specific integrated circuit (ASIC), a programmable logic controller, and an embedded microcontroller. Examples of controllers include, but are not limited to, the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20, and Silicone Labs C8051F320. The memory controller can also be implemented as part of the control logic of the memory. Those skilled in the art also know that in addition to implementing the controller in a purely computer-readable program code manner, the controller can be implemented in the form of a logic gate, a switch, an application-specific integrated circuit, a programmable logic controller, and an embedded microcontroller by logically programming the method steps. Therefore, this controller can be considered as a hardware component, and the devices included therein for implementing various functions can also be regarded as structures within the hardware component. Or even, the devices for implementing various functions can be regarded as both software modules for implementing the method and structures within the hardware component.
[0140] The systems, devices, modules or units described in the above embodiments may be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer. Specifically, the computer may be, for example, a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.
[0141] For the convenience of description, the above device is described in various units according to their functions. Of course, when implementing this specification, the functions of each unit can be implemented in the same or multiple software and / or hardware.
[0142] Those skilled in the art will appreciate that the embodiments of this specification may be provided as methods, systems, or computer program products. Therefore, this specification may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, this specification may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.
[0143] This specification is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of this specification. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0144] These computer program instructions may also be stored in a computer readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0145] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0146] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0147] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.
[0148] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0149] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0150] Those skilled in the art will appreciate that the embodiments of this specification may be provided as methods, systems or computer program products. Therefore, this specification may take the form of a complete hardware embodiment, a complete software embodiment or an embodiment combining software and hardware. Moreover, this specification may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0151] This specification may be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. This specification may also be practiced in distributed computing environments where tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules may be located in local and remote computer storage media, including storage devices.
[0152] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0153] The above description is only an embodiment of the present specification and is not intended to limit the present specification. For those skilled in the art, the present specification may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present specification shall be included in the scope of the claims of the present specification.
Claims
1. A code reinforcement method, characterized in that: include: Injecting a dynamic library into the client in advance, and obtaining the installation response received by the client through the dynamic library; Receiving an installation response sent after the dynamic library is acquired, and extracting each installation package acquisition address from the installation response; Acquire each application installation package according to the addresses of each installation package, and extract the executable file of each application from each application installation package; Extracting each code name from the executable file of each application, and storing each code name in a database; In response to the code reinforcement request, the application code to be reinforced is obtained, and reinforcement processing is performed on the application code to be reinforced according to the code names stored in the database to obtain the reinforced application code.
2. The method according to claim 1, characterized in that The step of obtaining the installation response received by the client through the dynamic library specifically includes: Sending an installation package acquisition signal to the client, so that the client generates an installation package acquisition request in response to the installation package acquisition signal, and sends the installation package acquisition request to the backend server; When the backend server sends an installation response to the client in response to the installation package acquisition request, the installation response is acquired through the dynamic library.
3. The method according to claim 1, characterized in that The acquiring addresses of the installation packages to acquire the application installation packages specifically includes: Distribute the installation package acquisition addresses to each sub-server; Receive each application installation package returned by each sub-server, wherein each application installation package is obtained by each sub-server according to received installation package obtaining addresses.
4. The method according to claim 1, characterized in that The extracting the executable files of each application from each application installation package specifically includes: Re-signing each of the application installation packages respectively, and sending each of the re-signed application installation packages to the client, so that the client installs each application according to each of the re-signed application installation packages; Sending a shell removal instruction to the client, and receiving executable files of each application returned by the client, wherein the executable files of each application are obtained by the client performing shell removal processing on each application installed on the client in response to the shell removal instruction.
5. The method according to claim 1, characterized in that The extracting each code name from the executable file of each application and storing each code name in a database specifically includes: Determine application types corresponding to the applications; Extracting each code name of each naming type from the executable file of each application corresponding to the application type, wherein the naming type at least includes a class name, a method name, and a protocol name; According to extracting each code name of each naming type from the executable file of each application corresponding to the application type, a corresponding relationship among the application type, each naming type and each code name is constructed, and each code name and the corresponding relationship are stored in a database.
6. The method according to claim 5, characterized in that The step of performing reinforcement processing on the application code to be reinforced according to the code names stored in the database to obtain the reinforced application code specifically includes: Determine the naming types corresponding to the names of the codes to be reinforced in the application code to be reinforced, wherein the names of the codes to be reinforced include class names, method names, and protocol names; For each code name to be reinforced, according to the code name to be reinforced and the corresponding relationship, search for a code name matching the naming type of the code name to be reinforced from the code names stored in the database as each first target code name corresponding to the code name to be reinforced; According to each first target code name corresponding to each code name to be reinforced, the application code to be reinforced is reinforced to obtain a reinforced code.
7. The method according to claim 6, characterized in that The step of performing reinforcement processing on the application code to be reinforced according to the first target code names corresponding to the code names to be reinforced to obtain the reinforced code specifically includes: Determine the target application type corresponding to the application code to be reinforced; For each code name to be reinforced, according to the corresponding relationship, determine the application types corresponding to each first target code name corresponding to the code name to be reinforced; Matching the application types corresponding to the first target code names corresponding to the code name to be reinforced with the target application type, and filtering out the second target code names corresponding to the code name to be reinforced from the first target code names corresponding to the code name to be reinforced; Each code name to be reinforced contained in the application code to be reinforced is replaced with a second target code name corresponding to each code name to be reinforced, so as to obtain a reinforced application code.
8. A code reinforcement device, characterized in that: include: An installation response acquisition module, used to pre-inject a dynamic library into the client, and acquire the installation response received by the client through the dynamic library; An address acquisition module, used to receive an installation response sent after the dynamic library is acquired, and extract each installation package acquisition address from the installation response; An executable file acquisition module, used to acquire each application installation package according to the address of each installation package, and extract the executable file of each application from each application installation package; A code naming determination module, used to extract each code name from the executable file of each application, and store each code name in a database; The reinforcement module is used to obtain the application code to be reinforced in response to the code reinforcement request, and reinforce the application code to be reinforced according to the code names stored in the database to obtain the reinforced application code.
9. A computer-readable storage medium, characterized in that: The storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.
10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the method according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Android application reinforcing system and method based on virtual machine instruction modification
CN107729725A
Code obfuscation method and device
CN113885872A
Executable file execution method and device, electronic equipment and computer readable medium
CN113987471A
Method, apparatus, system and non-transitory computer readable medium for code protection
US20170235963A1
