Application program automatic isomerization method and device, electronic equipment, medium and program
By randomly adjusting the relationship between mnemonics and opcodes in JAVA applications, automatic isomerization of applications is achieved, and compatible customized virtual machines are generated, solving the problems of high development costs and incompatible interfaces in existing technologies. , improving application security and development efficiency.
Patent Information
- Application Number
- CN202410629020.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-20
- Publication Date
- 2024-08-23
AI Technical Summary
In the existing technology, the development cost of implementing multiple heterogeneous versions of JAVA applications is high and the cycle is long. Moreover, the generated heterogeneous program and the source program are heterogeneous at the bytecode level, and the interfaces are incompatible, making it difficult to quickly Construct functionally equivalent and compatible isomerization programs.
By randomly adjusting the correspondence between mnemonics and opcodes in the program code, new correspondences between mnemonics and opcodes are generated, automatic isomerization of applications is achieved, and compatible customized virtual machines are generated to run heterogeneous Structure the program to reduce the probability of successful decompilation and improve security.
It realizes the rapid construction of multiple heterogeneous JAVA applications, ensures that the functions of the heterogeneous programs and the source programs are equivalent and the interfaces are compatible, reducing the development cost and cycle, while improving the security of the applications.
Smart Images

Figure CN118535165A
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a method, device, electronic device, medium and program for automatic isomerization of application programs. Background Art
[0002] Cyber Mimic Defense (CMD) is a defense method for dealing with unknown threats such as unknown vulnerabilities, backdoors, viruses or Trojans at the relevant application levels in different fields of cyberspace. It introduces a multi-dimensional dynamic reconstruction mechanism based on the redundant architecture in the reliability field, resulting in the strategy changes or transformations of the non-similar redundant structural elements inside the target object in terms of quantity, type, time or space dimensions under the condition that the function remains unchanged, and uses the uncertain defense principle to fight against the certain or uncertain threats in cyberspace.
[0003] At present, the heterogeneous redundancy technology of the mimetic security defense system includes heterogeneity at the hardware level and heterogeneity at the application software level. Traditional application heterogeneity needs to be achieved by independently developing multiple versions of applications with consistent interfaces. The implementation cost is relatively high and the development cycle is relatively long. This is a major difficulty in the mimetic transformation of conventional application systems. How to quickly build multiple heterogeneous JAVA applications based on a JAVA application, and the generated heterogeneous programs have bytecode-level heterogeneity with the source program, the heterogeneous programs are functionally equivalent to the original programs, and the interfaces of the heterogeneous programs are fully compatible with the original programs are currently urgent problems to be solved. Summary of the invention
[0004] The present invention provides a method, device, electronic device, medium and program for automatic isomerization of an application program. Automatic isomerization of an application program is achieved by randomly adjusting the correspondence between mnemonics and operation codes in program codes, thereby reducing the probability of successful decompilation of the application program and improving the security of the application program source code. The automatic isomerization process of the application program does not modify the business functions, thereby ensuring the stability of the application program.
[0005] According to one aspect of the present invention, a method for automatic isomerization of an application is provided, wherein the method comprises:
[0006] Generate a first correspondence between a mnemonic and an operation code corresponding to the heterogeneous program according to a preset random mapping rule;
[0007] Adjusting the original correspondence between the original mnemonics and the original operation codes in the program to be heterogeneous according to the first correspondence to obtain the isomerized program to be heterogeneous;
[0008] A customized virtual machine for running the program to be heterogeneous is generated according to the first corresponding relationship, wherein the customized virtual machine is used to run the heterogeneous program to be heterogeneous.
[0009] According to another aspect of the present invention, there is provided a device for automatically isomerizing an application program, wherein the device comprises:
[0010] A random mapping relationship generation module, used to generate a first correspondence relationship between a mnemonic and an operation code corresponding to a heterogeneous program according to a preset random mapping rule;
[0011] An application isomerization module, used for adjusting the original correspondence between the original mnemonics and the original operation codes in the program to be isomerized according to the first correspondence to obtain the isomerized program to be isomerized;
[0012] A customized virtual machine generation module is used to generate a customized virtual machine for running the program to be heterogeneous according to the first corresponding relationship, wherein the customized virtual machine is used to run the heterogeneous program to be heterogeneous.
[0013] According to another aspect of the present invention, an electronic device is provided, the electronic device comprising:
[0014] at least one processor; and
[0015] a memory communicatively connected to the at least one processor; wherein,
[0016] The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the method for automatic isomerization of an application program described in any embodiment of the present invention.
[0017] According to another aspect of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the method for automatic isomerization of an application program described in any embodiment of the present invention when executed.
[0018] According to another aspect of the present invention, a computer program product is provided. The computer program product includes a computer program. When the computer program is executed by a processor, the method for automatic isomerization of an application according to any embodiment of the present invention is implemented.
[0019] The technical solution of the embodiment of the present invention generates a first correspondence between mnemonics and operation codes of a program to be heterogeneous by presetting a random mapping rule, adjusts the original correspondence between original mnemonics and operation codes in the program to be heterogeneous based on the first correspondence between mnemonics and operation codes to obtain a heterogeneous program to be heterogeneous, generates a customized virtual machine of the program to be heterogeneous according to the first correspondence between mnemonics and operation codes, and the customized virtual machine is used to run the heterogeneous program to be heterogeneous, thereby realizing the heterogeneity of the code program, and can reduce the threat of external malicious insertion code to the security of the program code by randomly adjusting the correspondence between mnemonics and operation codes used in the program code, thereby ensuring the security of the program source code. At the same time, the update of the correspondence between mnemonics and operation codes in the source code can reduce the probability of successful decompilation of the application program, thereby further improving the security of the program.
[0020] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present invention, nor are they intended to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0022] Figure 1 is a flow chart of a method for automatic isomerization of an application program provided according to the first embodiment of the present invention;
[0023] Figure 2 is a flow chart of another method for automatic isomerization of an application program provided in accordance with the second embodiment of the present invention;
[0024] Figure 3 This is an example diagram of a corresponding relationship adjustment provided according to the second embodiment of the present invention;
[0025] Figure 4 is an example diagram of another correspondence relationship adjustment provided according to the second embodiment of the present invention;
[0026] Figure 5 is an example diagram of another correspondence relationship adjustment provided according to the second embodiment of the present invention;
[0027] Figure 6 is a flow chart of another method for automatic isomerization of an application program provided according to Embodiment 3 of the present invention;
[0028] Figure 7is a flowchart of another method for automatic isomerization of an application program provided according to a fourth embodiment of the present invention;
[0029] Figure 8 is a schematic diagram of the structure of a method for automatic isomerization of an application program provided in accordance with Embodiment 5 of the present invention;
[0030] Fig. 9 is a schematic diagram of the structure of an automatic isomerization device for an application program provided according to Embodiment 6 of the present invention;
[0031] Fig.10 It is a schematic diagram of the structure of an electronic device for implementing the method for automatic isomerization of application programs according to an embodiment of the present invention. DETAILED DESCRIPTION
[0032] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0033] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0034] Embodiment 1
[0035] Figure 1 1 is a flowchart of an automatic isomerization method for an application program according to the first embodiment of the present invention. This embodiment is applicable to the case where the application program software is heterogeneous. The method can be executed by an automatic isomerization device for an application program. The automatic isomerization device for an application program can be implemented in the form of hardware and / or software. The automatic isomerization device for an application program can be configured in a server or a user terminal. Figure 1 As shown, the method includes:
[0036] Step 110: Generate a first correspondence between a mnemonic and an operation code corresponding to the heterogeneous program according to a preset random mapping rule.
[0037] Among them, the preset random mapping rule can randomly generate a first correspondence between a mnemonic and an operation code, and the preset random mapping rule can be pre-configured or specified according to user needs. The program to be heterogeneous can be an application program that needs to be heterogeneously processed, and the program to be heterogeneous includes but is not limited to an application program, a system program, etc. The mnemonic can be a symbol that is easy for the user to remember and can describe the instruction function and the instruction operand. In some embodiments of the invention, the mnemonic can be an English word or an abbreviation that indicates the instruction function. The operation code can be an instruction or field specified in a computer program to perform an operation. The operation code can be a part of a computer instruction and can be used to convey specific operation requirements.
[0038] In an embodiment of the present invention, the application needs to call the instruction set of the virtual machine to implement the business function. Each instruction in the instruction set can be composed of an opcode and an operand. The mnemonic is equivalent to an alias of the opcode, which is used by programmers to facilitate the use of the opcode when programming. After the application bytecode file is decompiled, the user sees the mnemonic, not the opcode, to help the user understand the application instructions. In order to perform heterogeneous processing on the heterogeneous program, a first correspondence between the mnemonics and the opcodes in the heterogeneous program can be randomly generated, so that the external insertion program cannot call the first correspondence to achieve correct operation. Specifically, the mnemonics and opcodes used by the heterogeneous program can be obtained. The mnemonics and opcodes can be determined by the virtual machine running the heterogeneous program. The mnemonics and opcodes can be pre-configured for the type of the heterogeneous program. When the heterogeneous program needs to be processed, the mnemonics and opcodes can be obtained, and the first correspondence between the mnemonics and the opcodes is randomly generated by the preset random mapping rules. It can be understood that the first correspondence between the mnemonics and the opcodes is a one-to-one mapping, and a mnemonic has its unique corresponding opcode.
[0039] Step 120: Adjust the original correspondence between the original mnemonics and the original operation codes in the program to be heterogeneous according to the first correspondence to obtain the isomerized program to be heterogeneous.
[0040] Among them, the original correspondence between the original mnemonics and the original opcodes can be the correspondence between the mnemonics and opcodes used in different method calls in the program to be heterogeneous. The original correspondence between the original mnemonics and the original opcodes can be included in the bytecode file of the program to be heterogeneous. The original correspondence can be the code class attribute information of the program to be heterogeneous.
[0041] In an embodiment of the present invention, the heterogeneous program can be parsed to obtain a corresponding bytecode file, the original correspondence between the original mnemonics and the original operation codes can be extracted from the corresponding bytecode file, and the original correspondence used in the heterogeneous program can be adjusted according to the first correspondence randomly generated in the aforementioned steps, so that the heterogeneous program uses the first correspondence when implementing the business function. The adjustment of the heterogeneous program may include overwriting the original correspondence with the first correspondence, or modifying the original correspondence to the first correspondence.
[0042] Step 130: Generate a customized virtual machine for running the program to be heterogeneous according to the first corresponding relationship, wherein the customized virtual machine is used to run the heterogeneous program to be heterogeneous.
[0043] Among them, the customized virtual machine can be a virtual machine that can utilize the corresponding relationship, and can run the heterogeneous program to be heterogeneous through the corresponding relationship. The type of the customized virtual machine can be the same as the general virtual machine that runs the program to be heterogeneous. For example, the program to be heterogeneous is a JAVA program, which runs on a JAVA virtual machine. Then the corresponding customized virtual machine can be a JAVA virtual machine that can use the above-mentioned randomly generated mnemonics and operation codes. Compared with the JAVA virtual machine, the customized virtual machine adds the processing logic of using the above-mentioned corresponding relationship.
[0044] In an embodiment of the present invention, a virtual machine running a program to be heterogeneous can be obtained, and the processing logic of the virtual machine can be updated by determining the first correspondence between the operation code and the mnemonic. For example, the header file is updated to identify the first correspondence between the operation code and the mnemonic. The adjusted and updated virtual machine can be used as a customized virtual machine, so that the customized virtual machine can run the heterogeneous program to be heterogeneous.
[0045] In an embodiment of the present invention, a correspondence between mnemonics and operation codes of a program to be heterogeneous is generated by preset random mapping rules, an original correspondence between original mnemonics and operation codes in the program to be heterogeneous is adjusted based on a first correspondence between mnemonics and operation codes to obtain a heterogeneous program to be heterogeneous, and a customized virtual machine of the program to be heterogeneous is generated according to the first correspondence between mnemonics and operation codes, thereby realizing the heterogeneity of the code program. By randomly adjusting the first correspondence between mnemonics and operation codes used in the program code, the threat of external malicious insertion code to the program code can be prevented, and the security of the program source code can be guaranteed. At the same time, the update of the correspondence between mnemonics and operation codes in the source code can reduce the probability of successful decompilation of the application program, further improving the security of the program.
[0046] In some embodiments of the invention, it also includes: obtaining the program to be heterogeneous after the original corresponding relationship is adjusted, and packaging the program to be heterogeneous into an application package.
[0047] In an embodiment of the present invention, after the original corresponding relationship of the program to be heterogeneous is adjusted, the mapping relationship between the original mnemonics and the original operation codes in the program to be heterogeneous is changed, and the program to be heterogeneous can be repackaged, and the file generated by packaging the program to be heterogeneous can be used as an application package, which can be used to install the heterogeneous program to be heterogeneous. Exemplarily, for a JAVA type program to be heterogeneous that has been heterogeneous, the jar command can be called to package the JAVA application, thereby generating a heterogeneous JAVA application package.
[0048] In some other embodiments of the invention, it also includes:
[0049] Obtain a virtual machine deployment installation package of the customized virtual machine, and deploy the virtual machine deployment installation package in a preset environment to install the customized virtual machine; start and run the heterogeneous program in the customized virtual machine.
[0050] In an embodiment of the present invention, a customized virtual machine deployment installation package can be obtained, and the virtual machine deployment installation package can be installed in a preset environment, thereby implementing the deployment of a customized virtual machine, and the customized virtual machine can run the heterogeneous program to be heterogeneous, that is, the program to be heterogeneous after the original corresponding relationship is adjusted. For example, the customized virtual machine can obtain the application package of the program to be heterogeneous, and load the application package into the customized virtual machine, and the customized virtual machine runs the program to be heterogeneous through its own resources.
[0051] Embodiment 2
[0052] Figure 2 is a flowchart of another method for automatic isomerization of an application according to the second embodiment of the present invention. The embodiment of the present invention is a specific embodiment of the above-mentioned invention embodiment, and describes in detail the generation process of the correspondence between mnemonics and operation codes. Figure 2 The method provided in the embodiment of the present invention specifically includes the following steps:
[0053] Step 210: determine a general virtual machine that runs the program to be heterogeneous, and construct a preset mnemonic list and a preset operation code list according to the general mnemonics and general operation codes included in the general virtual machine.
[0054] Among them, the general virtual machine can be a virtual machine that runs the program to be heterogeneous, and the general virtual machine can be a publicly known virtual machine. For example, the general virtual machine can include a JAVA virtual machine, an Android virtual machine, etc. The general mnemonics and general operation codes can be all mnemonics and operation codes used in the general virtual machine. The preset mnemonic list can store general mnemonics, and the preset operation code list can store general operation codes. In some embodiments, the preset mnemonic list and the preset operation code list can exist in the form of an original mapping table of the general virtual machine, and the preset mnemonic list and the preset operation code list can be located in the original mapping table of the general virtual machine.
[0055] In an embodiment of the present invention, the program type of the program to be heterogeneous can be determined. For example, the program type of the program to be heterogeneous can be determined by the development language or application scenario, and a general virtual machine corresponding to the program type can be found. The general mnemonics and general operation codes in the general virtual machine can be counted, and the general mnemonics and general operation codes can be stored in a preset mnemonic list and a preset operation code list, respectively. It can be understood that the preset mnemonic list and the preset operation code list can exist in the form of configuration files.
[0056] Step 220: configure a position correspondence between mnemonic positions in the preset mnemonic list and opcode positions in the preset opcode list.
[0057] The mnemonic position may be the sequential position of different general mnemonics in the preset mnemonic list, and correspondingly, the opcode position may be the sequential position of different general opcodes in the preset opcode category. The position correspondence may be a correspondence set, and each correspondence in the position correspondence may be a correspondence between a mnemonic position in the preset mnemonic list and an opcode position in the preset opcode list.
[0058] In an embodiment of the present invention, each mnemonic position in a preset mnemonic list may be mapped to an opcode position in a preset opcode list, respectively, and the mapping relationship between these mnemonic positions and opcode positions may be used as a position correspondence relationship. It can be understood that the configured position correspondence relationship may include a logical correspondence or a physical correspondence. For example, the position correspondence relationship may include that the first position in the preset opcode list may correspond to the first position in the preset mnemonic list. The position correspondence relationship may be generated by a prior agreement without recording information, or the original correspondence relationship may include that the opcode position with a first identifier in the preset opcode list corresponds to the mnemonic position with a first identifier in the preset mnemonic list. The preset mnemonic list and the first identifier in the preset opcode list may be considered as a configured position correspondence relationship.
[0059] Furthermore, in some embodiments, the correspondence between universal mnemonics and universal opcodes in a universal virtual machine may not need to be pre-configured, and the original mapping relationship table in the universal virtual machine may be directly used, with the correspondence between the positions of universal mnemonics and universal opcodes in the original mapping relationship table being used as the position correspondence.
[0060] Step 230: Obtain the user's random configuration instruction, and search the preset random mapping rule corresponding to the random configuration instruction in the preset rule set.
[0061] The configuration randomization instruction may be a control instruction for a user to select a preset random mapping rule, and the configuration randomization instruction may be input by the user in real time or pre-configured as required.
[0062] In an embodiment of the present invention, a user can input configuration random instructions in real time according to business needs or pre-set configuration random instructions according to business needs, and can search for corresponding preset random mapping rules in a preset rule set according to the configuration random instructions. The preset random mapping rules can be used to generate a correspondence between mnemonics and operation codes.
[0063] Step 240: Generate a first correspondence between mnemonics in the preset mnemonic list and operation codes in the preset operation code list according to a preset random mapping rule.
[0064] In an embodiment of the present invention, a preset random mapping rule can be called to map the mnemonics in a preset mnemonic list to the opcodes in a preset opcode list, respectively, so as to generate a new correspondence between the mnemonics and the opcodes according to the preset random mapping rule. It can be understood that the preset random mapping rule may include at least one of a method for adjusting the correspondence between the mnemonic position in the preset mnemonic list and the opcode position in the preset opcode list, a preset random mapping rule can be used to adjust the mnemonic position of the mnemonics in the preset mnemonic list, and a preset random mapping rule can be used to adjust the opcode position of the opcode in the preset opcode list.
[0065] Exemplarily, the preset random mapping rule may include a rule for adjusting the correspondence between the mnemonic position in the preset mnemonic list and the opcode position in the preset opcode list. For example, the preset mnemonic list and the preset opcode list belong to different parts of the same mapping relationship table. Figure 3, the correspondence between mnemonics and opcodes at different positions in the mapping relationship table can be adjusted by a preset random mapping rule. Before the adjustment, the correspondence between the mnemonics in the preset mnemonic list and the opcodes in the preset opcode list may include mnemonics ADD corresponding to opcode 0X00, mnemonics MOV corresponding to opcode 0X10, and mnemonics POP corresponding to opcode 0X11. The correspondence between the mnemonics and opcodes is adjusted by the preset random mapping rule. After the adjustment, the correspondence between the mnemonics in the preset mnemonic list and the opcodes in the preset opcode list may include mnemonics ADD corresponding to opcode 0X10, mnemonics MOV corresponding to opcode 0X11, and mnemonics POP corresponding to opcode 0X00. In this exemplary embodiment, the preset random mapping rule may be to adjust the correspondence between the mnemonic position and the opcode position, without adjusting the position of each mnemonic or opcode.
[0066] For another example, the preset random mapping rule may include a rule for adjusting the mnemonic position of the mnemonics in the preset mnemonic list, see Figure 4 , the preset mnemonic list and the preset opcode list can be associated through the position correspondence between the mnemonic position in the preset mnemonic list and the opcode position in the preset opcode list, and the positions of some or all mnemonics in the preset mnemonic list can be adjusted according to the preset random mapping rule. Since the mnemonic position in the preset mnemonic list and the opcode position in the preset opcode list are bound through the position correspondence, after the position of the mnemonic in the mnemonic list changes, the mnemonics in the preset mnemonic list and the opcodes in the preset opcode list can generate a new correspondence, see Figure 4 , the mnemonic positions of the mnemonics in the preset mnemonic list can be adjusted by a preset random mapping rule. Before the adjustment, the correspondence between the mnemonics in the preset mnemonic list and the opcodes in the preset opcode list may include the mnemonic ADD corresponding to the opcode 0X10, the mnemonic MOV corresponding to the opcode 0X00, and the mnemonic POP corresponding to the opcode 0X11. The positions of the mnemonics in the list are adjusted by the preset random mapping rule. After the adjustment, the correspondence between the mnemonics in the preset mnemonic list and the opcodes in the preset opcode list may include the mnemonic POP corresponding to the opcode 0X10, the mnemonic ADD corresponding to the opcode 0X00, and the mnemonic MOV corresponding to the opcode 0X11.
[0067] For another example, the preset random mapping rule may include a rule for adjusting the opcode position of the opcode in the preset opcode list. For example, the preset opcode list and the preset mnemonic list belong to different parts of the same mapping relationship table. The position of the opcode in the mapping relationship table can be adjusted according to the preset random mapping rule. The mnemonics in the mapping relationship table will be mapped to the adjusted opcodes, thereby generating a new correspondence between the mnemonics and the opcodes. See Figure 5 , the opcode position of the opcode in the preset opcode list can be adjusted by a preset random mapping rule. Before the adjustment, the correspondence between the mnemonics in the preset mnemonic list and the opcodes in the preset opcode list may include the mnemonic ADD corresponding to the opcode 0X00, the mnemonic MOV corresponding to the opcode 0X10, and the mnemonic POP corresponding to the opcode 0X11. The position of the opcode in the list is adjusted by the preset random mapping rule. After the adjustment, the correspondence between the mnemonics in the preset mnemonic list and the opcodes in the preset opcode list may include the mnemonic ADD corresponding to the opcode 0X10, the mnemonic MOV corresponding to the opcode 0X11, and the mnemonic POP corresponding to the opcode 0X00.
[0068] It is understandable that the above-mentioned adjustment method of the corresponding relationship is only an example and is not limited. In some embodiments, the preset random mapping relationship can adjust the positions of the mnemonics and the operation codes in the corresponding list at the same time, so as to generate a new corresponding relationship between the mnemonics and the operation codes. Further, in some embodiments, the preset random mapping relationship can only adjust the positions of some mnemonics in the preset mnemonic list, or adjust the positions of some operation codes in the preset operation code list, or adjust some of the position correspondences in all the position correspondences of the preset mnemonic list and the preset operation code list, and the range of the adjusted part can be pre-configured or determined according to user input.
[0069] Step 250: Adjust the original correspondence between the original mnemonics and the original operation codes in the program to be heterogeneous according to the first correspondence to obtain the isomerized program to be heterogeneous.
[0070] Step 260: Generate a customized virtual machine for running the program to be heterogeneous according to the first corresponding relationship, wherein the customized virtual machine is used to run the program to be heterogeneous after being heterogeneous.
[0071] According to an embodiment of the present invention, a general virtual machine for running a program to be heterogeneous is obtained, a preset mnemonic list and a preset opcode list are generated according to the general mnemonics and general opcodes included in the general virtual machine, a position correspondence between a mnemonic position in the preset mnemonic list and an opcode position in the preset opcode list is configured, a corresponding preset random mapping rule is determined in a preset rule set according to a user's configured random instruction, a correspondence between a mnemonic in the preset mnemonic list and an opcode in the preset opcode list is generated according to the preset random mapping rule, a customized virtual machine is generated based on the correspondence, and an original correspondence between an original mnemonic and an original opcode in the program to be heterogeneous is adjusted. According to an embodiment of the present invention, automatic heterogeneity of an application is achieved by randomly adjusting the correspondence between a mnemonic and an opcode in a program code, thereby reducing the probability of successful decompilation of the application, thereby improving the security of the source code of the application, and the automatic heterogeneity process of the application does not modify the business function, thereby ensuring the stability of the application.
[0072] Based on the above-mentioned embodiment of the invention, a first correspondence between a mnemonic and an operation code is generated according to a preset random mapping rule, including:
[0073] Determine a first random rule corresponding to a preset mnemonic list within a preset random mapping rule and determine a second random rule corresponding to a preset opcode list; call the first random rule to randomly shuffle the positions of different mnemonics in the preset mnemonic list and call the second random rule to randomly shuffle the positions of different opcodes in the preset opcode list; determine a target opcode at the opcode position and a target mnemonic at the mnemonic position according to the position correspondence, and use the target correspondence between the target opcode and the target mnemonic as the first correspondence.
[0074] Among them, the first random rule can be an algorithm rule for randomly adjusting the mnemonic position of the mnemonics in the preset mnemonic list within the selected preset random mapping rule, and the second random rule can be an algorithm rule for randomly adjusting the opcode position of the opcode in the preset opcode list within the selected preset random mapping rule. In some embodiments, the first random rule can be the same as the second random rule.
[0075] In the implementation of the present invention, the preset random mapping rule may include a first random rule and a second random rule. The first random rule may be called to randomly shuffle all mnemonics in the preset mnemonic list, so that the order formed by the mnemonic positions of all mnemonics is different from the order formed by the mnemonic positions previously located. Similarly, the second random rule may be called to randomly shuffle the opcodes in the preset opcode list. The opcode positions of the opcodes in the preset opcode list are arranged. Since the original corresponding relationship configured is the corresponding relationship between the mnemonic position and the opcode position, each mnemonic is updated respectively by the first random rule and the second random rule. The mnemonics at the mnemonic positions and the opcodes at each opcode position can determine a set of corresponding opcode positions and mnemonic positions through a pre-configured position correspondence relationship. The position correspondence relationship can be a custom correspondence relationship between opcode positions and mnemonic positions, or a correspondence relationship between opcode positions and mnemonic positions in an original mapping relationship table in a heterogeneous program or virtual machine. The correspondence between the target opcodes at the group of opcode positions and the target mnemonics at the mnemonic positions can be used as a newly generated target correspondence relationship, which is also the first correspondence relationship generated according to a preset random mapping rule.
[0076] Exemplarily, the preset opcode list may include 3 opcodes, which are respectively located at opcode position 1, opcode position 2 and opcode position 3 of the preset opcode list, and the preset mnemonic list may include 3 mnemonics, which are respectively located at mnemonic position 1, mnemonic position 2 and mnemonic position 3 of the preset mnemonic list. The position correspondence between the preset opcode list and the preset mnemonic list may include opcode position 1 corresponding to mnemonic position 1, opcode position 2 corresponding to mnemonic position 2 and opcode position 3 corresponding to mnemonic position 3. After the positions of the preset mnemonic list and the preset opcode list are shuffled according to the first random rule and the second random rule of the preset random mapping rule, the position correspondence between the preset opcode list and the preset mnemonic list may be updated to opcode position 3 corresponding to mnemonic position 1, opcode position 2 corresponding to mnemonic position 2 and opcode position 1 corresponding to mnemonic position 3.
[0077] It can be understood that, in some other embodiments, the preset random mapping rule may include only the first random rule or the second random rule, and the positions of the mnemonics in the preset mnemonic list or the opcodes in the preset opcode list may be randomly shuffled only by the first random rule or the second random rule to generate a first correspondence between the mnemonics and the opcodes.
[0078] Based on the above-mentioned embodiments of the invention, the preset random mapping rules include at least one of the following: Fisher-Yates Shuffle algorithm rule, Knuth-Durstenfeld Shuffle algorithm rule, and reservoir sampling algorithm rule.
[0079] In an embodiment of the present invention, the preset random mapping rule for generating a first correspondence between opcodes and mnemonics may specifically be at least one of the Fisher-Yates Shuffle algorithm rule, the Knuth-Durstenfeld Shuffle algorithm rule, and the reservoir sampling algorithm rule. The above algorithm rule may be used to randomly shuffle the mnemonics in the preset mnemonic list or the opcodes in the preset opcode list to generate a new correspondence between opcodes and mnemonics.
[0080] Based on the above-mentioned embodiments of the invention, it also includes: extracting an order-reserved list of configured random instructions, and reserving the mnemonic positions of the reserved mnemonics and / or the opcode positions of the reserved opcodes in the order-reserved list before the first random rule or the second random rule is randomly shuffled.
[0081] The sequence reservation list may be an information list for reserving mnemonics in mnemonic positions of a preset mnemonic list and / or reserving opcodes in opcode positions of a preset opcode list. The sequence reservation list may include mnemonics and / or opcodes whose positions need to be reserved. The sequence reservation list may also include only mnemonics or only opcodes. When a mnemonic or opcode appears in the sequence reservation list, the position of the mnemonics in the preset mnemonic list and the position of the opcode corresponding to the mnemonic in the preset opcode list may be reserved, or the position of the opcode in the preset opcode list and the position of the mnemonics corresponding to the opcode in the preset mnemonic list may be reserved. The reserved mnemonics may be mnemonics that reserve mnemonic positions in the sequence reservation list, and the reserved opcodes may be opcodes that reserve opcode positions in the sequence reservation list. The sequence reservation list may be indicated by configuring random instructions, and the sequence reservation list may also be pre-configured by the user.
[0082] In an embodiment of the present invention, the configuration random instruction may further include a sequence reservation list, which may be used to reserve the mnemonic position of the mnemonic and / or the opcode position of the reserved opcode, and the sequence reservation list in the configuration random instruction may be extracted, and before the preset mnemonic list is randomly shuffled according to the first random rule and / or the preset opcode list is randomly shuffled according to the second random rule, the mnemonic position of the reserved mnemonics and / or the opcode position of the reserved opcode in the sequence reservation list may be reserved, and the reserved mnemonics and / or reserved opcodes in the sequence reservation list do not participate in the random shuffling process. It is understandable that in some embodiments, the sequence reservation list may not be configured through the configuration random instruction, and the sequence reservation list may be input by the user in the form of a configuration file or input information, and the input process of the sequence reservation list may be independent of the input process of the configuration random instruction.
[0083] Embodiment 3
[0084] Figure 6 is a flowchart of another method for automatic isomerization of an application program provided according to Embodiment 3 of the present invention. The embodiment of the present invention is a specific embodiment of the above-mentioned invention embodiment, and the process of generating a customized virtual machine is introduced in detail. Figure 6 The method provided in the embodiment of the present invention specifically includes the following steps:
[0085] Step 310: Generate a first correspondence between a mnemonic and an operation code corresponding to the heterogeneous program according to a preset random mapping rule.
[0086] Step 320: Obtain a general virtual machine that runs the program to be heterogeneous, and extract a header file from the source code of the general virtual machine, wherein the header file at least includes an original correspondence between general mnemonics and general operation codes.
[0087] The general virtual machine may be a virtual machine running a program to be heterogeneously processed, and the general virtual machine may be a virtual machine running an application that has not been heterogeneously processed. The general virtual machine may include a JAVA virtual machine, an Android virtual machine, etc. The header file may be a file in the general virtual machine used to store information related to the running source code, including function functions, data interface declarations, class methods, class attributes, etc. The source code may include classes or methods implemented by the general virtual machine, and the processing logic of the source code is used to implement the business functions of the general virtual machine.
[0088] In the embodiment of the present invention, a universal virtual machine running a program to be heterogeneous can be determined, the universal virtual machine can be parsed, and a header file including an original correspondence between universal mnemonics and universal operation codes can be extracted from a project file of the universal virtual machine.
[0089] Step 330: Replace the original corresponding relationship in the header file with the first corresponding relationship.
[0090] Specifically, the original corresponding relationship of the header file may be deleted, and the first corresponding relationship generated in the above step may be written into the file position where the original corresponding relationship is located in the header file.
[0091] Step 340: recompile the source code of the general virtual machine and package it into a virtual machine deployment installation package of the customized virtual machine.
[0092] In an embodiment of the present invention, the source code of the general virtual machine can be recompiled after the header file is modified, and the files generated after the compilation are packaged as a virtual machine deployment installation package of the customized virtual machine. Exemplarily, taking a JAVA virtual machine as an example, the source code file of the JAVA virtual machine can be obtained, the original corresponding relationship in the header file of the source code file is replaced with the corresponding relationship determined in the above steps, and the compilation tools such as Make and GCC can be called to compile the source code file, and the files generated by the compilation are packaged as a virtual machine deployment installation package, which can be a virtual machine deployment installation package for the customized virtual machine.
[0093] Step 350: Adjust the original correspondence between the original mnemonics and the original operation codes in the program to be heterogeneous according to the first correspondence to obtain the isomerized program to be heterogeneous.
[0094] The embodiment of the present invention generates a first correspondence between the mnemonics and the operation codes of the program to be heterogeneous by calling a preset random mapping rule, obtains a general virtual machine that runs the program to be heterogeneous, extracts a header file in the source code of the general virtual machine, replaces the original correspondence in the header file with the first correspondence, recompiles the source code of the general virtual machine, and packages the compiled source code into a virtual machine deployment installation package of the customized virtual machine, and adjusts the original correspondence between the original mnemonics and the original operation codes in the program to be heterogeneous according to the correspondence, thereby obtaining a heterogeneous program to be heterogeneous. The embodiment of the present invention realizes automatic heterogeneity of an application program by randomly adjusting the correspondence between the mnemonics and the operation codes in the program code, reduces the probability of successful decompilation of the application program, and can improve the security of the source code function of the application program. The automatic heterogeneity process of the application program does not modify the business function, and can ensure the stability of the application program.
[0095] Further, based on the above-mentioned embodiment of the invention, replacing the original correspondence in the header file with the first correspondence includes:
[0096] Extracting a first mapping relationship table of a first corresponding relationship; determining a storage location of a second mapping relationship table of an original corresponding relationship in a header file; inserting the first mapping relationship table into the storage location of the header file to cover the second mapping relationship table.
[0097] The first mapping relationship table may be an information table storing the first correspondence between mnemonics and operation codes generated in the aforementioned step, and the second mapping relationship table may be an information table storing the correspondence between mnemonics and operation codes of the program to be heterogeneously constructed in the header file.
[0098] In an embodiment of the present invention, a first mapping relationship table including a corresponding relationship can be extracted, and the storage location of the second mapping relationship table can be searched in the header file. The first mapping relationship table can be stored in the header file according to the storage location so that the first mapping relationship table covers and replaces the second mapping relationship table, thereby replacing the original corresponding relationship in the header file with the corresponding relationship. Further, the method of replacing the original corresponding relationship in the header file with the first corresponding relationship can also include modifying the second mapping relationship table according to the first mapping relationship table, and modifying the table items and the table item corresponding relationship in the second mapping relationship to the table items and the table item corresponding relationship in the first mapping relationship table.
[0099] In other embodiments of the invention, the original correspondence of the header file may exist in the form of a preset operation code table, a preset mnemonic table and a position correspondence. The preset operation code table, the preset mnemonic table and the position correspondence of the header file may exist in the form of a configuration file. Replacing the original correspondence in the header file with the correspondence in the source code may include modifying or overwriting the position of the operation code in the preset operation code list in the header file according to the correspondence, or modifying or overwriting the position of the mnemonic in the preset mnemonic list in the header file according to the correspondence, or modifying or overwriting the position correspondence of the header file according to the correspondence, etc.
[0100] Embodiment 4
[0101] Figure 7 is a flow chart of another automatic isomerization method for an application program according to a fourth embodiment of the present invention. The present embodiment of the present invention is a specific embodiment of the present invention, and describes in detail the adjustment process of the original corresponding relationship in the isomerized program. Figure 7 The method provided in the embodiment of the present invention specifically includes the following steps:
[0102] Step 410: Generate a first correspondence between a mnemonic and an operation code corresponding to the heterogeneous program according to a preset random mapping rule.
[0103] Step 420: Generate a customized virtual machine for running the program to be heterogeneous according to the first corresponding relationship, wherein the customized virtual machine is used to run the program to be heterogeneous after being heterogeneous.
[0104] Step 430: extract the method table of the program to be heterogeneous, and extract the bytecode array according to the method table.
[0105] Among them, the method table can be a bytecode instruction stored in the compiled program to be heterogeneous, and the bytecode instruction can be used as an opcode. The method table can be located in the bytecode file of the program to be heterogeneous. The method table can be generated by parsing the bytecode file of the program to be heterogeneous, and the bytecode array can be an array storing opcodes in the method table.
[0106] In the embodiment of the present invention, a method table may be extracted from the program to be heterogeneous, and a bytecode array in the method table may be parsed to obtain operation codes used by the program to be heterogeneous.
[0107] Step 440: Determine the opcode position of the original opcode in the program to be heterogeneous and the original mnemonic corresponding to the original opcode according to the bytecode array.
[0108] In an embodiment of the present invention, for each opcode in the bytecode array as the original opcode, the opcode position of the original opcode in the program to be heterogeneous can be determined, and the original mnemonic corresponding to the original opcode can be determined. It can be understood that the correspondence between the original opcode and the original mnemonic can be determined by a pre-configured original correspondence, that is, the corresponding original mnemonic is determined within the original correspondence through the original opcode.
[0109] Step 450: Determine the target operation code corresponding to the original mnemonic within the first corresponding relationship.
[0110] In the embodiment of the present invention, the operation code corresponding to the original mnemonic can be found in the first correspondence, and the operation code can be used as the target operation code. Exemplarily, taking the first correspondence through the mapping relationship table as an example, the original mnemonic can be found in the mapping relationship table, and the operation code stored in the mapping relationship table in association with the original mnemonic is used as the target operation code.
[0111] Step 460: Overwrite the original opcode with the target opcode according to the opcode position in the program to be heterogeneous to adjust the original corresponding relationship.
[0112] In the embodiment of the present invention, the target operation code can be written into the operation code position in the program to be heterogeneous, so that the target operation code covers the original operation code, thereby adjusting the original corresponding relationship in the program to be heterogeneous to a corresponding relationship.
[0113] According to an embodiment of the present invention, a first correspondence between a mnemonic and an operation code of a program to be heterogeneous is generated by a preset random mapping rule, a customized virtual machine of the program to be heterogeneous is generated according to the first correspondence between the mnemonic and the operation code, a method table of the program to be heterogeneous is extracted, and a bytecode array is obtained in the method table, the operation code position of the original operation code in the bytecode array in the program to be heterogeneous is determined, and the original mnemonic corresponding to the original operation code is determined, the target operation code corresponding to the original mnemonic is determined in the first correspondence, and the original operation code is overwritten with the target operation code according to the operation code position in the program to be heterogeneous, thereby realizing the heterogeneity of the code program, and by randomly adjusting the correspondence between the mnemonics and the operation codes used in the program code, the threat of external malicious insertion code to the program code can be prevented, and the security of the program source code can be guaranteed. At the same time, the update of the correspondence between the mnemonics and the operation codes in the source code can reduce the probability of successful decompilation of the application program, and further improve the security of the program.
[0114] In some embodiments of the invention, extracting a method table of the program to be heterogeneous, and extracting a bytecode array according to the method table includes:
[0115] Unpack the program to be heterogeneous and extract the target bytecode file of the program to be heterogeneous; determine the virtual machine structure specification of the program to be heterogeneous, and extract the method table in the target bytecode file according to the virtual structure specification; extract the code attribute of the code class in the method table; determine that the code attribute is the method code attribute of the method, and extract the bytecode array in the method code attribute.
[0116] The virtual machine structure specification may be a specification for the data result of a program when the virtual machine runs the program, and the virtual machine structure specification may include at least one data structure requirement.
[0117] In an embodiment of the present invention, the heterogeneous program to be treated can be unpacked to obtain various source code files of the heterogeneous program to be treated, the target bytecode file can be mentioned in each source code file, the target bytecode file can be parsed according to the virtual machine structure specification of the heterogeneous program to be treated, the method table can be extracted from the target bytecode file according to the method table field specified in the virtual machine structure specification, and the code attributes in the method table can be parsed, and the method code attribute belonging to the method is determined for each code attribute, and the bytecode array is extracted from the method code attribute belonging to the method, and the bytecode array can be the operation code constituting the method.
[0118] In some inventive embodiments, determining the target opcode corresponding to the original mnemonic within the first correspondence relationship includes:
[0119] Read a first mapping table of a first corresponding relationship; search the first mapping table for a mnemonic with the same characters as the original mnemonic; and use the operation code corresponding to the mnemonic in the first mapping table as the target operation code.
[0120] The first mapping table may be a mapping relationship table storing the correspondence between operation codes and mnemonics.
[0121] In the embodiment of the present invention, a mnemonic with the same characters as the original mnemonic may be searched in the first mapping table, and an operation code in the first mapping table that has a mapping relationship with the mnemonic may be used as a target operation code.
[0122] In some other embodiments of the invention, overwriting the original opcode with the target opcode according to the opcode position in the program to be heterogeneous includes:
[0123] The target bytecode file of the program to be heterogeneous is searched for a file position corresponding to the opcode position; and the original opcode at the file position is modified to the target opcode.
[0124] The file position may be the file position coordinates of the operation code position, and the file position may reflect the space occupied by the original operation code in the target bytecode file.
[0125] In an embodiment of the present invention, the file location indicated by the opcode location can be searched in the target bytecode file of the program to be heterogeneous, and the target opcode can be written to the file location of the target bytecode file, so that the target opcode replaces the original opcode.
[0126] Embodiment 5
[0127] Taking the isomerization process of JAVA application as an example, the process requires a JAVA application package in JAR format and an open source JAVA virtual machine source code to run the JAVA application. In the isomerization process of JAVA application, users can control the generation method of the mapping relationship between mnemonics and operation codes through configuration files. The automatic isomerization process of the application may include the following steps:
[0128] 1. Read the original mapping table between mnemonics and opcodes, and generate a mnemonic list and an opcode list.
[0129] 2. Read the configuration file, select at least one shuffling algorithm from the configured shuffling algorithms according to the configuration file, randomly shuffle the mnemonic list and the opcode list based on the selected shuffling algorithm, and then correspond the contents in the same position of the mnemonic list and the opcode list item by item, thereby generating a new randomized mnemonic-opcode mapping relationship table. In some embodiments, the configuration file set by the user retains the original order of the mnemonic list, then the mnemonics and the corresponding opcodes in this part do not participate in the random shuffling process of the shuffling algorithm, and their positions in the mnemonic list and the opcode list can be kept unchanged.
[0130] 3. Extract the header file storing the correspondence between mnemonics and opcodes from the JAVA virtual machine source code, find the opcode corresponding to the mnemonic in the newly generated randomized mapping table, and replace the original opcode in the header file according to the opcode.
[0131] 4. Call make, gcc and other compilation tools to compile the new JAVA virtual machine source code, compile the source code to generate JAVA virtual machine files and package them to generate a customized JAVA virtual machine installation and deployment package.
[0132] 5. Call the unzip tool to unpack the JAVA application in JAR format and recursively extract all the bytecode files in Class format in the package.
[0133] 6. Parse each bytecode file according to the JVM structure specification and extract the method table. Parse the attribute table in each method table, and parse the Code array of the Code class attribute in the attribute table, that is, the bytecode array of the method. The bytecode array can be parsed to find the position of the opcode in each bytecode in the bytecode file and the mnemonic corresponding to the opcode.
[0134] 7. Traverse the obtained Code array, determine the address of the bytecode's opcode and the mnemonic corresponding to the opcode, use the mnemonic to find the new opcode in the new randomized mnemonic-opcode mapping table, and replace the original opcode at the address with the new opcode.
[0135] 8. Call the JAR command tool to package the JAVA application and generate a heterogeneous JAVA application package, which can be in a JAR format.
[0136] In the embodiment of the present invention, the automatic isomerization method of an application program can be implemented by an automatic isomerization system of an application program. Figure 8 The application automatic heterogeneity system may include a random instruction mapping relationship generation module, a customized JAVA virtual machine generation module and a JAVA application heterogeneity module.
[0137] In the embodiment of the present invention, the random instruction mapping relationship generation module is mainly responsible for generating a randomized mapping relationship table between mnemonics and operation codes in JAVA bytecodes according to the random instruction generation rules configured by the user. The random instruction mapping relationship generation module is internally divided into a parameter configuration module and a randomized mapping rule generation module.
[0138] The parameter configuration module provides configuration options through configuration files. The parameter configuration module allows users to configure the generation rules of mapping relationships. The configurable generation rules of mapping relationships include shuffle algorithms and mnemonic lists that retain the original order. The optional shuffle algorithms include Fisher-Yates Shuffle algorithm, Knuth-Durstenfeld Shuffle algorithm, and reservoir sampling algorithm. The parameter configuration module reads the contents of the configuration file for use by the mapping relationship generation module.
[0139] The mapping relationship generation module generates a mnemonic list and an opcode list according to the correspondence between mnemonics and opcodes in the original JAVA virtual machine. The mapping relationship generation module uses the shuffling algorithm of the parameter configuration module to randomly shuffle the mnemonic list and the opcode list, and then matches the contents in the same position in the mnemonic list and the opcode list item by item to generate a new randomized mnemonic-opcode mapping relationship table. If the user configures a mnemonic list that retains the original order, this part of the mnemonics and the corresponding original opcodes will not participate in the random shuffling process of the shuffling algorithm.
[0140] In the embodiment of the present invention, the customized JAVA virtual machine generation module is mainly responsible for generating a customized JAVA virtual machine according to the mapping relationship table between mnemonics and operation codes generated by the mapping relationship generation module. The customized JAVA virtual machine generation module is internally divided into a header file rule replacement module and a virtual machine source code compilation and packaging module.
[0141] The header file mapping relationship replacement module is responsible for extracting the header file storing the correspondence between mnemonics and opcodes from the JAVA virtual machine source code, and using the randomized mapping relationship table generated by the mapping relationship generation module to replace the correspondence between mnemonics and opcodes in the header file to generate a new header file.
[0142] The virtual machine source code compilation and packaging module is responsible for calling compilation tools such as make and gcc to compile the new JAVA virtual machine source code, and packaging the JAVA virtual machine files generated by the source code compilation to generate a customized JAVA virtual machine installation and deployment package.
[0143] In the embodiment of the present invention, the JAVA application isomerization module is responsible for replacing the operation code in the class file of the JAVA application according to the randomized mapping relationship table generated by the mapping relationship generation module, thereby generating a heterogeneous JAVA application. The JAVA application isomerization module is internally divided into a Jar file unpacking module, a class file parsing module, an operation code replacement module and a Jar packaging module.
[0144] The Jar file unpacking module is responsible for calling the unzip tool to unpack the JAVA application in .jar format and recursively extract all .class format bytecode files in the package.
[0145] The class file parsing module is responsible for parsing the class bytecode file according to the JVM structure specification, parsing out the magic number (magic), version number, constant pool (constant_pool), access identifier, current class index (this_class), parent class index (super_class), interface index (interfaces), field table (fields), method table (methods), additional attributes (attributes) and other components. The attribute table (attributes) of each method is parsed in the method table, and the attributes of the Code category are parsed in the attribute table. The code array in the Code attribute is the bytecode array of the method, and the position of the opcode in each bytecode in the class file and the mnemonic corresponding to the opcode are parsed.
[0146] The bytecode replacement module traverses each method in the method table according to the results of the analysis by the class file analysis module, finds the Code class attribute in the method's attribute table, traverses the bytecode array of the Code class attribute, obtains the bytecode operation code address and the corresponding mnemonic, uses the mnemonic to find the new operation code in the mapping relationship table generated by the mapping relationship generation module, replaces the original operation code at the operation code address, and obtains the heterogeneous class file.
[0147] The Jar packaging module is responsible for calling the jar command tool to repackage the JAVA application and generate a heterogeneous .jar format JAVA application package.
[0148] Based on the above system, the implementation process of the automatic isomerization method of application provided by the embodiment of the present invention may include:
[0149] 1. There is a JAVA application in jar format and an open source JAVA virtual machine source code package. Modify the configuration file in the parameter configuration module, set relevant parameters, start the random instruction mapping relationship generation module, and generate a randomized mapping relationship table between mnemonics and opcodes.
[0150] 2. Start the customized virtual machine generation module, in which the header file mapping relationship replacement module will extract the header file storing the correspondence between mnemonics and opcodes in the JAVA virtual machine source code package, use the mnemonics to find the corresponding opcodes in the newly generated randomized mapping relationship table, replace the original opcodes in the header file, and generate a new header file. The virtual machine source code compilation and packaging module will compile the new JAVA virtual machine source code, and package the compiled JAVA virtual machine files to generate a customized JAVA virtual machine installation and deployment package.
[0151] 3. Start the JAVA application heterogeneous module. The Jar file unpacking module will unpack it. The class file parsing module will read and parse the class files in the unpacked file, parse out the method table, parse out the attribute table of each method, parse out the code array in the Code class attribute, which is the bytecode array of the method, and parse out the position of the opcode in each bytecode in the class file and the mnemonic corresponding to the opcode. The bytecode replacement module uses the parsed mnemonics to find the new opcode in the newly generated randomized mapping relationship table, replace the original opcode at the opcode address, and generate a new class file. The Jar packaging module repackages the unpacked JAVA application to generate a heterogeneous JAVA application.
[0152] 4. Install a customized JAVA virtual machine and start heterogeneous JAVA applications.
[0153] The embodiment of the present invention realizes the heterogeneity of JAVA application programs through the collaboration of multiple modules in the system; the mapping relationship between the bytecode opcode and the mnemonic is randomly generated and replaced, so that the heterogeneous application programs have heterogeneity at the JAVA bytecode level; after the heterogeneous JAVA application, the conventional decompilation tool uses the mapping relationship between the original bytecode opcode and the mnemonic to decompile, so it is impossible to decompile the JAVA source code, which plays a role in JAVA source code protection, which is equivalent to the role of code obfuscation. In addition, the application system composed of the heterogeneous JAVA application and the customized JAVA virtual machine makes it impossible for the native bytecode fragment injected by the attacker to run normally, improves the security of the JAVA application, achieves the effect of JAVA application level heterogeneity, and is suitable for the field of mimetic security defense. In addition, in the process of generating the heterogeneous JAVA application, the function is not modified, the generated heterogeneous application is equivalent to the original application in function, and the JAVA class path, name and method will not be modified. The interface of the generated heterogeneous application is fully compatible with the original application.
[0154] Embodiment 6
[0155] Fig. 9 is a schematic diagram of the structure of an automatic isomerization device for an application program according to Embodiment 6 of the present invention. Fig. 9 As shown, the device comprises:
[0156] The random mapping relationship generating module 510 is used to generate a first corresponding relationship between a mnemonic and an operation code corresponding to the heterogeneous program according to a preset random mapping rule.
[0157] The application isomerization module 520 is used to adjust the original correspondence between the original mnemonics and the original operation codes in the program to be isomerized according to the first correspondence to obtain the isomerized program to be isomerized.
[0158] The customized virtual machine generation module 530 is used to generate a customized virtual machine for running the program to be heterogeneous according to the first corresponding relationship.
[0159] In an embodiment of the present invention, a random mapping relationship generation module generates a first correspondence between a mnemonic and an operation code of a program to be heterogeneous according to a preset random mapping rule, a customized virtual machine generation module generates a customized virtual machine for running the heterogeneous program to be heterogeneous according to the first correspondence between the mnemonic and the operation code, and an application heterogeneity module adjusts the original correspondence between the original mnemonic and the original operation code in the program to be heterogeneous based on the first correspondence between the mnemonic and the operation code, thereby realizing the heterogeneity of the code program. By randomly adjusting the correspondence between the mnemonics and the operation code used in the program code, the threat of external malicious insertion code to the program function can be prevented, and the program function security can be guaranteed. At the same time, the update of the correspondence between the mnemonics and the operation code in the source code can reduce the probability of successful decompilation of the application program, and further improve the security of the program.
[0160] In some inventive embodiments, the random relationship module 510 includes:
[0161] The rule selection unit is used to obtain the user's configuration random instruction and search the preset random mapping rule corresponding to the configuration random instruction in the preset rule set.
[0162] A relationship generating unit is used to generate the first corresponding relationship between the mnemonics in the preset mnemonic list and the operation codes in the preset operation code list according to the preset random mapping rule.
[0163] In some embodiments of the invention, the preset random mapping rules in the device include at least one of the following: Fisher-Yates Shuffle algorithm rules, Knuth-Durstenfeld Shuffle algorithm rules, and reservoir sampling algorithm rules.
[0164] In some embodiments of the invention, the apparatus further comprises a pre-configuration module, which is used to determine a general-purpose virtual machine running the program to be heterogeneous, and to construct the preset mnemonic list and the preset opcode list respectively according to the general mnemonics and general opcodes included in the general-purpose virtual machine;
[0165] A position correspondence between mnemonic positions in the preset mnemonic list and opcode positions in the preset opcode list is configured.
[0166] In some inventive embodiments, the relationship generation unit is specifically used to: determine a first random rule corresponding to the preset mnemonic list within the preset random mapping rule and determine a second random rule corresponding to the preset opcode list; call the first random rule to randomly shuffle the positions of different mnemonics in the preset mnemonic list and call the second random rule to randomly shuffle the positions of different opcodes in the preset opcode list; determine the target opcode at the opcode position and the target mnemonic at the mnemonic position according to the position correspondence, and use the target correspondence between the target opcode and the target mnemonic as the first correspondence.
[0167] In some embodiments of the invention, the customized virtual machine generation module 530 includes:
[0168] The general virtual machine acquisition unit is used to acquire a general virtual machine that runs the program to be heterogeneous, and extract a header file from the source code of the general virtual machine, wherein the header file at least includes the original correspondence between the general mnemonics and the general operation codes.
[0169] The corresponding relationship replacing unit is used to replace the original corresponding relationship in the header file with the first corresponding relationship.
[0170] The compiling and packaging unit is used to recompile the source code of the general virtual machine and package it as a virtual machine deployment installation package of the customized virtual machine.
[0171] In some embodiments of the invention, the correspondence replacement unit is specifically used to: extract the first mapping relationship table of the first correspondence relationship; determine the storage location of the second mapping relationship table of the original correspondence relationship in the header file; and insert the first mapping relationship table into the storage location of the header file to cover the second mapping relationship table.
[0172] In some inventive embodiments, the application isomerization module 520 includes:
[0173] The bytecode extraction unit is used to extract the method table of the program to be heterogeneous, and extract the bytecode array according to the method table.
[0174] An information extraction unit is used to determine the operation code position of the original operation code in the program to be heterogeneous and the original mnemonic corresponding to the original operation code according to the bytecode array.
[0175] A target determination unit is used to determine a target operation code corresponding to the original mnemonic within the first corresponding relationship.
[0176] The replacement execution unit is used to overwrite the original operation code with the target operation code according to the operation code position in the program to be heterogeneous so as to adjust the original corresponding relationship.
[0177] In some inventive embodiments, the bytecode extraction unit is specifically used to: unpack the program to be heterogeneous and extract the target bytecode file of the program to be heterogeneous; determine the virtual machine structure specification of the program to be heterogeneous, and extract the method table in the target bytecode file according to the virtual structure specification; extract the code attributes of the code class in the method table; determine that the code attribute is a method code attribute of a method, and extract the bytecode array in the method code attribute.
[0178] In some embodiments of the invention, the target determination unit is specifically used to: read a first mapping table of the first correspondence; search the first mapping table for a mnemonic having the same characters as the original mnemonic; and use the opcode corresponding to the mnemonic in the first mapping table as the target opcode.
[0179] In some inventive embodiments, the relationship generation unit is also used to: extract the order retention list of the configuration random instructions, and retain the mnemonic positions of the reserved mnemonics and / or the opcode positions of the reserved opcodes in the order retention list before the first random rule or the second random rule is randomly shuffled.
[0180] In some inventive embodiments, the replacement execution unit is specifically used to: search for the file position corresponding to the opcode position in the target bytecode file of the program to be heterogeneous; and modify the original opcode at the file position to the target opcode.
[0181] In some embodiments of the invention, the device further includes: a packaging module, used to obtain the program to be heterogeneous after the original corresponding relationship is adjusted, and package the program to be heterogeneous into an application package.
[0182] In some embodiments of the invention, it also includes: a deployment module, used to obtain a virtual machine deployment installation package of the customized virtual machine, and deploy the virtual deployment installation package in a preset environment to install the customized virtual machine, wherein the customized virtual machine is used to run the heterogeneous program to be heterogeneous.
[0183] The automatic application isomerization device provided in the embodiment of the present invention can execute the automatic application isomerization method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.
[0184] Embodiment 7
[0185] Fig.10 A schematic diagram of the structure of an electronic device 10 that can be used to implement an embodiment of the present invention is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or required herein.
[0186] like Fig.10 As shown, the electronic device 10 includes at least one processor 11, and a memory connected to the at least one processor 11, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., wherein the memory stores a computer program that can be executed by at least one processor, and the processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 to the random access memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other through a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.
[0187] A number of components in the electronic device 10 are connected to the I / O interface 15, including: an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a disk, an optical disk, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0188] The processor 11 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The processor 11 executes the various methods and processes described above, such as an automatic application isomerization method.
[0189] In some embodiments, the automatic isomerization method of an application may be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as a storage unit 18. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 10 via the ROM 12 and / or the communication unit 19. When the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps of the automatic isomerization method of an application described above may be performed. Alternatively, in other embodiments, the processor 11 may be configured to execute the automatic isomerization method of an application by any other appropriate means (e.g., by means of firmware).
[0190] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0191] Computer programs for implementing the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that when the computer program is executed by the processor, the functions / operations specified in the flow chart and / or block diagram are implemented. The computer program may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0192] In the context of the present invention, a computer-readable storage medium may be a tangible medium that may contain or store a computer program for use by or in combination with an instruction execution system, device or equipment. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or equipment, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, 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 disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0193] To provide interaction with a user, the systems and techniques described herein may be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices may also be used to provide interaction with the user; for example, the feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form (including acoustic input, voice input, or tactile input).
[0194] The systems and techniques described herein may be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.
[0195] A computing system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The client and server relationship is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services.
[0196] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps described in the present invention can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solution of the present invention can be achieved, and this document does not limit this.
[0197] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A method for automatic isomerization of an application program; It is characterized in that The method comprises: Generate a first correspondence between a mnemonic and an operation code corresponding to the heterogeneous program according to a preset random mapping rule; Adjusting the original correspondence between the original mnemonics and the original operation codes in the program to be heterogeneous according to the first correspondence to obtain the isomerized program to be heterogeneous; A customized virtual machine for running the program to be heterogeneous is generated according to the first corresponding relationship, wherein the customized virtual machine is used to run the heterogeneous program to be heterogeneous.
2. The method according to claim 1, It is characterized in that The generating a first correspondence between a mnemonic and an operation code corresponding to the heterogeneous program according to a preset random mapping rule includes: Obtaining a user's random configuration instruction, and searching a preset rule set for the preset random mapping rule corresponding to the random configuration instruction; A first corresponding relationship between the mnemonic and the operation code is generated according to the preset random mapping rule.
3. The method according to claim 2, It is characterized in that Also includes: Determine a general virtual machine that runs the program to be heterogeneous, and construct a preset mnemonic list and a preset operation code list according to the general mnemonics and general operation codes included in the general virtual machine; A position correspondence between mnemonic positions in the preset mnemonic list and opcode positions in the preset opcode list is configured.
4. The method according to claim 3, It is characterized in that Generating the first correspondence between the mnemonic and the operation code according to the preset random mapping rule includes: Determining a first random rule corresponding to the preset mnemonic list within the preset random mapping rule and determining a second random rule corresponding to the preset operation code list; Calling the first random rule to randomly shuffle the positions of different mnemonics in the preset mnemonic list and calling the second random rule to randomly shuffle the positions of different opcodes in the preset opcode list; The target operation code at the operation code position and the target mnemonic at the mnemonic position are determined according to the position correspondence, and the target correspondence between the target operation code and the target mnemonic is used as the first correspondence.
5. The method according to claim 1, It is characterized in that The step of generating a customized virtual machine for running the program to be heterogeneous according to the first corresponding relationship includes: Obtaining a general virtual machine that runs the program to be heterogeneous, and extracting a header file from the source code of the general virtual machine, wherein the header file at least includes an original correspondence between a general mnemonic and a general operation code; Replacing the original correspondence in the header file with the first correspondence; The source code of the general virtual machine is recompiled and packaged as a virtual machine deployment installation package of the customized virtual machine.
6. The method according to claim 1, It is characterized in that The adjusting the original correspondence between the original mnemonics and the original operation codes in the program to be heterogeneously constructed according to the first correspondence includes: Extracting a method table of the program to be heterogeneous, and extracting a bytecode array according to the method table; Determine the opcode position of the original opcode in the program to be heterogeneous and the original mnemonic corresponding to the original opcode according to the bytecode array; Determining a target opcode corresponding to the original mnemonic within the first corresponding relationship; In the program to be heterogeneous, the original operation code is overwritten with the target operation code according to the operation code position to adjust the original corresponding relationship.
7. The method according to claim 6, It is characterized in that The step of extracting a method table of the program to be heterogeneous and extracting a bytecode array according to the method table includes: Unpacking the program to be isomerized and extracting the target bytecode file of the program to be isomerized; Determine a virtual machine structure specification of the program to be heterogeneous, and extract a method table from the target bytecode file according to the virtual structure specification; Extracting code attributes of the code class in the method table; The code attribute is determined to be a method code attribute of a method, and a bytecode array in the method code attribute is extracted.
8. The method according to claim 6, It is characterized in that Determining the target operation code corresponding to the original mnemonic within the first corresponding relationship includes: Reading a first mapping table of the first corresponding relationship; Searching the first mapping table for a mnemonic with the same characters as the original mnemonic; The operation code corresponding to the mnemonic in the first mapping table is used as the target operation code.
9. The method according to claim 4, It is characterized in that Also includes: An order-reserved list of the configuration random instructions is extracted, and the mnemonic positions of the reserved mnemonics and / or the opcode positions of the reserved opcodes in the order-reserved list are reserved before the first random rule or the second random rule is randomly disrupted.
10. An automatic isomerization device for an application program, It is characterized in that The device comprises: A random mapping relationship generation module, used to generate a first correspondence relationship between a mnemonic and an operation code corresponding to a heterogeneous program according to a preset random mapping rule; An application isomerization module, used for adjusting the original correspondence between the original mnemonics and the original operation codes in the program to be isomerized according to the first correspondence to obtain the isomerized program to be isomerized; A customized virtual machine generation module is used to generate a customized virtual machine for running the program to be heterogeneous according to the first corresponding relationship, wherein the customized virtual machine is used to run the heterogeneous program to be heterogeneous.
11. An electronic device, It is characterized in that The electronic device comprises: at least one processor; and a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the method for automatic isomerization of an application program according to any one of claims 1 to 10.
12. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the automatic application isomerization method according to any one of claims 1 to 10 when executed.
13. A computer program product, It is characterized in that The computer program product comprises a computer program, which, when executed by a processor, implements the method for automatic isomerization of an application program according to any one of claims 1 to 10.
