CN115935302B - Android installation package generation method and device - Google Patents

Android installation package generation method and device Download PDF

Info

Publication number
CN115935302B
CN115935302B CN202211612101.5A CN202211612101A CN115935302B CN 115935302 B CN115935302 B CN 115935302B CN 202211612101 A CN202211612101 A CN 202211612101A CN 115935302 B CN115935302 B CN 115935302B
Authority
CN
China
Prior art keywords
resource
file
random
package
android
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202211612101.5A
Other languages
Chinese (zh)
Other versions
CN115935302A (en
Inventor
盛金平
贺鹏飞
冯俊
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen Tange Intelligent Technology Co ltd
Original Assignee
Shenzhen Tange Intelligent Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shenzhen Tange Intelligent Technology Co ltd filed Critical Shenzhen Tange Intelligent Technology Co ltd
Priority to CN202211612101.5A priority Critical patent/CN115935302B/en
Publication of CN115935302A publication Critical patent/CN115935302A/en
Application granted granted Critical
Publication of CN115935302B publication Critical patent/CN115935302B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The application discloses a method and a device for generating an android installation package, wherein the method comprises the steps of obtaining a compiled resource file compression package, byte codes and application list files for generating the android installation package; carrying out confusion processing on preset contents contained in the resource file compression package to obtain a target resource file package, wherein the confusion processing is used for changing mapping information in the preset contents and names of resource files, and the mapping information is used for representing the relation between each resource name and a path of the resource file referenced by the mapping information; and packaging the target resource file package, the byte code and the application manifest file to generate an android installation package. The method solves the technical problems that the resource file and the application manifest file cannot be protected and the code security is low in the related technology, increases the analysis and cracking difficulty of a cracker on the resource class code, and improves the code security.

Description

Android installation package generation method and device
Technical Field
The application belongs to the technical field of computers, and particularly relates to a method and a device for generating an android installation package.
Background
After the Android application is developed, the Android application is packaged into an APK and provided for a user to install and use. In order to avoid the internal implementation principle of the application being snooped by others and to protect commercial secrets, some means are generally implemented to promote the code security in APK. The Android APK comprises three types of Java bytecodes, an application manifest file (Android manifest file, xml) and a resource file.
In the related art, the protection means provided by the Android authorities at present is a scheme named code confusion, and aiming at Java byte codes obtained by compiling and generating Java source files, variable names, class names, method names and the like in the Java byte codes are replaced by random English letters. The scheme can not protect the resource file and the application list file, and the code security is low.
Aiming at the technical problems that the resource file and the application manifest file cannot be protected and the code security is low in the related technology, no effective solution is proposed at present.
Disclosure of Invention
Therefore, an embodiment of the present application is to provide a method, an apparatus, an electronic device, and a storage medium for generating an android installation package, which aim to solve at least one problem existing in the prior art.
In order to achieve the above object, in a first aspect, the present application provides a method for generating an android installation package, including:
acquiring a compiled resource file compression package, byte codes and an application manifest file for generating an android installation package;
carrying out confusion processing on preset contents contained in the resource file compression package to obtain a target resource file package, wherein the confusion processing is used for changing mapping information in the preset contents and names of resource files, and the mapping information is used for representing the relation between each resource name and a path of the resource file referenced by the mapping information;
And packaging the target resource file package, the byte code and the application manifest file to generate an android installation package.
In one embodiment, the obfuscating the preset content included in the resource file compression packet to obtain a target resource file packet includes:
analyzing the binary files in the resource file compression package to obtain a key value mapping table for recording the mapping information;
replacing the value of the resource name of each row in the key value mapping table by using a first random character string, renaming the resource file referenced by each resource name in the resource file compression package into the first random character string according to the mapping information to obtain a replaced resource file, and updating the replaced resource file into the value of the corresponding path of the resource name in the key value mapping table to obtain the target resource file package; wherein the values of the first random strings utilized when processing mapping information of different rows are different.
In one embodiment, further comprising:
generating a random dictionary, wherein each item of the random dictionary is a word formed by using a plurality of random English letters;
an unused word is taken from the random dictionary as the first random string and marked as used in the random dictionary.
In one embodiment, before the android installation package is generated by packaging, the method further comprises:
processing the byte codes by using a byte code confusion tool to obtain the mixed byte codes;
and collecting all construction functions of the byte code files aiming at each byte code file in the mixed byte codes, and randomly inserting a plurality of lines of interference codes in the middle of each construction function to obtain the interfered byte code files.
In one embodiment, further comprising:
judging whether each interfered byte code file is based on the realization of four android components or not;
if not, skipping;
if yes, renaming the original file name of the byte code file into a second random character string;
searching all other byte code files referring to the byte code file, and replacing the original file name of the byte code file referred to in the reference path with the second random character string;
wherein the values of the second random strings utilized in processing different byte code files are different.
In one embodiment, further comprising:
and generating an android four-component Key Value mapping table, assigning the original file name as a Key Value of the android four-component Key Value mapping table, and assigning the second random character string as a Value of the android four-component Key Value mapping table.
In one embodiment, before the android installation package is generated by packaging, the method further comprises:
analyzing the application list file, processing each item of component in the application list file item by item, and changing the Value of the android name of the item of component into the Value of the Value corresponding to the Key in the Key mapping table of the four android components if the Value of the android name of the item of component is the same as the Value of a Key in the Key mapping table of the four android components.
In one embodiment, further comprising:
generating a random dictionary, wherein each item of the random dictionary is a word formed by using a plurality of random English letters;
taking an unused word in the random dictionary as the second random string, and marking the word as used in the random dictionary.
In a second aspect, the present application further provides a device for generating an android installation package, including:
the acquisition module is used for acquiring the compiled resource file compression package, byte codes and application list files for generating the android installation package;
the resource protection module is used for carrying out confusion processing on preset contents contained in the resource file compression package to obtain a target resource file package, wherein the confusion processing is used for changing mapping information in the preset contents and names of resource files, and the mapping information is used for representing the relation between each resource name and a path of the resource file referenced by the mapping information;
And the packaging module is used for packaging the target resource file package, the byte codes and the application manifest file to generate an android installation package.
In a third aspect, the present application further provides an electronic device, including a memory and a processor, where the memory stores a computer program, and when the computer program is executed by the processor, the processor is caused to execute the steps of the method for generating the android installation package.
In a fourth aspect, the present application also provides a computer readable storage medium, on which a computer program is stored, which when executed by a processor, causes the processor to execute the steps of the method for generating an android installation package.
According to the method, the device, the electronic equipment and the storage medium for generating the android installation package, which are provided by the embodiment of the application, the resource file compression package, the byte code and the application list file for generating the android installation package are obtained through compiling; carrying out confusion processing on preset contents contained in the resource file compression package to obtain a target resource file package, wherein the confusion processing is used for changing mapping information in the preset contents and names of resource files, and the mapping information is used for representing the relation between each resource name and a path of the resource file referenced by the mapping information; and packaging the target resource file package, the byte code and the application manifest file to generate an android installation package. The technical problems that the resource file and the application manifest file cannot be protected and the code security is low in the related technology are solved, and the following beneficial effects are realized by carrying out confusion processing on the resource file compression package for generating the android installation package: the analysis and cracking difficulty of a cracker on the resource class code is increased, and the safety of the code is improved.
Drawings
The accompanying drawings, which are included to provide a further understanding of the application, are incorporated in and constitute a part of this specification. The drawings and their description are illustrative of the application and are not to be construed as unduly limiting the application. In the drawings:
fig. 1 is a realization flow of a method for generating an android installation package according to an embodiment of the present application;
fig. 2 is a system architecture diagram of a method for generating an android installation package according to an embodiment of the present application;
fig. 3 is a schematic diagram of main modules of a generating device of an android installation package according to an embodiment of the present application;
FIG. 4 is a diagram of an exemplary system architecture to which embodiments of the present application may be applied;
fig. 5 is a schematic diagram of a computer system suitable for use in implementing an embodiment of the present application.
Detailed Description
In order that those skilled in the art will better understand the present application, a technical solution in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings in which it is apparent that the described embodiments are only some embodiments of the present application, not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the present application without making any inventive effort, shall fall within the scope of the present application.
It should be noted that the terms "first," "second," and the like in the description and the claims of the present application and the above figures are used for distinguishing between similar objects and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used may be interchanged where appropriate in order to describe the embodiments of the application herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
In the present application, the terms "upper", "lower", "left", "right", "front", "rear", "top", "bottom", "inner", "outer", "middle", "vertical", "horizontal", "lateral", "longitudinal" and the like indicate an azimuth or a positional relationship based on that shown in the drawings. These terms are only used to better describe the present application and its embodiments and are not intended to limit the scope of the indicated devices, elements or components to the particular orientations or to configure and operate in the particular orientations.
Also, some of the terms described above may be used to indicate other meanings in addition to orientation or positional relationships, for example, the term "upper" may also be used to indicate some sort of attachment or connection in some cases. The specific meaning of these terms in the present application will be understood by those of ordinary skill in the art according to the specific circumstances.
In addition, the term "plurality" shall mean two as well as more than two.
It should be noted that the terms mentioned in the present application follow the following description: android is an open source code mobile operating system based on a Linux kernel, is one of the currently mainstream mobile phone operating systems, and Android development refers to application program development based on an Android system; APK is totally called Android application package, is a finished product installation package obtained by packing after the development of the Android application program, and a user can directly install the APK on the Android mobile phone and use the corresponding application program function; java, a programming language; the Java source file, the code file written by a developer in Java language, the Java byte code which can be directly read and understood by human, can also be called simply as byte code, a product compiled by the Java source file and an instruction format executed by a Java virtual machine; a Java program, a handler for compiling Java source files into Java bytecodes, provided by Java authorities; the Dex program is used for converting Java byte codes into a processing program of codes capable of running on the Android platform; proguard program, a Java bytecode obfuscation tool provided by the Android authorities; in the resource. Ap_, android compiling process, the intermediate product after resource compiling is essentially a resource file compression package; the resources, arsc, the binary file generated after Android resource compiling contains mapping information from resource names to paths; the four components are basic building blocks of the Android application, and developers inherit the components to realize the operation of the components under the mechanism of the Android system, and the components have four types: activity, service, content provider, broadcast receiver; android manifest file is mainly used for declaring which components are in the Android application manifest file, and the Android system runs the corresponding components according to the declaration.
In the application, after the Android application is developed, the Android application is packaged into an APK and provided for a user to install and use. In order to avoid the internal implementation principle of the application being snooped by others and to protect commercial secrets, some means are generally implemented to promote the code security in APK.
At present, the protection means provided by the Android authorities is a scheme named code confusion. The specific scheme is as follows: for Java byte codes generated by compiling Java source files, variable names, class names, method names and the like in the Java byte codes are replaced by random English letters. Even if the external breaker decompiles Java byte codes into Java source codes, the external breaker can only see codes composed of randomly disordered English letters, the difficulty of understanding code logic is increased, and a certain code protection effect is achieved.
The problems of the above official technical solutions are: the Android APK has the composition of Java byte codes, and two categories of an application manifest file (Android manifest. Xml) and a resource file, and the code cannot be protected by using an official scheme. The official scheme is not confusing for the four large components, which also reduces the security of the code; meanwhile, the official scheme only replaces names in the codes, but the main execution logic of the codes is still reserved, and external personnel can guess the approximate implementation according to the decompiled codes, so that the code security can be damaged.
Based on the above, the application provides a novel Android application code security protection scheme for solving the problems.
It should be noted that, without conflict, the embodiments of the present application and features of the embodiments may be combined with each other. The application will be described in detail below with reference to the drawings in connection with embodiments.
Fig. 1 shows a realization flow of a method for generating an android installation package according to an embodiment of the present application, and for convenience of explanation, only the portions relevant to the embodiment of the present application are shown, which are described in detail below:
the android installation package generation method comprises the following steps:
s101: acquiring a compiled resource file compression package, byte codes and an application manifest file for generating an android installation package;
s102: carrying out confusion processing on preset contents contained in the resource file compression package to obtain a target resource file package, wherein the confusion processing is used for changing mapping information in the preset contents and names of resource files, and the mapping information is used for representing the relation between each resource name and a path of the resource file referenced by the mapping information;
s103: and packaging the target resource file package, the byte code and the application manifest file to generate an android installation package.
In step S101: and obtaining the compiled resource file compression package, byte codes and application list files for generating the android installation package. Here, the developer may compile the code through the code compiling platform, and after compiling the resource file compression package (i.e. resources. Ap) for generating apk, the byte code and the application manifest file (i.e. android management. Xml) in the compiling platform, obtain the resource file compression package, the byte code and the application manifest file obtained by compiling for generating the android installation package, so as to facilitate the subsequent code protection processing.
It should be noted that, a developer may compile and obtain resources.ap_, bytecodes, android management.xml by starting the Android engineering compiling process.
In step S102: and carrying out confusion processing on preset contents contained in the resource file compression package to obtain a target resource file package, wherein the confusion processing is used for changing mapping information in the preset contents and names of resource files, and the mapping information is used for representing the relation between each resource name and a path of the resource file referenced by the mapping information. After obtaining the resources.ap_, the byte codes and the android management.xml, carrying out confusion processing on preset contents contained in the resources.ap so as to obtain the protected resources.ap. Here, the confusion process is used for changing the mapping information in the preset content and the names of the resource files, where the mapping information is used for representing the relationship between each resource name and the path of the resource file referenced by the resource name, that is, only the mapping information in the preset content and the names of the resource files are changed, and the original mapping information and the names of the resource files cannot be known after decompilation. The preset content may be content in a folder obtained by decompressing the resource file compression package, for example, the folder includes a binary file and a plurality of files, the binary file is parsed to obtain a mapping table, mapping information is recorded in the mapping table, and the plurality of files are resource files.
In one embodiment, the obfuscating the preset content included in the resource file compression packet to obtain a target resource file packet includes: analyzing the binary files in the resource file compression package to obtain a key value mapping table for recording the mapping information; replacing the value of the resource name of each row in the key value mapping table by using a first random character string, renaming the resource file referenced by each resource name in the resource file compression package into the first random character string according to the mapping information to obtain a replaced resource file, and updating the replaced resource file into the value of the corresponding path of the resource name in the key value mapping table to obtain the target resource file package; wherein the values of the first random strings utilized when processing mapping information of different rows are different. Here, before the binary files in the resource file compression package are parsed, the Resources may be decompressed to obtain a folder, for example, the Resources-Dir folder in fig. 2 is the folder obtained after decompression, and the folder includes the binary files and a plurality of referenced resource files, for example, the Resources-arsc folder in fig. 2 is the binary files, and specific resource files, such as xml files, png files, and the like. As shown in the table of the resource protection module part in fig. 2, the name column describes the resource name, and the path column describes the corresponding path.
In one embodiment, further comprising: generating a random dictionary, wherein each item of the random dictionary is a word formed by using a plurality of random English letters; an unused word is taken from the random dictionary as the first random string and marked as used in the random dictionary.
For example, specifically, as shown in the flow of the Resource protection module in fig. 2, the resources. Ap_ is decompressed to obtain the Resource-Dir folder: contains resource.arsc, and specific resource files, such as xml files, png files, etc., to which it refers. Generating a random dictionary, wherein each item is a word formed by a plurality of random English letters; the resource. Arsc is analyzed, and the following processing is performed for each line of mapping information in the resource. Arsc: and randomly picking an unused word from the random dictionary, marking the word as used in the random dictionary, replacing the value of the Name of the current line mapping information of the resource. Arsc with the word, finding a file of a Path corresponding to the Path from the resource-Dir folder, renaming the file Name of the file as the word, and replacing the value of the Path of the current line mapping information of the resource. Arsc with the latest Path of the previous file, thereby completing the processing of the current line of the resource. Arsc. And finally, recompressing the Resources-Dir folder to obtain resources.ap_ after the protection processing, and obtaining the target resource file package.
Further, the method also comprises the following steps: processing the byte codes by using a byte code confusion tool to obtain the mixed byte codes; and collecting all construction functions of the byte code files aiming at each byte code file in the mixed byte codes, and randomly inserting a plurality of lines of interference codes in the middle of each construction function to obtain the interfered byte code files. Thereby further improving the security of the code by obfuscating the bytecode.
Further, the method further comprises the following steps: judging whether each interfered byte code file is based on the realization of four android components or not; if not, skipping; if yes, renaming the original file name of the byte code file into a second random character string; searching all other byte code files referring to the byte code file, and replacing the original file name of the byte code file referred to in the reference path with the second random character string; wherein the values of the second random strings utilized in processing different byte code files are different. Thus, the execution logic of the code is prevented from being speculated after decompilation, and the code security is further improved. Here, a random dictionary may be generated, each item of the random dictionary being a word composed of a plurality of random english letters; taking an unused word in the random dictionary as the second random string and marking the word as used in the random dictionary, thereby preventing repeated confusing characters from occurring at the code run time to cause program errors.
Further, the method further comprises the following steps: and generating an android four-component Key Value mapping table, assigning the original file name as a Key Value of the android four-component Key Value mapping table, and assigning the second random character string as a Value of the android four-component Key Value mapping table. Therefore, high safety protection of the byte codes is realized, errors of each reference path during program operation are prevented, and the stability of the system is improved while the safety of the codes is improved.
In one embodiment, further comprising: analyzing the application list file, processing each item of component in the application list file item by item, and changing the Value of the android name of the item of component into the Value of the Value corresponding to the Key in the Key mapping table of the four android components if the Value of the android name of the item of component is the same as the Value of a Key in the Key mapping table of the four android components.
Specifically, as shown in fig. 2, the program Proguard is used to process the bytecode to obtain the obfuscated bytecode; generating a mapping table of four large components, and storing mapping information of the four large components after randomization in the subsequent process; generating a random dictionary, wherein each item is a word formed by a plurality of random English letters; for each byte code file in the obfuscated byte code, the following processing is implemented: collecting all construction function information of a current byte code file, and randomly inserting a plurality of lines of interference codes in the middle of each function to obtain an interfered byte code; judging whether the current byte code is the realization of four large components (android four large components), and if not, skipping; if yes, continuing the next step, namely randomly taking an unused word from the random dictionary, marking the word as used in the random dictionary, and modifying the original file name of the current byte code into the word taken in the last step; analyzing and processing all other byte code files except the current byte code file: if the current byte code file is found to be referenced by a certain byte code file, modifying the original file name of the current byte code file referenced by the certain byte code file into a word; finally, in the four-component mapping table, mapping information of 'key=original file name and value=word' is recorded, so that the byte code after the protection processing is obtained.
Meanwhile, analyzing android management.xml, and analyzing and processing each component: if the Value of the android name of the item is the same as the Value of a certain Key in the four-component mapping table, replacing the Value of the android name with the Value corresponding to the Key in the four-component mapping table, thereby obtaining the android management.
In step S103: and packaging the target resource file package, the byte code and the application manifest file to generate an android installation package. Therefore, the resources.ap_, the byte codes and the android management.xml after the protection processing are packed to obtain the final installation package APK file, so that the code security protection is realized, and the code security is improved.
Therefore, the android installation package generation method provided by the application uses the resource protection module, introduces a file naming randomization flow in the global scope of the resource file, increases the analysis and cracking difficulty of a cracker on the resource class code, and improves the code security; the byte code protection module is used, four components of protection capability are introduced for the byte code file, randomly generated interference codes are embedded in the code file, and the understanding difficulty of a cracking person on the byte code main body logic is increased; by using the application list file protection module and combining the byte code protection module, a mechanism of naming randomization of four large components is introduced, and the defect that the use condition of the four large components is easy to analyze and crack due to the use of the prior art is avoided.
Furthermore, three main modules within the solution of the application: the resource protection module, the byte code protection module and the application list file protection module are all packaged into an application code protection device with black box property, and a developer can quickly and cost-effectively improve code safety by only introducing the device into Android engineering.
Therefore, according to the android installation package generation method provided by the embodiment of the application, the compiled resource file compression package, the byte code and the application list file for generating the android installation package are obtained; carrying out confusion processing on preset contents contained in the resource file compression package to obtain a target resource file package, wherein the confusion processing is used for changing mapping information in the preset contents and names of resource files, and the mapping information is used for representing the relation between each resource name and a path of the resource file referenced by the mapping information; and packaging the target resource file package, the byte code and the application manifest file to generate an android installation package. The technical problems that the resource file and the application manifest file cannot be protected and the code security is low in the related technology are solved, and the following beneficial effects are realized by carrying out confusion processing on the resource file compression package for generating the android installation package: the analysis and cracking difficulty of a cracker on the resource class code is increased, and the safety of the code is improved.
Fig. 3 is a schematic diagram of a main module of a generating device of an android installation package according to an embodiment of the present application, and for convenience of explanation, only a portion relevant to the embodiment of the present application is shown, which is described in detail below:
an android installation package generating apparatus 200, comprising:
an obtaining module 201, configured to obtain a compiled resource file compression package, byte codes and application manifest file for generating an android installation package;
a resource protection module 202, configured to perform confusion processing on preset content included in the resource file compression packet to obtain a target resource file packet, where the confusion processing is used to change mapping information in the preset content and names of resource files, and the mapping information is used to characterize a relationship between each resource name and a path of a resource file referenced by the mapping information;
and the packaging module 203 is configured to package the target resource file package, the byte code and the application manifest file to generate an android installation package.
For the obtaining module 201, the obtaining module is configured to obtain the compiled resource file compression package, the bytecode and the application manifest file for generating the android installation package. Here, the developer may compile the code through the code compiling platform, and after compiling the resource file compression package (i.e. resources. Ap) for generating apk, the byte code and the application manifest file (i.e. android management. Xml) in the compiling platform, obtain the resource file compression package, the byte code and the application manifest file obtained by compiling for generating the android installation package, so as to facilitate the subsequent code protection processing.
It should be noted that, a developer may compile and obtain resources.ap_, bytecodes, android management.xml by starting the Android engineering compiling process.
The resource protection module 202 is configured to perform confusion processing on preset content included in the resource file compression package to obtain a target resource file package, where the confusion processing is used to change mapping information in the preset content and names of resource files, and the mapping information is used to characterize a relationship between each resource name and a path of a resource file referenced by the mapping information. After obtaining the resources.ap_, the byte codes and the android management.xml, carrying out confusion processing on preset contents contained in the resources.ap so as to obtain the protected resources.ap. Here, the confusion process is used for changing the mapping information in the preset content and the names of the resource files, where the mapping information is used for representing the relationship between each resource name and the path of the resource file referenced by the resource name, that is, only the mapping information in the preset content and the names of the resource files are changed, and the original mapping information and the names of the resource files cannot be known after decompilation. The preset content may be content in a folder obtained by decompressing the resource file compression package, for example, the folder includes a binary file and a plurality of files, the binary file is parsed to obtain a mapping table, mapping information is recorded in the mapping table, and the plurality of files are resource files.
In one embodiment, the obfuscating the preset content included in the resource file compression packet to obtain a target resource file packet includes: analyzing the binary files in the resource file compression package to obtain a key value mapping table for recording the mapping information; replacing the value of the resource name of each row in the key value mapping table by using a first random character string, renaming the resource file referenced by each resource name in the resource file compression package into the first random character string according to the mapping information to obtain a replaced resource file, and updating the replaced resource file into the value of the corresponding path of the resource name in the key value mapping table to obtain the target resource file package; wherein the values of the first random strings utilized when processing mapping information of different rows are different. Here, before the binary files in the resource file compression package are parsed, the Resources may be decompressed to obtain a folder, for example, the Resources-Dir folder in fig. 2 is the folder obtained after decompression, and the folder includes the binary files and a plurality of referenced resource files, for example, the Resources-arsc folder in fig. 2 is the binary files, and specific resource files, such as xml files, png files, and the like. As shown in the table of the resource protection module part in fig. 2, the name column describes the resource name, and the path column describes the corresponding path.
In one embodiment, the method further comprises a first random dictionary examining module for generating a random dictionary, wherein each item of the random dictionary is a word composed of a plurality of random English letters; an unused word is taken from the random dictionary as the first random string and marked as used in the random dictionary.
For example, specifically, as shown in the flow of the Resource protection module in fig. 2, the resources. Ap_ is decompressed to obtain the Resource-Dir folder: contains resource.arsc, and specific resource files, such as xml files, png files, etc., to which it refers. Generating a random dictionary, wherein each item is a word formed by a plurality of random English letters; the resource. Arsc is analyzed, and the following processing is performed for each line of mapping information in the resource. Arsc: and randomly picking an unused word from the random dictionary, marking the word as used in the random dictionary, replacing the value of the Name of the current line mapping information of the resource. Arsc with the word, finding a file of a Path corresponding to the Path from the resource-Dir folder, renaming the file Name of the file as the word, and replacing the value of the Path of the current line mapping information of the resource. Arsc with the latest Path of the previous file, thereby completing the processing of the current line of the resource. Arsc. And finally, recompressing the Resources-Dir folder to obtain resources.ap_ after the protection processing, and obtaining the target resource file package.
Further, the device also comprises a byte code protection module, which is used for processing the byte codes by using a byte code confusion tool to obtain the confused byte codes; and collecting all construction functions of the byte code files aiming at each byte code file in the mixed byte codes, and randomly inserting a plurality of lines of interference codes in the middle of each construction function to obtain the interfered byte code files. Thereby further improving the security of the code by obfuscating the bytecode.
Further, the byte code protection module is further used for judging whether each interfered byte code file is based on the realization of four android components; if not, skipping; if yes, renaming the original file name of the byte code file into a second random character string; searching all other byte code files referring to the byte code file, and replacing the original file name of the byte code file referred to in the reference path with the second random character string; wherein the values of the second random strings utilized in processing different byte code files are different. Thus, the execution logic of the code is prevented from being speculated after decompilation, and the code security is further improved. Here, a random dictionary may be generated, each item of the random dictionary being a word composed of a plurality of random english letters; taking an unused word in the random dictionary as the second random string and marking the word as used in the random dictionary, thereby preventing repeated confusing characters from occurring at the code run time to cause program errors.
Further, the byte code protection module is further configured to generate an android four-component Key Value mapping table, assign the original file name to be a Key Value of the android four-component Key Value mapping table, and assign the second random string to be a Value of the android four-component Key Value mapping table. Therefore, high safety protection of the byte codes is realized, errors of each reference path during program operation are prevented, and the stability of the system is improved while the safety of the codes is improved.
In one embodiment, the method further includes an application manifest file protection module, configured to parse the application manifest file, process each item component in the application manifest file item by item, and if a Value of an android name of the item component is the same as a Value of a Key in the android four-component Key Value mapping table, change the Value of the android name of the item component to a Value corresponding to the Key in the android four-component Key Value mapping table.
Specifically, as shown in fig. 2, the program Proguard is used to process the bytecode to obtain the obfuscated bytecode; generating a mapping table of four large components, and storing mapping information of the four large components after randomization in the subsequent process; generating a random dictionary, wherein each item is a word formed by a plurality of random English letters; for each byte code file in the obfuscated byte code, the following processing is implemented: collecting all construction function information of a current byte code file, and randomly inserting a plurality of lines of interference codes in the middle of each function to obtain an interfered byte code; judging whether the current byte code is the realization of four large components (android four large components), and if not, skipping; if yes, continuing the next step, namely randomly taking an unused word from the random dictionary, marking the word as used in the random dictionary, and modifying the original file name of the current byte code into the word taken in the last step; analyzing and processing all other byte code files except the current byte code file: if the current byte code file is found to be referenced by a certain byte code file, modifying the original file name of the current byte code file referenced by the certain byte code file into a word; finally, in the four-component mapping table, mapping information of 'key=original file name and value=word' is recorded, so that the byte code after the protection processing is obtained.
Meanwhile, analyzing android management.xml, and analyzing and processing each component: if the Value of the android name of the item is the same as the Value of a certain Key in the four-component mapping table, replacing the Value of the android name with the Value corresponding to the Key in the four-component mapping table, thereby obtaining the android management.
And the packaging module 203 is configured to package the target resource file package, the byte code and the application manifest file to generate an android installation package. Therefore, the resources.ap_, the byte codes and the android management.xml after the protection processing are packed to obtain the final installation package APK file, so that the code security protection is realized, and the code security is improved.
Therefore, the android installation package generating device provided by the application uses the resource protection module, introduces a file naming randomization flow in the global scope of the resource file, increases the analysis and cracking difficulty of a cracker on the resource class code, and improves the code safety; the byte code protection module is used, four components of protection capability are introduced for the byte code file, randomly generated interference codes are embedded in the code file, and the understanding difficulty of a cracking person on the byte code main body logic is increased; by using the application list file protection module and combining the byte code protection module, a mechanism of naming randomization of four large components is introduced, and the defect that the use condition of the four large components is easy to analyze and crack due to the use of the prior art is avoided.
Furthermore, three main modules within the solution of the application: the resource protection module, the byte code protection module and the application list file protection module are all packaged into an application code protection device with black box property, and a developer can quickly and cost-effectively improve code safety by only introducing the device into Android engineering.
Therefore, the android installation package generating device solves the technical problems that the resource files and the application list files cannot be protected in the related technology, and the code security is low, and the following beneficial effects are realized by carrying out confusion processing on the resource file compression package for generating the android installation package: the analysis and cracking difficulty of a cracker on the resource class code is increased, and the safety of the code is improved.
The embodiment of the application also provides electronic equipment, which comprises: one or more processors; and the storage device is used for storing one or more programs, and when the one or more programs are executed by the one or more processors, the one or more processors realize the generation method of the android installation package.
The embodiment of the application also provides a computer readable medium, on which a computer program is stored, which when executed by a processor, implements the method for generating the android installation package according to the embodiment of the application.
Fig. 4 illustrates an exemplary system architecture 300 to which the android installation package generation method or apparatus of embodiments of the present application may be applied.
As shown in fig. 4, the system architecture 300 may include terminal devices 301, 302, 303, a network 304, and a server 305. The network 304 is used as a medium to provide communication links between the terminal devices 301, 302, 303 and the server 305. The network 304 may include various connection types, such as wired, wireless communication links, or fiber optic cables, among others.
A user may interact with the server 305 via the network 304 using the terminal devices 301, 302, 303 to receive or send messages or the like. Various communication client applications, such as shopping class applications, web browser applications, search class applications, instant messaging tools, mailbox clients, social platform software, etc., may be installed on the terminal devices 301, 302, 303.
The terminal devices 301, 302, 303 may be a variety of electronic devices having a display screen and supporting web browsing, including but not limited to smartphones, tablets, laptop and desktop computers, and the like.
The server 305 may be a server providing various services, such as a background management server providing support for user messages sent to and from the terminal devices 301, 302, 303. The background management server can perform analysis and other processes after receiving the terminal equipment request, and feed back the processing result to the terminal equipment.
It should be noted that, the method for generating the android installation package provided in the embodiment of the present application is generally executed by the terminal device 301, 302, 303 or the server 305, and accordingly, the generating device of the android installation package is generally set in the terminal device 301, 302, 303 or the server 305.
It should be understood that the number of terminal devices, networks and servers in fig. 4 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
Referring now to FIG. 5, there is illustrated a schematic diagram of a computer system 400 suitable for use in implementing an electronic device of an embodiment of the present application. The computer system illustrated in fig. 5 is merely an example, and should not be construed as limiting the functionality and scope of use of embodiments of the present application.
As shown in fig. 5, the computer system 400 includes a Central Processing Unit (CPU) 401, which can perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM) 402 or a program loaded from a storage section 408 into a Random Access Memory (RAM) 403. In RAM 403, various programs and data required for the operation of system 400 are also stored. The CPU 401, ROM 402, and RAM 403 are connected to each other by a bus 404. An input/output (I/O) interface 405 is also connected to bus 404.
The following components are connected to the I/O interface 405: an input section 406 including a keyboard, a mouse, and the like; an output portion 407 including a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, and a speaker, and the like; a storage section 408 including a hard disk or the like; and a communication section 409 including a network interface card such as a LAN card, a modem, or the like. The communication section 409 performs communication processing via a network such as the internet. The drive 410 is also connected to the I/O interface 405 as needed. A removable medium 411 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is installed on the drive 410 as needed, so that a computer program read therefrom is installed into the storage section 408 as needed.
In particular, according to embodiments of the present disclosure, the processes described above with reference to flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method shown in the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network via the communication portion 409 and/or installed from the removable medium 411. The above-described functions defined in the system of the present application are performed when the computer program is executed by a Central Processing Unit (CPU) 401.
The computer readable medium shown in the present application may be a computer readable signal medium or a computer readable storage medium, or any combination of the two. The computer readable storage medium can be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any of the foregoing. More specific examples of the computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of this document, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In the present application, however, the computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, with the computer-readable program code embodied therein. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination of the foregoing. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, fiber optic cable, RF, etc., or any suitable combination of the foregoing.
The flowcharts and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present application. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The modules involved in the embodiments of the present application may be implemented in software or in hardware. The described modules may also be provided in a processor, for example, as: a processor includes a determination module, an extraction module, a training module, and a screening module. Where the names of the modules do not constitute a limitation on the module itself in some cases, the determination module may also be described as "module for determining a candidate set of users", for example.
The foregoing examples illustrate only a few embodiments of the application and are described in detail herein without thereby limiting the scope of the application. It should be noted that it will be apparent to those skilled in the art that several variations and modifications can be made without departing from the spirit of the application, which are all within the scope of the application. Accordingly, the scope of protection of the present application is to be determined by the appended claims.
The above description is only of the preferred embodiments of the present application and is not intended to limit the present application, but various modifications and variations can be made to the present application by those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the protection scope of the present application.

