Software code protection method, equipment, storage medium and device
By eliminating and streaming encoding of APP's original business bytecode in the Android system, generating puppet files, and using the QDavlik engine and strengthening the execution of QVM virtual machine, the problem of APP business code leakage in the Android system is solved, and the code is realized Safety protection.
Patent Information
- Application Number
- CN202310507455.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-05-06
- Publication Date
- 2024-11-08
AI Technical Summary
The open source nature of the Android system leads to the .dex code format being easily restored, resulting in a greater risk of leaking APP business code.
By eliminating the original business bytecode of the original code file in the software to be protected and streaming it, generating a puppet file, packaging and storage with the eliminated code file, using the QDavlik engine to decode and strengthen the QVM virtual machine Execute, confusing the cracker.
Effectively prevent APP business code leakage, protect program security, prevent personal information and property leakage, and reduce property losses.
Smart Images

Figure CN118916854A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a software code protection method, device, storage medium and apparatus. Background Art
[0002] Android is an open source system. Due to the open source nature of the system, the .dex code format is clearly known, and the code logic restored using decompilation tools is very clear. At the same time, there is a lot of room for adding, deleting, modifying and checking the code, which leads to great risks.
[0003] The above contents are only used to assist in understanding the technical solution of the present invention and do not constitute an admission that the above contents are prior art. Summary of the invention
[0004] The main purpose of the present invention is to provide a software code protection method, device, storage medium and apparatus, aiming to solve the technical problem in the prior art that the APP business code is easily leaked due to the system's open source code format being easily restored to the code logic.
[0005] To achieve the above object, the present invention provides a software code protection method, which comprises the following steps:
[0006] The original business bytecode of the original code file in the software to be protected is removed from the original code file to obtain a code file after the removal;
[0007] Performing streaming encoding processing on the original business bytecode to obtain a processed encoded file;
[0008] The encoded file and the removed code file are packaged and stored in the software to be protected.
[0009] Optionally, after the step of packaging the encoded file and the removed code file and storing them in the software to be protected, the method further includes:
[0010] After the program in the software to be protected is started and runs, the code file in the software to be protected is preloaded to obtain the loading result;
[0011] Identify the code files in the loading result, and determine the code files to be identified according to the identification result;
[0012] The code file to be identified is parsed based on a preset engine to obtain a parsing result.
[0013] Optionally, the code file to be identified includes a .qex file, the preset engine is a QDavlik engine, and the step of parsing the code file to be identified based on the preset engine to obtain a parsing result includes:
[0014] If the file to be identified is a .qex file, decoding the streaming encoding of the .qex file based on the QDavlik engine to obtain a decoding result;
[0015] The decoding result is parsed to obtain a parsing result.
[0016] Optionally, the step of decoding the streaming encoding of the .qex file based on the QDavlik engine to obtain a decoding result includes:
[0017] The QDavlik engine is controlled to load the .qex file in a serial manner according to the instructions, and the streaming encoding of the .qex file is decoded to obtain a decoding result.
[0018] Optionally, the step of controlling the QDavlik engine to load the .qex file in a serial manner according to instructions, and decoding the streaming encoding of the .qex file to obtain a decoding result includes:
[0019] According to the instruction serialization mode, the .qex file loading parsing function is searched from the preset QDavlik engine database, and the .qex file loading parsing function is controlled to load the .qex file according to the qex file loading parsing function, and the streaming encoding of the .qex file is decoded to obtain the decoding result.
[0020] Optionally, after the step of parsing the decoding result to obtain the parsing result, the method further includes:
[0021] The qdex code contained in the parsing result is executed based on the hardened QVM virtual machine, and an execution success instruction is returned.
[0022] Optionally, if the file to be identified is a .qex file, before the step of decoding the streaming encoding of the .qex file based on the QDavlik engine and obtaining the decoding result, the step further includes:
[0023] If the file to be identified is a .dex file, a dex file loading and parsing function is searched from a preset database, and the dex file loading and parsing function is called according to the address of the dex file loading and parsing function to load the .dex file into a preset system list;
[0024] The code in the .dex file is executed based on a preset virtual machine in the preset system and invalid instructions are added to the .dex file.
[0025] Optionally, before the step of removing the original business bytecode of the original code file in the software to be protected from the original code file to obtain the removed code file, the step further includes:
[0026] Obtain the original code file in the software to be protected;
[0027] Marking the original code file according to a preset sequence marking method to obtain a marking symbol;
[0028] The original business bytecode corresponding to the original code file is searched according to the marking symbol.
[0029] Optionally, the file format of the original code file is .dex, and the file format of the encoded file is .qex.
[0030] Optionally, the step of performing streaming encoding processing on the original business bytecode to obtain a processed encoded file includes:
[0031] The original business bytecode is stream-encoded in a manner of randomly replacing the operation code to obtain a processed encoding file.
[0032] Optionally, after the step of parsing the code file to be identified based on a preset engine to obtain a parsing result, the step further includes:
[0033] Obtaining an approximate maximum number of bytecodes corresponding to the parsing result;
[0034] When the approximate value of the maximum number exceeds a preset value, the bytecodes exceeding the preset value are cached.
[0035] Optionally, the removed code file is stored separately and independently from the encoding file in the software to be protected.
[0036] In addition, to achieve the above-mentioned purpose, the present invention also proposes a software code protection device, which includes a memory, a processor, and a software code protection program stored in the memory and executable on the processor, and the software code protection program is configured to implement the steps of software code protection as described above.
[0037] In addition, to achieve the above-mentioned purpose, the present invention further proposes a storage medium, on which a software code protection program is stored, and when the software code protection program is executed by a processor, the steps of the software code protection method described above are implemented.
[0038] In addition, to achieve the above object, the present invention also provides a software code protection device, the software code protection device comprising:
[0039] A code removal module is used to remove the original business bytecode of the original code file in the software to be protected from the original code file to obtain the removed code file;
[0040] A coding conversion module, used for performing streaming coding processing on the original business bytecode to obtain a processed coded file;
[0041] The packaging and storage module is used to package and store the encoded file and the removed code file into the software to be protected.
[0042] Optionally, the software code protection device further comprises: a loading and parsing module;
[0043] The loading and parsing module is also used to preload the code file in the software to be protected after the program in the software to be protected is started and run, and obtain the loading result;
[0044] The loading and parsing module is further used to identify the code files in the loading result, and determine the code files to be identified according to the identification result;
[0045] The loading and parsing module is further used to parse the code file to be identified based on a preset engine to obtain a parsing result.
[0046] Optionally, the code file to be identified includes a .qex file, the preset engine is a QDavlik engine, and the loading and parsing module is further used to decode the streaming encoding of the .qex file based on the QDavlik engine to obtain a decoding result if the file to be identified is a .qex file;
[0047] The loading and parsing module is further used to parse the decoding result to obtain a parsing result.
[0048] Optionally, the loading and parsing module is also used to control the QDavlik engine to load the .qex file in a serial instruction manner, and decode the streaming encoding of the .qex file to obtain a decoding result.
[0049] Optionally, the loading and parsing module is also used to search for the .qex file loading and parsing function from a preset QDavlik engine database in an instruction series manner, and control the QDavlik engine to load the .qex file according to the qex file loading and parsing function, and decode the streaming encoding of the .qex file to obtain a decoding result.
[0050] Optionally, the software code protection device also includes a code execution module, which is further used to execute the qdex code contained in the parsing result based on the hardened QVM virtual machine and return an execution success instruction.
[0051] The present invention removes the original business bytecode of the original code file in the software to be protected from the original code file to obtain the removed code file; performs streaming encoding processing on the original business bytecode to obtain the processed encoded file; and packages the encoded file and the removed code file into the software to be protected. Since the present invention performs streaming encoding processing on the original business bytecode and packages and stores the removed code file as a puppet file in the software to be protected to confuse crackers, compared with the problem in the prior art that the open source code format of the system is easy to restore the code logic, resulting in the problem that the APP business code is easy to leak, the present invention can effectively prevent the leakage of the APP business code, protect the program security, prevent the leakage of personal information and the safety of property, and reduce property losses. BRIEF DESCRIPTION OF THE DRAWINGS
[0052] Figure 1 It is a structural diagram of a software code protection device in a hardware operating environment involved in an embodiment of the present invention;
[0053] Figure 2 This is a flowchart of a first embodiment of a software code protection method according to the present invention;
[0054] Figure 3 This is a schematic diagram of file packaging in the first embodiment of the software code protection method of the present invention;
[0055] Figure 4 This is a flowchart of a second embodiment of a software code protection method according to the present invention;
[0056] Figure 5 A schematic diagram of program startup and operation of the second embodiment of the software code protection method of the present invention;
[0057] Figure 6 FIG. 1 is a structural block diagram of a first embodiment of a software code protection device according to the present invention.
[0058] The realization of the purpose, functional features and advantages of the present invention will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0059] It should be understood that the specific embodiments described herein are only used to explain the present invention, and are not used to limit the present invention.
[0060] Reference Figure 1 , Figure 1 It is a schematic diagram of the structure of a software code protection device in a hardware operating environment involved in an embodiment of the present invention.
[0061] like Figure 1As shown, the software code protection device may include: a processor 1001, such as a central processing unit (CPU), a communication bus 1002, a user interface 1003, a network interface 1004, and a memory 1005. Among them, the communication bus 1002 is used to realize the connection and communication between these components. The user interface 1003 may include a display screen (Display), and the user interface 1003 may also include a standard wired interface and a wireless interface. The wired interface of the user interface 1003 may be a USB interface in the present invention. The network interface 1004 may optionally include a standard wired interface and a wireless interface (such as a wireless fidelity (Wireless-Fidelity, Wi-Fi) interface). The memory 1005 may be a high-speed random access memory (Random Access Memory, RAM), or a stable memory (Non-volatile Memory, NVM), such as a disk memory. The memory 1005 may also be a storage device independent of the aforementioned processor 1001.
[0062] Those skilled in the art will understand that Figure 1 The structure shown in the figure does not constitute a limitation on the software code protection device, and may include more or less components than those shown in the figure, or combine certain components, or arrange the components differently.
[0063] like Figure 1 As shown, the memory 1005 identified as a computer storage medium may include an operating system, a network communication module, a user interface module, and a software code protection program.
[0064] exist Figure 1 In the software code protection device shown, the network interface 1004 is mainly used to connect to the background server and communicate data with the background server; the user interface 1003 is mainly used to connect to the user device; the software code protection device calls the software code protection program stored in the memory 1005 through the processor 1001, and executes the software code protection method provided by the embodiment of the present invention.
[0065] Based on the above hardware structure, an embodiment of the software code protection method of the present invention is proposed.
[0066] Reference Figure 2 , Figure 2 The flowchart of the first embodiment of the software code protection method of the present invention is shown in FIG.
[0067] In this embodiment, the software code protection method includes the following steps:
[0068] Step S10: removing the original business bytecode of the original code file in the software to be protected from the original code file to obtain a code file after removal.
[0069] It should be noted that the execution subject in this embodiment can be a device with a software code protection function, such as a server, a smart phone, a notebook, a computer, and a tablet, etc., and can also be other software code protection devices that can achieve the same or similar functions, and this embodiment does not limit this. Here, the above-mentioned computer will be used as an example to illustrate this embodiment and the following embodiments.
[0070] It is understandable that the software to be protected may refer to software that requires encryption protection of the original code files in the software, and the original code files may be code files composed of .dex files, where the file format of the .dex file can be divided into a dex header, various constant index tables and a data area.
[0071] It should be understood that the original business code may refer to the code directly used to implement user needs, that is, the business code. For example, if a user needs to query certain data, then the database is directly queried and the code returning the result is returned. The original business code bytecode may be the bytecode represented by converting the original business code into binary characters.
[0072] In the specific implementation, the core .dex file is an executable file run by the Davlik virtual machine on the Android system. It is also the core code of the APP business. Protecting the code in the .dex file is equivalent to protecting the APP. In this embodiment, the original business bytecode in the original code file is removed, and the .dex file generated by deleting the original bytecode data is saved as a puppet file in the software to be protected to mislead the cracker.
[0073] Step S20: Perform streaming encoding processing on the original business bytecode to obtain a processed encoded file.
[0074] It should be noted that the file format of the original code file is .dex, and the file format of the encoded file is .qex. After obtaining the processed encoded file, the encoded file is saved in the protected software according to .qex.
[0075] Furthermore, the step S20 also includes: performing streaming encoding processing on the original business bytecode in a manner of randomly replacing the operation code to obtain a processed encoded file.
[0076] It should be noted that streaming encoding may refer to randomly distributing the original business bytecode to a preset number of byte positions in a manner of randomly replacing operation codes, and performing encryption processing operations on the dispersed bytecode.
[0077] It should be understood that the .qex file format is a new file format created based on the analysis and reconstruction of the .dex file. In the streaming encoding process, the smali quality of the traditional assembly code of .dex is abandoned, and it is composed of q-smali assembly instructions used in the new format .qex. Compared with the existing encoding, the streaming encoding adopted in this scheme is more complex and safer, so it can increase the difficulty of cracking and further ensure the security of the program.
[0078] Furthermore, before step S10, the method further includes: obtaining the original code file in the software to be protected; marking the original code file according to a preset sequence marking method to obtain a marking symbol; and searching for the original business bytecode corresponding to the original code file according to the marking symbol.
[0079] It should be noted that the original code file is first obtained from the software to be protected, and the original code file can be a .dex file. The analysis engine is started to analyze the original .dex file as a whole, obtain the parameter information and position information corresponding to each bytecode in the .dex file, mark it, and obtain the marking symbol information corresponding to each byte.
[0080] It is understandable that when the bytecode needs to be formatted later, each bytecode in the original .dex file is searched through the marking symbol so as to accurately obtain the original bytecode data in the original .dex file.
[0081] In the specific implementation, to further illustrate the file conversion process, refer to Figure 3 The file packaging schematic diagram shown in the figure obtains the original code file data packet in the software to be protected, performs code processing (i.e. format conversion) on the data packet, outputs the middleware (i.e. .qex file and .dex file), and packages the .qex file and .dex file and stores them in the software to be protected.
[0082] Step S30: Packing the encoded file and the removed code file and storing them in the software to be protected.
[0083] Furthermore, it should be noted that the removed code files and the encoding files are stored separately and independently in the software to be protected, that is, the encoding files are stored in the software to be protected independently of the removed code files.
[0084] It is understandable that by storing the .dex file and the .qex file separately, the storage security can be improved. Compared with the prior art in which .dex is stored in a fixed list, this solution can ensure the security of the executable program by storing them separately.
[0085] This embodiment removes the original business bytecode of the original code file in the protected software from the original code file to obtain the removed code file; performs streaming encoding on the original business bytecode to obtain the processed encoded file; and packages the encoded file and the removed code file and stores them in the protected software. Since this embodiment performs streaming encoding on the original business bytecode and packages and stores the removed code file as a puppet file in the protected software to confuse crackers, compared with the problem in the prior art that the open source code format of the system is easy to restore the code logic, resulting in the easy leakage of APP business code, this embodiment can effectively prevent the leakage of APP business code, protect program security, prevent the leakage of personal information and property safety, and reduce property losses.
[0086] Reference Figure 4 , Figure 4 This is a flow chart of the second embodiment of the software code protection method of the present invention. Figure 2 The first embodiment shown provides a second embodiment of the software code protection method of the present invention.
[0087] In this embodiment, after step S30, the following steps are further included:
[0088] Step S40: After the program in the software to be protected is started and runs, the code file in the software to be protected is preloaded to obtain a loading result.
[0089] It should be noted that after the original business bytecode in the original business code file in the protected software is converted into a format in the early stage, when the program starts running after receiving the program start instruction, the code file in the protected software is preloaded first, and the loading results include .dex files and .qex files or files in other formats.
[0090] It is understandable that, due to the existence of dex files and .qex files or files in other formats, the files need to be preloaded first and then specific code identification is performed to determine the corresponding parsing engine.
[0091] Step S50: Identify the code files in the loading result, and determine the code files to be identified according to the identification result.
[0092] It should be noted that the recognition results include the code file type and the data attribute information carried by each code. However, since the .qex file is a file that has been specially encoded, the system cannot directly recognize it and needs to be disassembled and analyzed by a preset engine.
[0093] In a specific implementation, the code files in the loading result include .dex files and .qex files or files in other formats. However, due to the particularity of .qex files, a specific parsing engine needs to be selected to process them.
[0094] Step S60: parsing the code file to be identified based on a preset engine to obtain a parsing result.
[0095] It should be noted that the preset engines include engines for disassembling and analyzing .qex files, such as the QDavlik engine, and may also be analysis engines configured in other systems.
[0096] It is understandable that in order to ensure data security, the QDavlik engine is independent of other analysis engines in the system, so that the parsing process can be handled independently outside the system.
[0097] In a specific implementation, the code file to be identified is disassembled and analyzed through a pre-set engine to obtain information such as the parsed bytecode.
[0098] Furthermore, the code file to be identified includes a .qex file, and the preset engine is a QDavlik engine. The step S60 also includes: if the file to be identified is a .qex file, decoding the streaming encoding of the .qex file based on the QDavlik engine to obtain a decoding result; parsing the decoding result to obtain a parsing result.
[0099] It should be noted that after the program is started, the pre-set QDavlik engine loads the .qex file while running. When it runs into the relevant protection business code, it is handed over to the engine to complete the streaming encoding disassembly, parsing and running, so as to prevent the cracker from directly obtaining the .dex file business code from the system, thereby achieving the protection purpose.
[0100] It is understandable that the Davlik engine can be an engine that is inserted in the Davlik virtual machine to complete parsing and running. The Davlik virtual machine loads .dex files, which can be generated by .class files; and the QDavlik engine is a pre-set engine for loading and parsing .qex files. The engine can be inserted in the reinforced QVM virtual machine to parse .qex files. The difference from the art virtual machine is that the art virtual machine loads piece by piece, and the encoding length is fixed. However, the streaming encoding in this solution is a custom encoding, and the encoding length is not fixed, so it is necessary to pre-set the QDavlik engine for parsing .qex files.
[0101] It should be understood that the decoding result may be a business bytecode composed of at least one byte, and the business bytecode in the decoding result is parsed to determine the specific business code information to be executed corresponding to the bytecode.
[0102] In the specific implementation, to further illustrate the processing flow when the program is running, you can refer to Figure 5 As shown in the program startup diagram, after the program starts running, the QDavlik engine runs and loads the .qex file at the same time. When it runs into the relevant protected business code, it is handed over to the engine to complete the streaming encoding disassembly, parsing and running. The business code is stored in a new streaming encoding method, so that .dex and .qex are completely separated, preventing crackers from directly obtaining the .dex file business code from the system, thereby achieving the protection purpose.
[0103] Furthermore, the step of decoding the streaming encoding of the .qex file based on the QDavlik engine to obtain a decoding result includes: controlling the QDavlik engine to load the .qex file in an instruction series manner, and decoding the streaming encoding of the .qex file to obtain a decoding result.
[0104] It should be noted that the instruction concatenation method refers to executing commands in series, that is, the instructions are loaded in series by the virtual machine that processes the qdex file. Compared with the existing block-by-block loading method, this solution can achieve faster loading.
[0105] In a specific implementation, the QDavlik engine is controlled to load the .qex file in a serial manner according to instructions, and the streaming encoding of the .qex file is decoded to obtain a decoding result.
[0106] Furthermore, the step of controlling the QDavlik engine to load the .qex file in a serial instruction manner and decoding the streaming encoding of the .qex file to obtain a decoding result includes: searching for a .qex file loading parsing function from a preset QDavlik engine database in a serial instruction manner, and controlling the QDavlik engine to load the .qex file according to the qex file loading parsing function, and decoding the streaming encoding of the .qex file to obtain a decoding result.
[0107] It should be noted that the preset QDavlik engine database may be a pre-set database storing a mapping relationship between a file loading and parsing function and a .qex file, wherein the mapping relationship represents the correlation between the file size of the .qex file and the file loading and parsing function.
[0108] It is understandable that since the .qex file is a file that is processed independently of the open source system, when the .qex file is processed, it is independent of the open source system. The .qex file loading parsing function is searched from the preset QDavlik engine database in a serial manner of instructions, and the QDavlik engine is controlled to load the .qex file according to the qex file loading parsing function and the serial manner of instructions, and the streaming encoding of the .qex file is decoded to obtain the decoding result.
[0109] Furthermore, after the step of parsing the decoding result and obtaining the parsing result, the method further includes: executing the qdex code contained in the parsing result based on the hardened QVM virtual machine, and returning an execution success instruction.
[0110] It should be noted that the hardened QVM virtual machine is a virtual machine based on the hardened QEMU acceleration module, which can be used to parse the qdex code and return instructions that have been successfully executed after execution.
[0111] In this embodiment, the original business bytecode of the original code file in the software to be protected is removed from the original code file to obtain the removed code file; the original business bytecode is stream-encoded to obtain the processed coded file; the coded file and the removed code file are packaged and stored in the software to be protected. After the program in the software to be protected is started and run, the code file in the software to be protected is preloaded to obtain the loading result; the code file in the loading result is identified, and the code file to be identified is determined according to the identification result; the code file to be identified is parsed based on the preset engine to obtain the parsing result. Since this embodiment performs streaming encoding on the original business bytecode and packages and stores the removed code file as a puppet file in the software to be protected to confuse crackers, compared with the problem in the prior art that the open source code format of the system is easy to restore the code logic, resulting in the easy leakage of APP business code, this embodiment can effectively prevent the leakage of APP business code, protect program security, prevent the leakage of personal information and property security, and reduce property losses.
[0112] Based on the above Figure 4 The second embodiment shown provides a third embodiment of the software code protection method of the present invention.
[0113] In this embodiment, if the file to be identified is a .qex file, the streaming encoding of the .qex file is decoded based on the QDavlik engine, and before the step of obtaining the decoding result, it also includes: if the file to be identified is a .dex file, searching the dex file loading and parsing function from the preset database, and calling the dex file loading and parsing function according to the address of the dex file loading and parsing function to load the .dex file into the preset system list; executing the code in the .dex file based on the preset virtual machine in the preset system and adding invalid instructions to the .dex file.
[0114] It should be noted that the preset database may be a pre-set database storing a mapping relationship between a file loading and parsing function and a .dex file, wherein the mapping relationship represents the correlation between the file size of the .dex file and the file loading and parsing function.
[0115] It is understandable that the preset system may refer to an open source system, may be an Android system, or may be an iOS system, and the preset virtual machine includes an art virtual machine and a Davlik virtual machine, wherein the Davlik virtual machine may be used to process the .dex file.
[0116] In a specific implementation, if the file to be identified is a .dex file, a dex file loading and parsing function is searched from a preset database, and the dex file loading and parsing function is called according to the address of the dex file loading and parsing function to load the .dex file into a preset system list; based on a preset virtual machine in the preset system, the code in the .dex file is executed and invalid instructions are added to the .dex file.
[0117] Furthermore, after the step of parsing the code file to be identified based on a preset engine and obtaining the parsing result, it also includes: obtaining an approximate maximum number of bytecodes corresponding to the parsing result; when the approximate maximum number exceeds a preset value, caching the bytecodes that exceed the preset value.
[0118] It should be noted that in order to ensure processing efficiency, if the bytecode in the parsing result exceeds the preset bytecode processable value, part of the bytecode will be cached and processed after the previous part is processed.
[0119] In a specific implementation, an approximate maximum number of bytecodes corresponding to the parsing result is obtained; when the approximate maximum number exceeds a preset value, the bytecodes exceeding the preset value are cached.
[0120] In this embodiment, the original business bytecode of the original code file in the software to be protected is removed from the original code file to obtain the removed code file; the original business bytecode is stream-encoded to obtain the processed coded file; the coded file and the removed code file are packaged and stored in the software to be protected. After the program in the software to be protected is started and run, the code file in the software to be protected is preloaded to obtain the loading result; the code file in the loading result is identified, and the code file to be identified is determined according to the identification result; the code file to be identified is parsed based on the preset engine to obtain the parsing result. Since this embodiment performs streaming encoding on the original business bytecode and packages and stores the removed code file as a puppet file in the software to be protected to confuse crackers, compared with the problem in the prior art that the open source code format of the system is easy to restore the code logic, resulting in the easy leakage of APP business code, this embodiment can effectively prevent the leakage of APP business code, protect program security, prevent the leakage of personal information and property security, and reduce property losses.
[0121] In addition, to achieve the above-mentioned purpose, the present invention further proposes a storage medium, on which a software code protection program is stored, and when the software code protection program is executed by a processor, the steps of the software code protection method described above are implemented.
[0122] Reference Figure 6 , Figure 6 FIG. 1 is a structural block diagram of a first embodiment of a software code protection device according to the present invention.
[0123] like Figure 6 As shown, the software code protection device proposed in the embodiment of the present invention includes:
[0124] A code removal module 10 is used to remove the original business bytecode of the original code file in the software to be protected from the original code file to obtain the removed code file;
[0125] The encoding conversion module 20 is used to perform streaming encoding processing on the original business bytecode to obtain a processed encoding file;
[0126] The packaging and storage module 30 is used to package and store the encoded file and the removed code file into the software to be protected.
[0127] This embodiment removes the original business bytecode of the original code file in the protected software from the original code file to obtain the removed code file; performs streaming encoding on the original business bytecode to obtain the processed encoded file; and packages the encoded file and the removed code file and stores them in the protected software. Since this embodiment performs streaming encoding on the original business bytecode and packages and stores the removed code file as a puppet file in the protected software to confuse crackers, compared with the problem in the prior art that the open source code format of the system is easy to restore the code logic, resulting in the easy leakage of APP business code, this embodiment can effectively prevent the leakage of APP business code, protect program security, prevent the leakage of personal information and property safety, and reduce property losses.
[0128] Furthermore, the software code protection device further comprises: a loading and parsing module;
[0129] The loading and parsing module is also used to preload the code file in the software to be protected after the program in the software to be protected is started and run, and obtain the loading result;
[0130] The loading and parsing module is further used to identify the code files in the loading result, and determine the code files to be identified according to the identification result;
[0131] The loading and parsing module is further used to parse the code file to be identified based on a preset engine to obtain a parsing result.
[0132] Furthermore, the code file to be identified includes a .qex file, the preset engine is a QDavlik engine, and the loading and parsing module is further used for, if the file to be identified is a .qex file, decoding the streaming encoding of the .qex file based on the QDavlik engine to obtain a decoding result;
[0133] The loading and parsing module is further used to parse the decoding result to obtain a parsing result.
[0134] Furthermore, the loading and parsing module is also used to control the QDavlik engine to load the .qex file in a serial instruction manner, and decode the streaming encoding of the .qex file to obtain a decoding result.
[0135] Furthermore, the loading and parsing module is also used to search for the .qex file loading and parsing function from the preset QDavlik engine database in an instruction series manner, and control the QDavlik engine to load the .qex file according to the qex file loading and parsing function, and decode the streaming encoding of the .qex file to obtain a decoding result.
[0136] Furthermore, the software code protection device also includes a code execution module, which is further used to execute the qdex code contained in the parsing result based on the hardened QVM virtual machine and return an execution success instruction.
[0137] Furthermore, the code execution module is also used to search for a dex file loading and parsing function from a preset database if the file to be identified is a .dex file, and call the dex file loading and parsing function according to the address of the dex file loading and parsing function to load the .dex file into a preset system list;
[0138] The code execution module is also used to execute the code in the .dex file based on the art virtual machine in the preset system and add invalid instructions to the .dex file.
[0139] Furthermore, the software code protection device further comprises: a file marking module;
[0140] The file tag is used to obtain the original code file in the software to be protected;
[0141] The file marking is also used to mark the original code file according to a preset sequence marking method to obtain a marking symbol;
[0142] The file mark is also used to find the original business bytecode corresponding to the original code file according to the mark symbol.
[0143] Furthermore, the loading and parsing module is also used to perform streaming encoding processing on the original business bytecode in a manner of randomly replacing operation codes to obtain a processed encoded file.
[0144] Furthermore, the loading and parsing module is also used to obtain an approximate maximum number of bytecodes corresponding to the parsing result; when the approximate maximum number exceeds a preset value, the bytecodes exceeding the preset value are cached.
[0145] Other embodiments or specific implementations of the software code protection device of the present invention may refer to the above-mentioned method embodiments, which will not be described in detail here.
[0146] The present invention provides A1, a software code protection method, the software code protection method comprising the following steps:
[0147] The original business bytecode of the original code file in the software to be protected is removed from the original code file to obtain a code file after the removal;
[0148] Performing streaming encoding processing on the original business bytecode to obtain a processed encoded file;
[0149] The encoded file and the removed code file are packaged and stored in the software to be protected.
[0150] A2. The software code protection method as described in A1, after the step of packaging the coded file and the removed code file and storing them in the software to be protected, further comprises:
[0151] After the program in the software to be protected is started and runs, the code file in the software to be protected is preloaded to obtain the loading result;
[0152] Identify the code files in the loading result, and determine the code files to be identified according to the identification result;
[0153] The code file to be identified is parsed based on a preset engine to obtain a parsing result.
[0154] A3. The software code protection method as described in A2, wherein the code file to be identified includes a .qex file, the preset engine is a QDavlik engine, and the step of parsing the code file to be identified based on the preset engine to obtain the parsing result includes:
[0155] If the file to be identified is a .qex file, decoding the streaming encoding of the .qex file based on the QDavlik engine to obtain a decoding result;
[0156] The decoding result is parsed to obtain a parsing result.
[0157] A4, as described in A3, the software code protection method, the step of decoding the streaming encoding of the .qex file based on the QDavlik engine to obtain the decoding result, comprises:
[0158] The QDavlik engine is controlled to load the .qex file in a serial manner according to the instructions, and the streaming encoding of the .qex file is decoded to obtain a decoding result.
[0159] A5. The software code protection method as described in A4, wherein the step of controlling the QDavlik engine to load the .qex file in a serial manner according to instructions, and decoding the streaming encoding of the .qex file to obtain the decoding result comprises:
[0160] According to the instruction serialization mode, the .qex file loading parsing function is searched from the preset QDavlik engine database, and the .qex file loading parsing function is controlled to load the .qex file according to the qex file loading parsing function, and the streaming encoding of the .qex file is decoded to obtain the decoding result.
[0161] A6. The software code protection method as described in A3, after the step of parsing the decoding result to obtain the parsing result, further comprising:
[0162] The qdex code contained in the parsing result is executed based on the hardened QVM virtual machine, and an execution success instruction is returned.
[0163] A7. The software code protection method as described in A2, wherein if the file to be identified is a .qex file, before the step of decoding the streaming encoding of the .qex file based on the QDavlik engine and obtaining the decoding result, the method further comprises:
[0164] If the file to be identified is a .dex file, a dex file loading and parsing function is searched from a preset database, and the dex file loading and parsing function is called according to the address of the dex file loading and parsing function to load the .dex file into a preset system list;
[0165] The code in the .dex file is executed based on a preset virtual machine in the preset system and invalid instructions are added to the .dex file.
[0166] A8. The software code protection method as described in A1, before the step of removing the original business bytecode of the original code file in the software to be protected from the original code file to obtain the removed code file, further comprises:
[0167] Obtain the original code file in the software to be protected;
[0168] Marking the original code file according to a preset sequence marking method to obtain a marking symbol;
[0169] The original business bytecode corresponding to the original code file is searched according to the marking symbol.
[0170] A9. In the software code protection method as described in A1, the file format of the original code file is .dex, and the file format of the encoded file is .qex.
[0171] A10. In the software code protection method described in A1, the step of performing streaming encoding processing on the original business bytecode to obtain the processed encoded file comprises:
[0172] The original business bytecode is stream-encoded in a manner of randomly replacing the operation code to obtain a processed encoding file.
[0173] A11. The software code protection method as described in any one of A1 to A10, wherein after the step of parsing the code file to be identified based on a preset engine to obtain a parsing result, the method further comprises:
[0174] Obtaining an approximate maximum number of bytecodes corresponding to the parsing result;
[0175] When the approximate value of the maximum number exceeds a preset value, the bytecodes exceeding the preset value are cached.
[0176] A12. The software code protection method as described in A1, wherein the removed code files and the encoding files are stored separately and independently in the software to be protected.
[0177] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or system including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or system. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or system including the element.
[0178] The serial numbers of the embodiments of the present invention are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments. In a unit claim that lists several means, several of these means may be embodied by the same hardware item. The use of the words first, second, and third, etc. does not indicate any order and these words may be interpreted as names.
[0179] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course can also be implemented by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a storage medium (such as a read-only memory image (ROM) / random access memory (RAM), a magnetic disk, or an optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods described in each embodiment of the present invention.
[0180] The above are only preferred embodiments of the present invention, and are not intended to limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made using the contents of the present invention specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.
Claims
1. A software code protection method, characterized in that: The software code protection method comprises the following steps: The original business bytecode of the original code file in the software to be protected is removed from the original code file to obtain a code file after the removal; Performing streaming encoding processing on the original business bytecode to obtain a processed encoded file; The encoded file and the removed code file are packaged and stored in the software to be protected.
2. The software code protection method according to claim 1, characterized in that: After the step of packaging the coded file and the removed code file and storing them in the software to be protected, the method further includes: After the program in the software to be protected is started and runs, the code file in the software to be protected is preloaded to obtain the loading result; Identify the code files in the loading result, and determine the code files to be identified according to the identification result; The code file to be identified is parsed based on a preset engine to obtain a parsing result.
3. The software code protection method according to claim 2, characterized in that: The code file to be identified includes a .qex file, the preset engine is a QDavlik engine, and the step of parsing the code file to be identified based on the preset engine to obtain a parsing result includes: If the file to be identified is a .qex file, decoding the streaming encoding of the .qex file based on the QDavlik engine to obtain a decoding result; The decoding result is parsed to obtain a parsing result.
4. The software code protection method according to claim 3, characterized in that: The step of decoding the streaming encoding of the .qex file based on the QDavlik engine to obtain a decoding result includes: The QDavlik engine is controlled to load the .qex file in a serial manner according to the instructions, and the streaming encoding of the .qex file is decoded to obtain a decoding result.
5. The software code protection method according to claim 4, characterized in that: The step of controlling the QDavlik engine to load the .qex file in a serial manner according to the instructions, and decoding the streaming encoding of the .qex file to obtain the decoding result includes: According to the instruction serialization mode, the .qex file loading parsing function is searched from the preset QDavlik engine database, and the .qex file loading parsing function is controlled to load the .qex file according to the qex file loading parsing function, and the streaming encoding of the .qex file is decoded to obtain the decoding result.
6. The software code protection method according to claim 2, characterized in that: If the file to be identified is a .qex file, before the step of decoding the streaming encoding of the .qex file based on the QDavlik engine and obtaining the decoding result, the step further includes: If the file to be identified is a .dex file, a dex file loading and parsing function is searched from a preset database, and the dex file loading and parsing function is called according to the address of the dex file loading and parsing function to load the .dex file into a preset system list; The code in the .dex file is executed based on a preset virtual machine in the preset system and invalid instructions are added to the .dex file.
7. The software code protection method according to claim 1, characterized in that: Before the step of removing the original business bytecode of the original code file in the software to be protected from the original code file to obtain the removed code file, the method further includes: Obtain the original code file in the software to be protected; Marking the original code file according to a preset sequence marking method to obtain a marking symbol; The original business bytecode corresponding to the original code file is searched according to the marking symbol.
8. A software code protection device, characterized in that: The software code protection device comprises: a memory, a processor, and a software code protection program stored in the memory and executable on the processor, wherein the software code protection program implements the software code protection method according to any one of claims 1 to 7 when executed by the processor.
9. A storage medium, characterized in that: The storage medium stores a software code protection program, and when the software code protection program is executed by the processor, the software code protection method according to any one of claims 1 to 7 is implemented.
10. A software code protection device, characterized in that: The software code protection device comprises: A code removal module is used to remove the original business bytecode of the original code file in the software to be protected from the original code file to obtain the removed code file; A coding conversion module, used for performing streaming coding processing on the original business bytecode to obtain a processed coded file; The packaging and storage module is used to package and store the encoded file and the removed code file into the software to be protected.
