Installation package generation method and apparatus, code obfuscation methods and apparatuses, and code obfuscation system
By obfuscating the application's entity class code to generate an installation package, the problems of large installation package size and easy reverse engineering are solved, and the code size is reduced and security is improved.
Patent Information
- Application Number
- PCT/CN2024/118368
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2024-03-29
- Filing Date
- 2024-09-11
- Publication Date
- 2025-10-02
AI Technical Summary
The application installation package contains unobfuscated entity class codes, which results in a larger package size, occupies more storage resources and takes a long time to download.
By obfuscating the original entity class code of the application, the entity class obfuscated code is generated and converted into an obfuscated string to generate an installation package. The user terminal is mapped to the corresponding entity class according to the obfuscated string.
The size of the installation package code is reduced, the details of the original installation code are hidden, and the difficulty of reverse engineering is increased.
Smart Images

Figure CN2024118368_02102025_PF_FP_ABST
Abstract
Description
Installation package generation method, code obfuscation method, device and system
[0001] CROSS-REFERENCE TO RELATED APPLICATIONS
[0002] This application claims priority to Chinese patent application No. 2024103742435, filed on March 29, 2024, entitled “Installation Package Generation Method, Code Obfuscation Method, Device and System,” the entire contents of which are incorporated herein by reference. Technical Field
[0003] The present application relates to the field of computer technology, and in particular to an installation package generation method, a code obfuscation method, a device, and a system. Background Art
[0004] From development to normal use of an application, the collaboration of the development terminal, the server, and the user terminal is required. Specifically, the development terminal will negotiate with the server in advance to obtain an identical installation code. The development terminal can then generate an installation package based on the installation code stored in its own storage. The user terminal can download the installation package and then install the application. Then, after receiving the JSON formatted data (hereinafter referred to as JSON data) sent by the server, the JSON data is parsed so that subsequent operations and processing can be performed based on the installation code in the installation package.
[0005] In the related art, when the user terminal parses JSON data, for entity class data, it will confirm whether the field name of the entity class in the JSON data is consistent with the field name of the corresponding entity class in the installation code of the installation package. Only when the two are consistent can the JSON data be mapped to the entity class corresponding to the application. Therefore, in order to parse JSON data normally, the entity class code is usually not involved in the obfuscation. For this reason, the installation code provided by the development terminal includes unobfuscated entity class code, and the unobfuscated entity class code will occupy a larger volume of the installation package, which can easily cause problems such as occupying more storage resources and extending download time.
[0006] Summary of the Invention
[0007] The purpose of the embodiments of the present application is to provide an installation package generation method, a code obfuscation method, an apparatus and a system to reduce the size of the code portion in the application installation package, hide the details of the original installation code, and increase the difficulty of reverse engineering.
[0008] First, embodiments of the present application provide a method for generating an installation package, applied to a development terminal. The method comprises: obfuscating entity class source code within an application's original installation code to obtain entity class obfuscated code; and generating an installation package for the application based on the entity class obfuscated code. In this way, the development terminal obfuscates the bulky entity class source code into a concise entity class obfuscated code, thereby reducing the size of the code portion of the installation package. Furthermore, by obfuscating the entity class source code, this implementation method can also conceal details of the original installation code, increasing the difficulty of reverse engineering.
[0009] Optionally, the method further includes: obfuscating non-entity class original code in the original installation code of the application to obtain non-entity class obfuscated code; and generating the application installation package based on the entity class obfuscated code includes: generating the application installation package based on the non-entity class obfuscated code and the entity class obfuscated code. In this way, the code length of the entity class original code and the non-entity class original code can be shortened, thereby reducing the size of the code portion of the installation package.
[0010] In a second aspect, an embodiment of the present application provides a code obfuscation method for a server, comprising: obfuscating entity class original code in the original installation code of an application according to a mapping file to obtain entity class obfuscation code; the mapping file containing a correspondence between the entity class original code in the original installation code of the application and its entity class obfuscation code; converting the entity class obfuscation code into an entity class obfuscation string; and sending the entity class obfuscation string to a user terminal so that the user terminal maps the entity class corresponding to the application based on the entity class obfuscation string. In this way, the server can obfuscate the entity class original code in the original installation code of the application based on the obfuscation status in the development terminal, so that the user terminal can operate normally according to the logic of the installation code in the installation package. In this way, compared with obfuscation methods that cannot obfuscate entity class code or methods that do not obfuscate code, the size of the code portion in the application installation package is effectively reduced. Moreover, since the entity class code can also be obfuscated, the details of the original installation code are further hidden, increasing the difficulty of reverse engineering.
[0011] Optionally, before obtaining the entity class obfuscated code by obfuscating the original entity class code in the original installation code of the application according to the mapping file, the method further includes: reading the mapping files corresponding to multiple different versions of the application; and obtaining the entity class obfuscated code by obfuscating the original entity class code in the original installation code of the application according to the mapping files includes: obfuscating the original entity class code in the original installation code of each version of the application according to the mapping files corresponding to each version of the application to obtain the entity class obfuscated code. In this way, the server can obfuscate the original installation code of multiple versions of the application and manage the obfuscation status of multiple versions of the application, so that each version of the application can effectively reduce the size of the code portion in the installation package, further hide the details of the original installation code, and increase the difficulty of reverse engineering.
[0012] Optionally, before converting the entity class obfuscated code into an entity class obfuscated string, the method further includes: searching for a target mapping file corresponding to the target version information of the application based on the correspondence between the version information and the mapping file; determining a target entity class obfuscated code obtained by obfuscating the target mapping file; and converting the entity class obfuscated code into an entity class obfuscated string includes converting the target entity class obfuscated code into a target entity class obfuscated string. In this way, the corresponding target entity class obfuscated code can be found through the correspondence between the version information and the mapping file, which is more convenient and accurate.
[0013] Optionally, before obfuscating the entity class original code in the original installation code of each version of the application according to the mapping files corresponding to the respective versions of the application to obtain the entity class obfuscated code, the method further includes: searching for a mapping file corresponding to a version information that meets preset requirements from multiple mapping files; and obfuscating the entity class original code in the original installation code of each version of the application according to the mapping files corresponding to the respective versions of the application to obtain the entity class obfuscated code, including: obfuscating the entity class original code in the original installation code of the corresponding version of the application according to the mapping files corresponding to the version information that meets the preset requirements to obtain the entity class obfuscated code. In this way, the server can only obfuscate the entity class original code in the original installation code of the application corresponding to the version information that meets the preset requirements, and not obfuscate the entity class original code in the original installation code of the application that does not meet the preset requirements. This can reduce the processing burden on the server.
[0014] Optionally, after reading the mapping files corresponding to the multiple different versions of the application, the method further includes: after parsing the multiple mapping files respectively, caching the multiple correspondence information obtained by parsing; and according to the mapping file corresponding to the version information that meets the preset requirements, obfuscating the entity class original code in the original installation code of the corresponding version of the application to obtain the entity class obfuscated code, including: searching for multiple candidate correspondence information corresponding to the multiple mapping files corresponding to the version information that meets the preset requirements from the cached multiple correspondence information; according to each candidate correspondence information, obfuscating the corresponding entity class original code to obtain the corresponding entity class obfuscated code. In this way, compared with the implementation method of directly reading the correspondence from the mapping file, this implementation method can increase the reading rate, thereby improving the processing efficiency.
[0015] Optionally, determining the target entity class obfuscated code obtained by obfuscating the target mapping file includes: determining whether the target version information meets preset requirements; if the determination result indicates that the target version information meets the preset requirements, then determining the target entity class obfuscated code from multiple entity class obfuscated codes corresponding to multiple selected correspondences according to the target mapping file; if the determination result indicates that the target version information does not meet the preset requirements, then determining the target correspondence relationship information corresponding to the target mapping file from the multiple correspondence relationship information; and obfuscating the corresponding entity class original code according to the target correspondence relationship information to obtain the target entity class obfuscated code. In this way, on the one hand, it is possible to quickly send entity class obfuscated strings to applications with higher versions while reducing the processing burden on the server, thereby improving processing efficiency. On the other hand, it is also possible to achieve the purpose of responding to a small number of applications with lower versions. Therefore, for applications of different versions, this implementation method can determine the target entity class obfuscated code, thereby meeting the needs of applications of different versions.
[0016] Optionally, before obfuscating the entity class original code in the original installation code of the application according to the mapping file to obtain the entity class obfuscated code, the method further includes: parsing the mapping file and caching the correspondence information obtained by the parsing; and obfuscating the entity class original code in the original installation code of the application according to the mapping file to obtain the entity class obfuscated code includes: obfuscating the entity class original code in the original installation code of the application according to the cached correspondence information to obtain the entity class obfuscated code. This eliminates the need for multiple versions of the application, allowing the pre-parsed correspondence information to be read from memory and obfuscated based on the correspondence information to quickly obtain the entity class obfuscated code.
[0017] Optionally, the mapping file also includes the correspondence between the non-entity class original code in the original installation code of the application and its non-entity class obfuscation code; and the method further includes: obfuscating the non-entity class original code in the original installation code of the application according to the mapping file to obtain the non-entity class obfuscation code; converting the non-entity class obfuscation code into a non-entity class obfuscation string; and sending the non-entity class obfuscation string to the user terminal so that the user terminal maps to the corresponding non-entity class based on the non-entity class obfuscation string. In this way, a mapping file can be used to include the correspondence between non-entity class codes and the correspondence between entity class codes, thereby forming a one-to-one correspondence between the application and the obfuscation code, so as to facilitate the overall management of the obfuscation of the application. In addition, since both the entity class code and the non-entity class code are obfuscated, the size of the code portion of the application installation package can be further reduced, and the details of the original installation code can be further hidden, increasing the difficulty of reverse engineering.
[0018] Optionally, obtaining the entity class obfuscated code based on the original entity class code in the original installation code of the mapping file obfuscating application includes: obtaining the entity class obfuscated code based on the original entity class code in the original installation code of the mapping file obfuscating application before receiving the acquisition request sent by the user terminal; or obtaining the entity class obfuscated code based on the original entity class code in the original installation code of the mapping file obfuscating application after receiving the acquisition request sent by the user terminal. The timing of the obfuscation process is limited here, and the operator can select it according to actual circumstances.
[0019] In a third aspect, an embodiment of the present application provides a code obfuscation method applied to a user terminal, the method comprising: installing the application based on an installation package of the application; the installation package includes the entity class obfuscation code of the application; receiving an entity class obfuscation string sent by a server; the entity class obfuscation string is obtained by converting the entity class obfuscation code; the entity class obfuscation code is obtained by obfuscating the entity class original code in the original installation code of the application according to a mapping file; the mapping file contains a correspondence between the entity class original code in the original installation code of the application and its entity class obfuscation code; if the field name of the entity class obfuscation string is the same as the entity class field name specified by the entity class obfuscation code in the installation package, then mapping to the entity class corresponding to the entity class field name according to the entity class obfuscation code in the installation package. In this way, the volume of the code part in the application installation package can be reduced, and the details of the original installation code can be hidden, which increases the difficulty of reverse engineering.
[0020] In a fourth aspect, an embodiment of the present application provides a code obfuscation method, comprising: using a development terminal to obfuscate entity class original code in the original installation code of an application to obtain entity class obfuscation code; generating an installation package for the application based on the entity class obfuscation code; sending a mapping file to a server; the mapping file containing a correspondence between the entity class original code in the original installation code of the application and its entity class obfuscation code; using the server to obfuscate the entity class original code in the original installation code of the application based on the mapping file to obtain the entity class obfuscation code, converting the entity class obfuscation code into an entity class obfuscation string, and sending the entity class obfuscation string to a user terminal; using the user terminal to install the application based on the installation package; and when the field name corresponding to the entity class obfuscation string is the same as the entity class field name specified by the entity class obfuscation code in the installation package, mapping the entity class obfuscation code in the installation package to the entity class corresponding to the entity class field name. In this way, the volume of the code portion in the application installation package can be reduced, the details of the original installation code can be hidden, and the difficulty of reverse engineering can be increased.
[0021] In a fifth aspect, embodiments of the present application provide an installation package generation device for use on a development terminal. The device comprises: a first obfuscation module for obfuscating entity class source code within an application's original installation code to generate entity class obfuscated code; and a generation module for generating an installation package for the application based on the entity class obfuscated code. This reduces the size of the code portion of the application installation package and hides details of the original installation code, increasing the difficulty of reverse engineering.
[0022] In a sixth aspect, an embodiment of the present application provides a code obfuscation device, which is applied to a server and includes: a second obfuscation module, configured to obfuscate the entity class original code in the original installation code of an application according to a mapping file to obtain the entity class obfuscated code; the mapping file contains a correspondence between the entity class original code in the original installation code of the application and its entity class obfuscated code; a conversion module, configured to convert the entity class obfuscated code into an entity class obfuscated string; and a sending module, configured to send the entity class obfuscated string to a user terminal, so that the user terminal maps the entity class obfuscated string to the entity class corresponding to the application. In this way, the size of the code portion in the application installation package can be reduced, and the details of the original installation code can be hidden, thereby increasing the difficulty of reverse engineering.
[0023] In a seventh aspect, an embodiment of the present application provides a code obfuscation device for use in a user terminal, the device comprising: an installation module for installing the application based on an installation package of the application; the installation package comprising the entity class obfuscation code of the application; a receiving module for receiving an entity class obfuscation string sent by a server; the entity class obfuscation string is obtained by converting the entity class obfuscation code; the entity class obfuscation code is obtained by obfuscating the entity class original code in the original installation code of the application according to a mapping file; the mapping file comprises a correspondence between the entity class original code in the original installation code of the application and its entity class obfuscation code; a mapping module for mapping the entity class obfuscation string to the entity class corresponding to the entity class field name according to the entity class obfuscation code in the installation package if the field name of the entity class obfuscation string is the same as the entity class field name specified by the entity class obfuscation code in the installation package. In this way, the volume of the code portion in the application installation package can be reduced, and the details of the original installation code can be hidden, thereby increasing the difficulty of reverse engineering.
[0024] In an eighth aspect, an embodiment of the present application provides a code obfuscation system, comprising: a development terminal configured to obfuscate entity class original code in the original installation code of an application to obtain entity class obfuscation code; generating an installation package for the application based on the entity class obfuscation code; sending a mapping file to a server; the mapping file containing a correspondence between the entity class original code in the original installation code of the application and its entity class obfuscation code; a server configured to obfuscate the entity class original code in the original installation code of the application based on the mapping file to obtain the entity class obfuscation code, convert the entity class obfuscation code into an entity class obfuscation string, and send the entity class obfuscation string to a user terminal; a user terminal configured to install the application based on the installation package; and, if the field name corresponding to the entity class obfuscation string is the same as the entity class field name specified by the entity class obfuscation code in the installation package, mapping the entity class obfuscation code in the installation package to the entity class corresponding to the entity class field name according to the entity class obfuscation code in the installation package. In this way, the code portion in the application installation package can be reduced in size, the details of the original installation code can be hidden, and the difficulty of reverse engineering can be increased.
[0025] In the ninth aspect, an embodiment of the present application provides an electronic device, comprising a processor and a memory, wherein the memory stores computer-readable instructions. When the computer-readable instructions are executed by the processor, the steps in the method provided in the first, second, third or fourth aspect are executed.
[0026] In the tenth aspect, an embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, runs the steps of the method provided in the first, second, third or fourth aspect above.
[0027] In an eleventh aspect, an embodiment of the present application provides a computer program product, which includes a computer program or instructions, and when the computer program or instructions are executed by a processor, the method described in the first aspect, the second aspect, the third aspect or the fourth aspect is executed.
[0028] Other features and advantages of the present application will be described in the following description and, in part, will become apparent from the description or be understood by practicing the embodiments of the present application. The objectives and other advantages of the present application can be achieved and obtained through the structures particularly pointed out in the written description, claims, and drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following is a brief introduction to the drawings required for use in the embodiments of the present application. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other relevant drawings can be obtained based on these drawings without creative work.
[0030] FIG1 is a flowchart of a code obfuscation method provided in an embodiment of the present application;
[0031] FIG2 is a flow chart of a method for generating an installation package provided in an embodiment of the present application;
[0032] FIG3 is a flowchart of a code obfuscation method applied to a server according to an embodiment of the present application;
[0033] FIG4 is a flowchart of a code obfuscation method applied to a user terminal according to an embodiment of the present application;
[0034] FIG5 is a flowchart of a code obfuscation system provided in an embodiment of the present application;
[0035] FIG6 is a flow chart of an installation package generating device provided in an embodiment of the present application;
[0036] FIG7 is a structural block diagram of a code obfuscation device applied to a server according to an embodiment of the present application;
[0037] FIG8 is a structural block diagram of a code obfuscation device applied to a user terminal according to an embodiment of the present application;
[0038] FIG9 is a schematic structural diagram of an electronic device for executing a code obfuscation method provided in an embodiment of the present application. DETAILED DESCRIPTION
[0039] The technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all of the embodiments. The components of the embodiments of the present application generally described and shown in the drawings here can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the application for protection, but merely represents the selected embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without making creative work fall within the scope of protection of the present application.
[0040] It should be noted that similar reference numerals and letters represent similar items in the following drawings. Therefore, once an item is defined in one drawing, it does not need to be further defined or explained in subsequent drawings. At the same time, in the description of this application, the terms "first", "second", etc. are only used to distinguish the description and should not be understood as indicating or implying relative importance.
[0041] It should be noted that, unless there is any conflict, the embodiments in this application or the technical features in the embodiments may be combined.
[0042] In the related art, application installation packages contain a lot of unobfuscated entity class codes, resulting in a large installation package size. To solve this problem, this application provides a code obfuscation method. Please refer to Figure 1, which shows a flowchart of the code obfuscation method. As shown in Figure 1, the code obfuscation method includes:
[0043] Step 101: Obfuscating entity class original code in the original installation code of the application using a development terminal to obtain entity class obfuscated code; generating an installation package for the application based on the entity class obfuscated code; and sending a mapping file to a server; the mapping file contains a correspondence between the entity class original code in the original installation code of the application and its entity class obfuscated code.
[0044] Step 102: Obfuscating the entity class original code in the original installation code of the application according to the mapping file using the server to obtain the entity class obfuscated code, converting the entity class obfuscated code into an entity class obfuscated string, and sending the entity class obfuscated string to the user terminal;
[0045] Step 103, using the user terminal to install the application based on the installation package; and when the field name corresponding to the entity class obfuscation string is the same as the entity class field name specified by the entity class obfuscation code in the installation package, the entity class obfuscation code in the installation package is mapped to the entity class corresponding to the entity class field name, so that the user terminal can operate normally according to the logic of the installation code in the installation package.
[0046] In this way, since the entity class code can also be obfuscated, the installation package volume occupied by the entity class code is reduced, thereby achieving the effect of reducing the size of the application installation package.
[0047] It should be noted that the following application describes in detail the operations performed by the above-mentioned development terminal, server and user terminal and the technical effects achieved. Please refer to the following content for details and will not go into details here.
[0048] The defects existing in the solutions in the above-mentioned related technologies are the results obtained by the inventors after practice and careful research. Therefore, the process of discovering the above-mentioned problems and the solutions proposed in the embodiments of the present invention below for the above-mentioned problems should all be the contributions made by the inventors to the present invention during the process of the invention.
[0049] Please refer to Figure 2, which shows a flow chart of a method for generating an installation package provided by an embodiment of the present application. As shown in Figure 2, the method for generating an installation package includes the following steps 201 to 202.
[0050] Step 201, obfuscating the original entity class code in the original installation code of the application to obtain the entity class obfuscated code;
[0051] In some application scenarios, when obfuscating the original entity class code, the development terminal can rename the entity class name, method name, variable name, etc., replacing meaningful names with meaningless short names. For example, the original entity class code "userId" can be replaced with the obfuscated entity class code "a".
[0052] Step 202: Generate an installation package for the application based on the entity class obfuscated code.
[0053] In this implementation, the development terminal obfuscates the bulky original entity class code into a shorter obfuscated entity class code, reducing the size of the installation package's code. Furthermore, by obfuscating the original entity class code, this implementation also hides details of the original installation code, making reverse engineering more difficult.
[0054] In some optional implementations, the method further includes: obfuscating the non-entity class original code in the original installation code of the application to obtain the non-entity class obfuscated code;
[0055] The original installation code can contain not only entity class source code but also non-entity class source code. Therefore, the development terminal can obfuscate the non-entity class source code. For example, the non-entity class names, method names, and variable names in the non-entity class source code can be replaced with short, meaningless, or random characters to generate non-entity class obfuscated code.
[0056] In this way, the step 202 of generating the installation package of the application according to the entity class obfuscation code includes: generating the installation package of the application according to the non-entity class obfuscation code and the entity class obfuscation code.
[0057] In this implementation, the code length of the entity class original code and the non-entity class original code can be shortened, thereby reducing the size of the installation package code portion.
[0058] Please refer to Figure 3, which shows a flow chart of a code obfuscation method applied to a server provided by an embodiment of the present application. As shown in Figure 3, the code obfuscation method includes the following steps 301 to 302.
[0059] Step 301: Obfuscating the entity class original code in the original installation code of the application according to the mapping file to obtain the entity class obfuscated code; the mapping file contains the correspondence between the entity class original code in the original installation code of the application and the entity class obfuscated code;
[0060] In some application scenarios, the mapping file can be obtained from a development terminal. Specifically, after obfuscating the original entity class code and obtaining the obfuscated entity class code, the development terminal can record the original entity class code, the obfuscated entity code, and the corresponding relationship between the two, thereby obtaining the mapping file. For example, the mapping file may include the corresponding relationship between the original entity class code userId and the obfuscated entity class code a, and the corresponding relationship between the original entity class code username and the obfuscated entity class code b.
[0061] In other application scenarios, the server may also generate the above mapping file first, store it locally, and then send the mapping file to the development terminal so that the development terminal can obfuscate the original code of its entity class based on the mapping file.
[0062] Therefore, the server can obfuscate the internally stored entity class original code into the entity class obfuscated code based on the corresponding relationship in the mapping file. For example, based on the corresponding relationship between the entity class original code userId and the entity class obfuscated code a in the above example, the internally stored entity class original code userId is obfuscated into the entity class obfuscated code a; and the internally stored entity class original code username is obfuscated into the entity class obfuscated code b.
[0063] Step 302: convert the entity class obfuscation code into an entity class obfuscation string;
[0064] In some application scenarios, the server may use, for example, the GSON library, the Jackson library, etc. to convert the entity class obfuscation code into an entity class obfuscation string.
[0065] Step 303: Send the entity class obfuscated string to the user terminal, so that the user terminal is mapped to the entity class corresponding to the application based on the entity class obfuscated string.
[0066] The above-mentioned entity class obfuscated string is also string data in JSON format. After receiving the entity class obfuscated string, the user terminal can map each entity class field name in the entity class obfuscated string to the entity class corresponding to the entity class field name based on the correspondence between the entity class field name and the entity class, if the entity class field name is the same as the corresponding entity class field name specified in the code portion of the installation package. This allows the application to run normally according to the logic of the installation code in the installation package. Among them, if the fields and structure of each entity class field name in the entity class obfuscated string are consistent with the corresponding entity class field name in the code portion of the installation package, it indicates that the two are identical.
[0067] In this implementation, the original entity class code within the application's original installation code can be obfuscated based on the obfuscation status of the development terminal, allowing the user terminal to operate normally according to the logic of the installation code in the installation package. This effectively reduces the code size of the application installation package compared to obfuscation methods that do not obfuscate entity class code or methods that do not obfuscate the code at all. Furthermore, since entity class code can also be obfuscated, the details of the original installation code are further hidden, increasing the difficulty of reverse engineering.
[0068] In some application scenarios, as the application is updated and iterated, the original entity class code in its installation code will also change, resulting in different entity class obfuscated code. Therefore, different versions of the application correspond to different mapping files.
[0069] In these application scenarios, after the development terminal generates the installation package for each version of the application, the user terminal can download the installation package. The server can only obfuscate the original installation code after the development terminal has generated multiple versions of the application. Therefore, in some optional implementations, before obfuscating the entity class original code in the original installation code of the application according to the mapping file to obtain the entity class obfuscated code as described in step 301 above, the method further includes 300: reading the mapping files corresponding to multiple different versions of the application.
[0070] That is to say, for each version of the application, the server can read the mapping file corresponding to the version of the application, and can store the correspondence between the version information corresponding to the version of the application and the mapping file, thereby establishing the correspondence between the version information, application and mapping file.
[0071] In this way, the above-mentioned step 301, in which the entity class original code in the original installation code of the application is obfuscated according to the mapping file to obtain the entity class obfuscated code, includes sub-step 3011: in which the entity class original code in the original installation code of each version of the application is obfuscated according to the mapping file corresponding to each version of the application to obtain the entity class obfuscated code.
[0072] That is to say, for each mapping file, the server can obfuscate the corresponding entity class original code according to the corresponding relationship contained in the mapping file, thereby obtaining the corresponding entity class obfuscated code.
[0073] In this implementation, since different users have different needs, some users are happy to use the new version of the application, and some users are happy to use the old version of the application. Therefore, in order to adapt to different versions of the application, the server can obfuscate the original installation code of multiple versions of the application and manage the obfuscation of multiple versions of the application, so that each version of the application can effectively reduce the size of the code part in the installation package, and further hide the details of the original installation code, thereby increasing the difficulty of reverse engineering.
[0074] In some optional implementations, before converting the entity class obfuscated code into an entity class obfuscated string in step 302, the method further includes:
[0075] Step 1: searching for a target mapping file corresponding to the target version information of the application program according to the corresponding relationship between the version information and the mapping file;
[0076] Step 2, determining the target entity class obfuscated code obtained by obfuscating the target mapping file;
[0077] That is, for each version of an application, the server stores the correspondence between the application's version information and its mapping file, as well as the correspondence between the mapping file and its entity class obfuscation code. Therefore, the server can gradually find the target entity class obfuscation code corresponding to the target version information of the application based on the target version information.
[0078] Thus, the step 302 of converting the entity class obfuscated code into an entity class obfuscated string includes: converting the target entity class obfuscated code into a target entity class obfuscated string.
[0079] In this implementation, the corresponding target entity class obfuscation code can be found through the correspondence between the version information and the mapping file, which is more convenient and accurate.
[0080] In some optional implementations, before obfuscating the entity class original code in the original installation code of each version of the application program according to the mapping files corresponding to each version of the application program to obtain the entity class obfuscated code as described in sub-step 3011 above, the method further includes: searching for a mapping file corresponding to the version information that meets preset requirements from the plurality of mapping files;
[0081] In some application scenarios, although users have different requirements, most users use a few versions of applications that are more recently updated. Therefore, the server can pre-determine the version information of applications that are more recently updated. Here, the version information of applications that are more recently updated is also the version information that meets the preset requirements.
[0082] In some application scenarios, for example, it is possible to determine whether a certain version information meets a preset requirement based on the version number. For example, if the preset requirement is that the version number is greater than 4.0, then if the version number of a certain version application (e.g., 5.0) is greater than 4.0, it can be determined that its version information meets the preset requirement; if the version number of a certain version application (e.g., 3.0) is less than 4.0, it can be determined that its version information does not meet the preset requirement.
[0083] In this way, the above-mentioned step 3011 obfuscates the entity class original code in the original installation code of each version of the application according to the mapping file corresponding to the version information that meets the preset requirements, and obtains the entity class obfuscated code, including sub-step A: obfuscates the entity class original code in the original installation code of the corresponding version of the application according to the mapping file corresponding to the version information that meets the preset requirements, and obtains the entity class obfuscated code.
[0084] Specifically, for each mapping file corresponding to an application whose version information meets the preset requirements, the original entity class code in the original installation code of the corresponding version of the application is obfuscated based on the corresponding relationship within the mapping file to obtain obfuscated entity class code. The specific obfuscation process is the same or similar to that described above and will not be repeated here.
[0085] In this implementation, the server can only obfuscate the original entity class code in the original installation code of applications corresponding to version information that meets the preset requirements, while not obfuscating the original entity class code in the original installation code of applications that do not meet the preset requirements. This can reduce the processing burden on the server.
[0086] In some optional implementations, after reading the mapping files corresponding to the multiple different versions of the application in step 300, the method further includes: parsing the multiple mapping files respectively, and caching the multiple correspondence information obtained by parsing;
[0087] That is, for each version of the application's mapping file, the corresponding relationship information in the mapping file is parsed and stored. For example, if the mapping file for version 1.0 contains the correspondence between the original entity class code userId and the obfuscated target entity class code a, the correspondence information between userId and a is parsed and stored.
[0088] Thus, after the plurality of correspondence information are stored, the plurality of correspondence information are cached in the server. Here, the server can cache the plurality of correspondence information in the memory.
[0089] In this way, the above-mentioned sub-step A, according to the mapping file corresponding to the version information that meets the preset requirements, obfuscates the original entity class code in the original installation code of the corresponding version of the application to obtain the entity class obfuscated code, including:
[0090] Sub-step A1, searching from the cached plurality of correspondence information for a plurality of candidate correspondence information corresponding to a plurality of mapping files corresponding to version information that meets a preset requirement;
[0091] That is, since most users will use multiple applications with newer versions, the server can only obtain the corresponding relationship information of the mapping files corresponding to multiple version information that meet the preset requirements from the memory. The obtained corresponding relationship information is also the above-mentioned selected corresponding relationship information.
[0092] Sub-step A2: Obfuscate the corresponding entity class original code according to each candidate corresponding relationship information to obtain the corresponding entity class obfuscated code.
[0093] Specifically, for each candidate correspondence, the original entity class code corresponding to that candidate correspondence is obfuscated to obtain the corresponding obfuscated entity class code. This results in the server storing multiple sets of obfuscated entity class codes corresponding to each candidate correspondence. The specific obfuscation process is the same or similar to that described above and will not be elaborated upon here.
[0094] In some application scenarios, the server may not parse the corresponding relationships contained in the mapping files, but may directly read the corresponding relationships contained in each mapping file, and then obfuscate the corresponding target entity class obfuscated code.
[0095] In this implementation, the server can first cache the correspondence information in the mapping file, and then search the cached correspondence information for the selected correspondence information for obfuscation processing. Compared with the implementation method of directly reading the correspondence from the mapping file, this implementation method can increase the reading rate and thus improve processing efficiency.
[0096] In some optional implementations, the step 2 of determining the target entity class obfuscated code obtained by obfuscating the target mapping file includes:
[0097] Sub-step 21: determining whether the target version information meets preset requirements; if the determination result indicates that the target version information meets the preset requirements, determining the target entity class obfuscation code from a plurality of entity class obfuscation codes corresponding to a plurality of candidate correspondences according to the target mapping file;
[0098] Sub-step 22, if the determination result shows that the target version information does not meet the preset requirements, then determine the target corresponding relationship information corresponding to the target mapping file from the multiple corresponding relationship information; obfuscate the corresponding entity class original code according to the target corresponding relationship information to obtain the target entity class obfuscated code.
[0099] That is, if the server determines that the target version information meets the preset requirements, it means that the target entity class obfuscation code corresponding to the application has been processed through the above steps A1 and A2, so the server can directly determine the target entity class obfuscation code from multiple sets of entity class obfuscation codes, which is faster and more convenient. If it is determined that the target version information does not meet the preset requirements, it means that the version of the application is lower and the server has not pre-obfuscated the corresponding entity class obfuscation code. At this time, the target correspondence information corresponding to the target version information can be obtained from the multiple correspondence information stored in the memory, and the target entity class obfuscation code can be obtained based on the correspondence obfuscation.
[0100] In this implementation, the target entity class obfuscation code, obtained from the target mapping file, can be adaptively determined based on the target version information. This allows, on the one hand, to quickly send entity class obfuscation strings to applications with higher versions while reducing the server's processing burden, improving processing efficiency. On the other hand, it can also achieve responsiveness for a small number of applications with lower versions. Therefore, this implementation can determine the target entity class obfuscation code for applications of different versions, thus meeting the needs of applications with different versions.
[0101] In some optional implementations, before obtaining the entity class obfuscated code by obfuscating the original entity class code in the original installation code of the application according to the mapping file in step 301, the method further includes: parsing the mapping file and caching the corresponding relationship information obtained by the parsing; the parsing process and the technical effects achieved here are the same or similar to the corresponding parts of the previous text and will not be repeated here.
[0102] In this way, the above-mentioned step 301 obfuscates the entity class original code in the original installation code of the application according to the mapping file to obtain the entity class obfuscated code, including: obfuscating the entity class original code in the original installation code of the application according to the cached corresponding relationship information to obtain the entity class obfuscated code.
[0103] In this implementation, the situation where there are multiple versions of the application is not involved, so the pre-parsed correspondence information can be read from the memory, and obfuscation processing can be performed based on the correspondence information to quickly obtain the entity class obfuscated code.
[0104] In some optional implementations, the mapping file further includes a correspondence between the non-entity class original code and the non-entity class obfuscated code in the original installation code of the application; and the method further includes:
[0105] First, non-entity class original codes in the original installation code of the application are obfuscated according to the mapping file to obtain non-entity class obfuscated codes;
[0106] Here, the obfuscation process for the original code of the non-entity class can be, for example: replacing the class name, method name, variable name, etc. of the original code of the non-entity class with short meaningless characters or random characters to shorten its code length and achieve the purpose of reducing the size of the code part of the installation package.
[0107] It should be noted that the correspondence between the non-entity class obfuscated code and the non-entity class original code can also be included separately in different mapping files.
[0108] Then, the non-entity class obfuscation code is converted into a non-entity class obfuscation string. Here, for example, the non-entity class obfuscation code can also be converted into a non-entity class obfuscation string using a GSON library, a Jackson library, or the like.
[0109] Finally, the non-entity class obfuscated character string is sent to the user terminal, so that the user terminal is mapped to the corresponding non-entity class based on the non-entity class obfuscated character string.
[0110] In some application scenarios, the server may send the non-entity obfuscated string together with the entity obfuscated string, or may send the two separately, which is not limited here.
[0111] In this implementation, a mapping file can be used to contain the correspondence between non-entity class code and entity class code, thereby establishing a one-to-one correspondence between the application and the obfuscated code, facilitating the overall management of the application's obfuscation. Furthermore, since both entity and non-entity class code are obfuscated, the code portion of the application installation package can be further reduced in size, further concealing details of the original installation code and increasing the difficulty of reverse engineering.
[0112] In some optional implementations, the obtaining of the entity class obfuscation code according to the entity class original code in the original installation code of the mapping file obfuscating application described in the above step 301 includes: before receiving the acquisition request sent by the user terminal, obtaining the entity class obfuscation code according to the entity class original code in the original installation code of the mapping file obfuscating application; or after receiving the acquisition request sent by the user terminal, obtaining the entity class obfuscation code according to the entity class original code in the original installation code of the mapping file obfuscating application.
[0113] The acquisition request may be a request for acquiring any data. That is, when the user terminal needs to acquire certain data, it may send a corresponding acquisition request.
[0114] In some application scenarios, the server can send an entity-class obfuscated string to the user terminal based on a request sent by the user terminal. The server can perform obfuscation processing before receiving the request, then directly send the corresponding entity-class obfuscated string upon receiving the request, and then convert the string to obtain the entity-class obfuscated string. Alternatively, the server can perform obfuscation processing after receiving the request, and then obtain the entity-class obfuscated string. That is, in this implementation, the timing of obfuscation processing is limited, and the operator can choose according to the actual situation.
[0115] Furthermore, upon receiving the retrieval request, the server can further determine the original code corresponding to the object requested in the retrieval request to determine the entity class original code. Then, based on the correspondence between the entity class original code and the entity class obfuscated code, the obfuscated entity class code corresponding to the entity class original code can be found. For example, if the entity class original code requested in the retrieval request is userId, the obfuscated entity class code a can be found based on the correspondence.
[0116] In some application scenarios, if multiple versions of an application exist, the user terminal can send the application's version information along with the request. Furthermore, the application's version information can be embedded in the request header or sent separately with the request, without specific limitations here. The server can then obtain the application's target version information and determine the corresponding target entity class obfuscation code based on the target mapping file corresponding to the target version information.
[0117] Please refer to Figure 4, which shows a flow chart of a code obfuscation method applied to a user terminal provided by an embodiment of the present application. As shown in Figure 4, the method includes:
[0118] Step 401: Install the application based on the application installation package; the installation package includes the entity class obfuscation code of the application;
[0119] Step 402: Receive an entity class obfuscated string sent by the server; the entity class obfuscated string is obtained by converting the entity class obfuscated code; the entity class obfuscated code is obtained by obfuscating the entity class original code in the original installation code of the application according to a mapping file; the mapping file contains a correspondence between the entity class original code in the original installation code of the application and its entity class obfuscated code;
[0120] Step 403: If the field name of the entity class obfuscation string is the same as the entity class field name specified by the entity class obfuscation code in the installation package, the entity class obfuscation code in the installation package is mapped to the entity class corresponding to the entity class field name.
[0121] The implementation process of the above steps 401 to 403 and the technical effects achieved may be the same or similar to those in the embodiment shown in FIG. 2 or FIG. 3 , and are not described in detail here.
[0122] Those skilled in the art will understand that, in the above-mentioned method of a specific embodiment, the writing order of each step does not mean a strict execution order and does not constitute any limitation on the implementation process. The specific execution order of each step should be determined by its function and possible internal logic.
[0123] Please refer to Figure 5, which shows a structural block diagram of a code obfuscation system provided in an embodiment of the present application. The system includes a development terminal 501, a server 502, and a user terminal 503. It should be understood that this system corresponds to the method embodiment of Figure 1 above and can execute each step involved in the method embodiment of Figure 1.
[0124] The development terminal 501 is configured to obfuscate the entity class original code in the original installation code of the application to obtain the entity class obfuscated code; generate an installation package for the application based on the entity class obfuscated code; and send a mapping file to the server; the mapping file contains a correspondence between the entity class original code in the original installation code of the application and its entity class obfuscated code.
[0125] The server 502 is configured to obfuscate the entity class original code in the original installation code of the application according to the mapping file to obtain the entity class obfuscated code, convert the entity class obfuscated code into an entity class obfuscated string, and send the entity class obfuscated string to the user terminal 503;
[0126] User terminal 503 is used to install the application based on the installation package; and when the field name corresponding to the entity class obfuscation string is the same as the entity class field name specified by the entity class obfuscation code in the installation package, it is mapped to the entity class corresponding to the entity class field name according to the entity class obfuscation code in the installation package.
[0127] It should be noted that those skilled in the art can clearly understand that for the convenience and brevity of description, the specific working process of the system described above can refer to the corresponding process in the aforementioned method embodiment and will not be repeated here.
[0128] Please refer to Figure 6, which shows a block diagram of a device for generating an installation package provided in an embodiment of the present application. The device for generating an installation package may be a module, program segment, or code on an electronic device. It should be understood that the device corresponds to the method embodiment of Figure 2 above and can perform each step involved in the method embodiment of Figure 2.
[0129] Optionally, the installation package generation apparatus includes a first obfuscation module 601 and a generation module 602. The first obfuscation module 601 is configured to obfuscate the original entity class code in the original installation code of the application to obtain entity class obfuscated code; and the generation module 602 is configured to generate the installation package of the application based on the entity class obfuscated code.
[0130] Optionally, the above-mentioned installation package generation device also includes a third obfuscation module, which is used to: obfuscate the non-entity class original code in the original installation code of the application to obtain the non-entity class obfuscated code; and the above-mentioned generation module 602 is used to: generate the installation package of the application based on the non-entity class obfuscation code and the entity class obfuscation code.
[0131] It should be noted that those skilled in the art can clearly understand that for the convenience and brevity of description, the specific working process of the device described above can refer to the corresponding process in the aforementioned method embodiment and will not be repeated here.
[0132] Please refer to Figure 7, which shows a block diagram of a code obfuscation device for a server according to an embodiment of the present application. The code obfuscation device can be a module, program segment, or code on an electronic device. It should be understood that the device corresponds to the method embodiment of Figure 3 above and can perform each step involved in the method embodiment of Figure 3.
[0133] Optionally, the code obfuscation device includes a second obfuscation module 701, a conversion module 702, and a sending module 703. The second obfuscation module 701 is configured to obfuscate the entity class original code in the original installation code of the application according to a mapping file to obtain the entity class obfuscated code; the mapping file contains a correspondence between the entity class original code in the original installation code of the application and its entity class obfuscated code; the conversion module 702 is configured to convert the entity class obfuscated code into an entity class obfuscated string; and the sending module 703 is configured to send the entity class obfuscated string to a user terminal, so that the user terminal maps the entity class obfuscated string to the entity class corresponding to the application.
[0134] Optionally, the method further includes a reading module, which is used to: obfuscate the entity class original code in the original installation code of the application according to the mapping file, and read the mapping files corresponding to multiple different versions of the application before obtaining the entity class obfuscated code; and the second obfuscation module 701 is used to: obfuscate the entity class original code in the original installation code of each version of the application according to the mapping file corresponding to each version of the application, and obtain the entity class obfuscated code.
[0135] Optionally, the device also includes a determination module, which is used to: before converting the entity class obfuscation code into an entity class obfuscation string, search for the target mapping file corresponding to the target version information corresponding to the application according to the correspondence between the version information and the mapping file; determine the target entity class obfuscation code obtained by obfuscating the target mapping file; and the conversion module 702 is used to: convert the target entity class obfuscation code into a target entity class obfuscation string.
[0136] Optionally, the device also includes a search module, which is used to: before obfuscating the entity class original code in the original installation code of each version of the application according to the mapping files corresponding to each version of the application to obtain the entity class obfuscated code, find the mapping file corresponding to the version information that meets the preset requirements from multiple mapping files; and the second obfuscation module 701 is used to: obfuscate the entity class original code in the original installation code of the corresponding version of the application according to the mapping file corresponding to the version information that meets the preset requirements to obtain the entity class obfuscated code.
[0137] Optionally, the device also includes a first cache module, which is used to: after reading the mapping files corresponding to multiple different versions of the application, and parsing the multiple mapping files respectively, cache the multiple correspondence information obtained by parsing; and the second obfuscation module 701 is used to: find out from the multiple correspondence information in the cache multiple correspondence information, multiple candidate correspondence information corresponding to the multiple mapping files corresponding to the version information that meets the preset requirements; according to each candidate correspondence information, obfuscate the corresponding entity class original code to obtain the corresponding entity class obfuscated code.
[0138] Optionally, the determination module is further used to: determine whether the target version information meets the preset requirements; if the determination result shows that the target version information meets the preset requirements, then determine the target entity class obfuscation code from multiple entity class obfuscation codes corresponding to multiple selected correspondences according to the target mapping file; if the determination result shows that the target version information does not meet the preset requirements, then determine the target corresponding relationship information corresponding to the target mapping file from the multiple correspondence information; and obfuscate the corresponding entity class original code according to the target correspondence information to obtain the target entity class obfuscation code.
[0139] Optionally, the device also includes a second cache module, which is used to: parse the mapping file and cache the corresponding relationship information obtained by the parsing before the entity class original code in the original installation code of the application is obfuscated according to the mapping file to obtain the entity class obfuscated code; and the second obfuscation module 701 is used to: obfuscate the entity class original code in the original installation code of the application according to the cached corresponding relationship information to obtain the entity class obfuscated code.
[0140] Optionally, the mapping file also includes a correspondence between the non-entity class original code in the original installation code of the application and its non-entity class obfuscation code; and the device also includes a non-entity class obfuscation module, which is used to: obfuscate the non-entity class original code in the original installation code of the application according to the mapping file to obtain a non-entity class obfuscation code; convert the non-entity class obfuscation code into a non-entity class obfuscation string; and send the non-entity class obfuscation string to the user terminal so that the user terminal is mapped to the corresponding non-entity class based on the non-entity class obfuscation string.
[0141] Optionally, the second obfuscation module 701 is further used to: before receiving the acquisition request sent by the user terminal, obtain the entity class obfuscated code based on the entity class original code in the original installation code of the mapping file obfuscated application; or after receiving the acquisition request sent by the user terminal, obtain the entity class obfuscated code based on the entity class original code in the original installation code of the mapping file obfuscated application.
[0142] It should be noted that those skilled in the art can clearly understand that for the convenience and brevity of description, the specific working process of the device described above can refer to the corresponding process in the aforementioned method embodiment and will not be repeated here.
[0143] Please refer to Figure 8, which shows a block diagram of a code obfuscation device for a user terminal according to an embodiment of the present application. The code obfuscation device can be a module, program segment, or code on an electronic device. It should be understood that this device corresponds to the method embodiment of Figure 4 above and can perform each step involved in the method embodiment of Figure 4.
[0144] Optionally, the above-mentioned code obfuscation device includes an installation module 801, a receiving module 802, and a mapping module 803. Among them, the installation module 801 is used to install the application based on the application installation package; the installation package includes the entity class obfuscation code of the application; the receiving module 802 is used to receive the entity class obfuscation string sent by the server; the entity class obfuscation string is obtained by converting the entity class obfuscation code; the entity class obfuscation code is obtained by obfuscating the entity class original code in the original installation code of the application according to the mapping file; the mapping file contains the correspondence between the entity class original code in the original installation code of the application and its entity class obfuscation code; the mapping module 803 is used to map the entity class obfuscation string to the entity class corresponding to the entity class field name according to the entity class obfuscation code in the installation package if the field name of the entity class obfuscation string is the same as the entity class field name specified by the entity class obfuscation code in the installation package.
[0145] It should be noted that those skilled in the art can clearly understand that for the convenience and brevity of description, the specific working process of the device described above can refer to the corresponding process in the aforementioned method embodiment and will not be repeated here.
[0146] Please refer to Figure 9, which is a structural diagram of an electronic device for executing an installation package generation method or a code obfuscation method provided in an embodiment of the present application. The electronic device may include: at least one processor 901, such as a CPU, at least one communication interface 902, at least one memory 903 and at least one communication bus 904. Among them, the communication bus 904 is used to realize direct connection and communication between these components. Among them, the communication interface 902 of the device in the embodiment of the present application is used to communicate signaling or data with other node devices. The memory 903 can be a high-speed RAM memory or a non-volatile memory (non-volatile memory), such as at least one disk storage. The memory 903 can optionally be at least one storage device located away from the aforementioned processor. Computer-readable instructions are stored in the memory 903. When the computer-readable instructions are executed by the processor 901, the electronic device can execute the process of any of the methods shown in Figures 1 to 4 above.
[0147] It is understood that the structure shown in Figure 9 is merely illustrative, and the electronic device may include more or fewer components than shown in Figure 9, or have a configuration different from that shown in Figure 9. Each component shown in Figure 9 may be implemented using hardware, software, or a combination thereof.
[0148] An embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the method process performed by the electronic device in any of the method embodiments shown in FIG. 1 to FIG. 4 can be executed.
[0149] An embodiment of the present application provides a computer program product, which includes a computer program stored on a non-transitory computer-readable storage medium. The computer program includes program instructions. When the program instructions are executed by a computer, the computer can execute the methods provided by the above-mentioned method embodiments. For example, the method may include: obfuscating the original code of the entity class in the original installation code of the application to obtain the entity class obfuscated code; and generating the installation package of the application based on the entity class obfuscated code.
[0150] In the embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interface, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0151] In addition, the units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0152] Furthermore, the functional modules in each embodiment of the present application can be integrated together to form an independent part, or each module can exist independently, or two or more modules can be integrated to form an independent part.
[0153] In this document, relational terms such as first and second, etc. are used merely to distinguish one entity or operation from another entity or operation, but do not necessarily require or imply any actual relationship or order between these entities or operations.
[0154] The above description is merely an embodiment of the present application and is not intended to limit the scope of protection of the present application. For those skilled in the art, various modifications and variations of the present application are possible. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application shall be included in the scope of protection of the present application.
Claims
1. A method for generating an installation package, characterized in that: Applied to a development terminal, the method includes: Obfuscating the original code of the entity class in the original installation code of the application to obtain the obfuscated code of the entity class; An installation package of the application is generated based on the entity class obfuscated code.
2. The method according to claim 1, characterized in that The method further comprises: Obfuscating the non-entity class original code in the original installation code of the application to obtain the non-entity class obfuscated code; and Generating the installation package of the application according to the entity class obfuscated code includes: An installation package of the application is generated according to the non-entity class obfuscation code and the entity class obfuscation code.
3. A code obfuscation method, characterized in that: Applied to a server, the method includes: Obfuscating the entity class original code in the original installation code of the application according to the mapping file to obtain the entity class obfuscated code; the mapping file contains the corresponding relationship between the entity class original code in the original installation code of the application and the entity class obfuscated code; Converting the entity class obfuscation code into an entity class obfuscation string; The entity class obfuscated character string is sent to a user terminal, so that the user terminal is mapped to the entity class corresponding to the application based on the entity class obfuscated character string.
4. The method according to claim 3, characterized in that Obfuscating the entity class original code in the original installation code of the application according to the mapping file, before obtaining the entity class obfuscated code, the method further includes: Read mapping files corresponding to multiple different versions of applications; and Obfuscating the entity class original code in the original installation code of the application according to the mapping file to obtain the entity class obfuscated code includes: According to the mapping files corresponding to each version of the application, the original code of the entity class in the original installation code of each version of the application is obfuscated to obtain the obfuscated code of the entity class.
5. The method according to claim 4, characterized in that Before converting the entity class obfuscation code into an entity class obfuscation string, the method further includes: According to the correspondence between the version information and the mapping file, searching for the target mapping file corresponding to the target version information corresponding to the application program; Determining a target entity class obfuscated code obtained by obfuscating the target mapping file; and The converting the entity class obfuscation code into an entity class obfuscation string includes: The target entity class obfuscation code is converted into a target entity class obfuscation string.
6. The method according to claim 5, characterized in that Before obfuscating the entity class original code in the original installation code of each version of the application program according to the mapping file corresponding to each version of the application program to obtain the entity class obfuscated code, the method further includes: Finding a mapping file corresponding to version information that meets preset requirements from multiple mapping files; and Obfuscating the entity class original code in the original installation code of each version of the application program according to the mapping file corresponding to each version of the application program to obtain the entity class obfuscated code includes: According to the mapping file corresponding to the version information that meets the preset requirements, the entity class original code in the original installation code of the corresponding version of the application is obfuscated to obtain the entity class obfuscated code.
7. The method according to claim 6, characterized in that After reading the mapping files corresponding to the multiple different versions of the application programs, the method further includes: After parsing the multiple mapping files respectively, caching the multiple correspondence information obtained from the parsing; and Obfuscating the entity class original code in the original installation code of the corresponding version of the application program according to the mapping file corresponding to the version information meeting the preset requirements to obtain the entity class obfuscated code includes: Searching out, from the cached plurality of corresponding relationship information, a plurality of candidate corresponding relationship information corresponding to a plurality of mapping files corresponding to version information that meets a preset requirement; According to each candidate corresponding relationship information, the corresponding entity class original code is obfuscated to obtain the corresponding entity class obfuscated code.
8. The method according to claim 7, characterized in that The determining of the target entity class obfuscated code obtained by obfuscating the target mapping file includes: determining whether the target version information meets a preset requirement, and if the determination result indicates that the target version information meets the preset requirement, determining the target entity class obfuscation code from a plurality of entity class obfuscation codes corresponding to a plurality of candidate correspondences according to the target mapping file; If the determination result indicates that the target version information does not meet the preset requirement, determining the target corresponding relationship information corresponding to the target mapping file from the plurality of corresponding relationship information; The corresponding entity class original code is obfuscated according to the target correspondence information to obtain the target entity class obfuscated code.
9. The method according to claim 3, characterized in that Before obtaining the entity class obfuscated code by obfuscating the entity class original code in the original installation code of the application according to the mapping file, the method further comprises: Parsing the mapping file and caching the corresponding relationship information obtained from the parsing; and Obfuscating the entity class original code in the original installation code of the application according to the mapping file to obtain the entity class obfuscated code includes: The entity class original code in the original installation code of the application is obfuscated according to the cached corresponding relationship information to obtain the entity class obfuscated code.
10. The method according to claim 3, characterized in that The mapping file also includes a correspondence between the non-entity class original code and its non-entity class obfuscated code in the original installation code of the application; And the method further comprises: Obfuscating the non-entity class original code in the original installation code of the application according to the mapping file to obtain the non-entity class obfuscated code; Converting the non-entity class obfuscation code into a non-entity class obfuscation string; The non-entity class obfuscated string is sent to the user terminal, so that the user terminal is mapped to a corresponding non-entity class based on the non-entity class obfuscated string.
11. The method according to claim 3, characterized in that Obfuscating the entity class original code in the original installation code of the application according to the mapping file to obtain the entity class obfuscated code includes: Obfuscating the entity class original code in the original installation code of the application program according to the mapping file to obtain the entity class obfuscated code before receiving the acquisition request sent by the user terminal; or After receiving the acquisition request sent by the user terminal, the entity class original code in the original installation code of the application is obfuscated according to the mapping file to obtain the entity class obfuscated code.
12. A code obfuscation method, characterized in that: Applied to a user terminal, the method includes: Installing the application based on an installation package of the application; the installation package includes entity class obfuscation code of the application; Receiving an entity class obfuscated string sent by a server; the entity class obfuscated string is obtained by converting an entity class obfuscated code; the entity class obfuscated code is obtained by obfuscating the entity class original code in the original installation code of the application according to a mapping file; the mapping file contains a correspondence between the entity class original code in the original installation code of the application and its entity class obfuscated code; If the field name of the entity class obfuscation string is the same as the entity class field name specified by the entity class obfuscation code in the installation package, the entity class obfuscation code in the installation package is mapped to the entity class corresponding to the entity class field name.
13. A code obfuscation method, characterized in that: The method includes: Obfuscating entity class original code in the original installation code of the application using a development terminal to obtain entity class obfuscated code; generating an installation package for the application based on the entity class obfuscated code; and sending a mapping file to a server; the mapping file containing a correspondence between the entity class original code in the original installation code of the application and its entity class obfuscated code; Obfuscating the entity class original code in the original installation code of the application according to the mapping file using the server to obtain the entity class obfuscated code, converting the entity class obfuscated code into an entity class obfuscated string, and sending the entity class obfuscated string to the user terminal; The application is installed based on the installation package using the user terminal; and when the field name corresponding to the entity class obfuscation string is the same as the entity class field name specified by the entity class obfuscation code in the installation package, the entity class obfuscation code in the installation package is mapped to the entity class corresponding to the entity class field name.
14. An installation package generating device, characterized in that: Applicable to development terminals, the device includes: A first obfuscation module is used to obfuscate the original code of the entity class in the original installation code of the application to obtain the obfuscated code of the entity class; A generation module is used to generate an installation package of the application according to the entity class obfuscation code.
15. A code obfuscation device, characterized in that: Applied to a server, the device includes: A second obfuscation module is configured to obfuscate the entity class original code in the original installation code of the application according to the mapping file to obtain the entity class obfuscated code; the mapping file contains the correspondence between the entity class original code in the original installation code of the application and the entity class obfuscated code; A conversion module, used for converting the entity class obfuscation code into an entity class obfuscation string; The sending module is configured to send the entity class obfuscated character string to a user terminal, so that the user terminal is mapped to the entity class corresponding to the application based on the entity class obfuscated character string.
16. A code obfuscation device, characterized in that: Applied to a user terminal, the device includes: An installation module, configured to install the application based on an installation package of the application; the installation package includes entity class obfuscation code of the application; A receiving module, configured to receive an entity class obfuscated string sent by a server; the entity class obfuscated string is obtained by converting an entity class obfuscated code; the entity class obfuscated code is obtained by obfuscating the entity class original code in the original installation code of the application according to a mapping file; the mapping file contains a correspondence between the entity class original code in the original installation code of the application and its entity class obfuscated code; A mapping module is used to map the entity class obfuscation code in the installation package to the entity class corresponding to the entity class field name if the field name of the entity class obfuscation string is the same as the entity class field name specified by the entity class obfuscation code in the installation package.
17. A code obfuscation system, characterized in that: The system includes: The development terminal is configured to obfuscate the original entity class code in the original installation code of the application to obtain the entity class obfuscated code; generate an installation package for the application based on the entity class obfuscated code; and send a mapping file to the server; the mapping file contains a correspondence between the original entity class code in the original installation code of the application and its entity class obfuscated code; The server is configured to obfuscate the entity class original code in the original installation code of the application according to the mapping file to obtain the entity class obfuscated code, convert the entity class obfuscated code into an entity class obfuscated string, and send the entity class obfuscated string to the user terminal; A user terminal is used to install the application based on the installation package; and when the field name corresponding to the entity class obfuscation string is the same as the entity class field name specified by the entity class obfuscation code in the installation package, the entity class obfuscation code in the installation package is mapped to the entity class corresponding to the entity class field name.
18. An electronic device, characterized in that: The method comprises a processor and a memory, wherein the memory stores computer-readable instructions, and when the computer-readable instructions are executed by the processor, the method according to any one of claims 1 to 13 is executed.
19. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 13 is executed.
20. A computer program product comprising a computer program or instructions, characterized in that When the computer program or instruction is executed by a processor, the method according to any one of claims 1 to 13 is executed.
Citation Information
Patent Citations
Obfuscation method and obfuscation device for application program code
CN106326693A
Code obfuscation method and system, computer device and computer readable storage medium
CN109784009A
Installation package generation method, code obfuscation method, device and system
CN118113315A
Use of code obfuscation to inhibit generation of non-use-restricted versions of copy protected software applications
US6643775B1
Method for identifying SDK in application, terminal, and server
WO2023169212A1