Claims (8)

1. The method for generating the android installation package is characterized by comprising the following steps of:
acquiring a compiled resource file compression package, byte codes and an application manifest file for generating an android installation package;
carrying out confusion processing on preset contents contained in the resource file compression package to obtain a target resource file package, wherein the confusion processing is used for changing mapping information in the preset contents and names of resource files, and the mapping information is used for representing the relation between each resource name and a path of the resource file referenced by the mapping information;
Packaging the target resource file package, the byte code and the application manifest file to generate an android installation package;
the step of performing confusion processing on preset contents contained in the resource file compression package to obtain a target resource file package includes:
analyzing the binary files in the resource file compression package to obtain a key value mapping table for recording the mapping information;
replacing the value of the resource name of each row in the key value mapping table by using a first random character string, renaming the resource file referenced by each resource name in the resource file compression package into the first random character string according to the mapping information to obtain a replaced resource file, and updating the replaced resource file into the value of the corresponding path of the resource name in the key value mapping table to obtain the target resource file package; wherein the values of the first random strings utilized when processing mapping information of different rows are different;
the method further comprises the steps of:
generating a random dictionary, wherein each item of the random dictionary is a word formed by using a plurality of random English letters;
an unused word is taken from the random dictionary as the first random string and marked as used in the random dictionary.
2. The method for generating the android installation package according to claim 1, further comprising, before packaging to generate the android installation package:
processing the byte codes by using a byte code confusion tool to obtain the mixed byte codes;
and collecting all construction functions of the byte code files aiming at each byte code file in the mixed byte codes, and randomly inserting a plurality of lines of interference codes in the middle of each construction function to obtain the interfered byte code files.
3. The method for generating the android installation package according to claim 2, further comprising:
judging whether each interfered byte code file is based on the realization of four android components or not;
if not, skipping;
if yes, renaming the original file name of the byte code file into a second random character string;
searching all other byte code files referring to the byte code file, and replacing the original file name of the byte code file referred to in the reference path with the second random character string;
wherein the values of the second random strings utilized in processing different byte code files are different.
4. The method for generating the android installation package according to claim 3, further comprising:
And generating an android four-component Key Value mapping table, assigning the original file name as a Key Value of the android four-component Key Value mapping table, and assigning the second random character string as a Value of the android four-component Key Value mapping table.
5. The method for generating the android installation package of claim 4, further comprising, prior to packaging to generate the android installation package:
analyzing the application list file, processing each item of component in the application list file item by item, and changing the Value of the android name of the item of component into the Value of the Value corresponding to the Key in the Key mapping table of the four android components if the Value of the android name of the item of component is the same as the Value of a Key in the Key mapping table of the four android components.
6. The method for generating the android installation package according to claim 3, further comprising:
generating a random dictionary, wherein each item of the random dictionary is a word formed by using a plurality of random English letters;
taking an unused word in the random dictionary as the second random string, and marking the word as used in the random dictionary.
7. The utility model provides a generating device of android installation package which characterized in that includes:
The acquisition module is used for acquiring the compiled resource file compression package, byte codes and application list files for generating the android installation package;
the resource protection module is used for carrying out confusion processing on preset contents contained in the resource file compression package to obtain a target resource file package, wherein the confusion processing is used for changing mapping information in the preset contents and names of resource files, and the mapping information is used for representing the relation between each resource name and a path of the resource file referenced by the mapping information;
the packaging module is used for packaging the target resource file package, the byte codes and the application manifest file to generate an android installation package;
the resource protection module is specifically used for analyzing the binary files in the resource file compression package to obtain a key value mapping table for recording the mapping information;
replacing the value of the resource name of each row in the key value mapping table by using a first random character string, renaming the resource file referenced by each resource name in the resource file compression package into the first random character string according to the mapping information to obtain a replaced resource file, and updating the replaced resource file into the value of the corresponding path of the resource name in the key value mapping table to obtain the target resource file package; wherein the values of the first random strings utilized when processing mapping information of different rows are different;
The resource protection module is also used for generating a random dictionary, and each item of the random dictionary is a word formed by using a plurality of random English letters;
an unused word is taken from the random dictionary as the first random string and marked as used in the random dictionary.
8. An electronic device comprising a memory and a processor, the memory having stored therein a computer program which, when executed by the processor, causes the processor to perform the steps of the method of generating an android installation package of any one of claims 1 to 6.
CN202211612101.5A 2022-12-13 2022-12-13 Android installation package generation method and device Active CN115935302B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211612101.5A CN115935302B (en) 2022-12-13 2022-12-13 Android installation package generation method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211612101.5A CN115935302B (en) 2022-12-13 2022-12-13 Android installation package generation method and device

Publications (2)

Publication Number Publication Date
CN115935302A CN115935302A (en) 2023-04-07
CN115935302B true CN115935302B (en) 2023-09-15

Family

ID=86655648

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211612101.5A Active CN115935302B (en) 2022-12-13 2022-12-13 Android installation package generation method and device

Country Status (1)

Country Link
CN (1) CN115935302B (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110781462A (en) * 2019-10-10 2020-02-11 郑州阿帕斯科技有限公司 Resource confusion method and device
CN112163195A (en) * 2020-10-14 2021-01-01 北京邮电大学 Novel virtual machine software protection method based on stack hiding
CN113094664A (en) * 2021-04-09 2021-07-09 每日互动股份有限公司 System for preventing android application program from being decompiled
CN113094667A (en) * 2021-04-09 2021-07-09 每日互动股份有限公司 System for preventing java program from being decompiled

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104166822B (en) * 2013-05-20 2017-10-13 阿里巴巴集团控股有限公司 A kind of method and apparatus of data protection

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110781462A (en) * 2019-10-10 2020-02-11 郑州阿帕斯科技有限公司 Resource confusion method and device
CN112163195A (en) * 2020-10-14 2021-01-01 北京邮电大学 Novel virtual machine software protection method based on stack hiding
CN113094664A (en) * 2021-04-09 2021-07-09 每日互动股份有限公司 System for preventing android application program from being decompiled
CN113094667A (en) * 2021-04-09 2021-07-09 每日互动股份有限公司 System for preventing java program from being decompiled

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
一种基于源代码的java代码混淆器的设计与实现;杨旭辉;甘肃科学学报;第27卷(第2期);1-5 *

Also Published As

Publication number Publication date
CN115935302A (en) 2023-04-07

Similar Documents

Publication Publication Date Title
CN105068932B (en) A kind of detection method of Android application programs shell adding
CN110502222B (en) AAR method, apparatus, medium, and device for outbound dependency on internal base repository
US20150007142A1 (en) Branch destination tables
US8615750B1 (en) Optimizing application compiling
CN108536451B (en) Method and device for embedding embedded point of application program
CN108229112A (en) A kind of operation method and device for protecting application program, application program
CN110781462B (en) Resource confusion method and device
CN110059456B (en) Code protection method, code protection device, storage medium and electronic equipment
CN109948308A (en) Code security guard method, device, electronic equipment and computer readable storage medium
CN111736840A (en) Compiling method and running method of applet, storage medium and electronic equipment
CN111176717B (en) Method and device for generating installation package and electronic equipment
CN109255235B (en) Mobile application third-party library isolation method based on user state sandbox
CN108647032B (en) Application loading method and device, computer device and computer readable storage medium
CN110688096B (en) Method and device for constructing application program containing plug-in, medium and electronic equipment
CN112527386B (en) Application program issuing method and device
CN112612502A (en) Patch generation method, device, equipment and storage medium
CN114925338A (en) Compiling method, device, equipment, medium and product
CN109739582B (en) Function calling method and device, electronic equipment and computer readable storage medium
CN112395098A (en) Application program interface calling method and device, storage medium and electronic equipment
Xie et al. Trimming mobile applications for bandwidth-challenged networks in developing regions
Li Mining androzoo: A retrospect
CN115935302B (en) Android installation package generation method and device
CN109240696A (en) A kind of Oftware updating method and device
CN115145574A (en) Code generation method and device, storage medium and server
CN113377376A (en) Data packet generation method, data packet generation device, electronic device, and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant