Software packing and unpacking methods based on quantum random number entropy source

By using a casting method based on quantum random number entropy source in software casting technology, the target file is encrypted using stream key and protection key, which solves the insufficient protection of encryption algorithms and insufficient security of key information in the prior art. The problem of this achieves high security and fast key generation effects.

CN116361749BActive Publication Date: 2025-02-11CHINA TELECOM QUANTUM TECH CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202310480390.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-04-28
Publication Date
2025-02-11
Estimated Expiration
2043-04-28

AI Technical Summary

Technical Problem

The existing software encapsulation technology is difficult to meet the high security needs, mainly due to problems such as insufficient protection of encryption algorithms, lack of support for password components, and lack of protection of key information.

Method used

Using a software shelling method based on quantum random number entropy source, by obtaining the protection key and the stream key and storing it to the cryptographic component, the code segment of the target file is streamed using the stream key, and the protection key pair is used. The data segment is encrypted to ensure the secure storage of key information.

Benefits of technology

It greatly improves the security protection capability of executable code, meets the requirements of streaming key generation speed, ensures high-level security protection of key information, and prevents cracking software from obtaining key information.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116361749B_ABST
    Figure CN116361749B_ABST
Patent Text Reader

Abstract

The invention discloses a software shelling method and a shelling method based on a quantum random number entropy source. The shelling method comprises: obtaining a protection key and a stream key, and storing the protection key in a password component, wherein both the protection key and the stream key are random numbers; performing stream encryption processing on a code segment plaintext in a target file by using the stream key, and overwriting the code segment plaintext in the target file with the obtained code segment ciphertext; sending an ID value of the protection key and a data segment to the password component, so that the password component obtains the corresponding protection key to encrypt the data segment; receiving the data segment ciphertext returned by the password component, and writing the ciphertext into the binary encoding address of the target file; and improving the security protection capability of executable code.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of software shells, and in particular to a software shelling method and a software decryption method based on a quantum random number entropy source. Background Art

[0002] Software shell is the most common and safest technology in software encryption. Shell technology refers to the use of a certain algorithm to encrypt and compress the original executable file, and add a shell outside the actual execution code to prevent the executable file from being illegally used, tampered with, reverse analyzed, etc.

[0003] A stream cipher, also known as stream encryption, is a symmetric encryption algorithm. The encryption and decryption parties use the same random key data stream as the key. The plaintext data is encrypted sequentially with the key data stream each time to obtain a ciphertext data stream. In practice, data is usually encrypted bit by bit using an exclusive OR (XOR) operation.

[0004] As users’ requirements for device local security and application security continue to increase, the self-protection function of software combined with cryptographic technology has gradually become a requirement for a high security level. For example, in the related technology, an executable program shell protection method is proposed in the invention patent application document with application publication number CN102609666A, which increases the security of the software by encrypting the software program twice. In a program code encryption and decryption method proposed in the invention patent application document with application publication number CN112597453A, a key generator is used to encrypt the combination of a random number and a code book to obtain a target key, and the target key is used to encrypt the code. However, the above-mentioned related technologies all use a stream cipher that uses true random numbers for encryption, but the stream key method has very high requirements on the generation rate of the random number generator, and the general random number generator cannot meet it.

[0005] At present, the traditional software packaging technology is difficult to meet the requirements, and the main problems are as follows:

[0006] (1) Most shelling technologies only compress key code segments and data segments and lack the protection of encryption algorithms with higher security strength.

[0007] (2) Lack of support for cryptographic components. The de-shelling information is usually preset in the shell software code. After being reverse cracked, the protected object can be easily restored and stolen.

[0008] (3) Key information lacks protection and is not stored securely. Summary of the invention

[0009] The technical problem to be solved by the present invention is how to improve the security protection capability of executable code.

[0010] The present invention solves the above technical problems by the following technical means:

[0011] In a first aspect, the present invention proposes a software shelling method based on a quantum random number entropy source, the shelling method comprising:

[0012] Obtaining a protection key and a stream key, and storing the protection key in a cryptographic component, wherein both the protection key and the stream key are random numbers;

[0013] Using the stream key to perform stream encryption on the code segment plaintext in the target file, and overwriting the code segment plaintext in the target file with the obtained code segment ciphertext;

[0014] Sending the ID value of the protection key and the data segment to the cryptographic component, so that the cryptographic component obtains the corresponding protection key to encrypt the data segment;

[0015] After receiving the data segment ciphertext returned by the password component and writing it into the binary encoding address of the target file.

[0016] Further, the obtaining of the protection key and the stream key, and storing the protection key in the cryptographic component, includes:

[0017] Obtaining a random number from a quantum random number entropy source as the protection key, and storing the protection key in the cryptographic component;

[0018] Receiving the ID value of the protection key returned by the cryptographic component;

[0019] Obtaining a random number having the same length as the code segment in the target file from the quantum random number entropy source as the stream key, and storing the stream key in the quantum random number entropy source;

[0020] Receive the ID value of the stream key returned by the quantum random number entropy source.

[0021] Furthermore, before obtaining a random number having the same length as the code segment in the target file from the quantum random number entropy source as the stream key, the shelling method further includes:

[0022] Inserting the section_header information of the quantum software loader into the target file, and moving the section_header information of the target file upward;

[0023] Modify the section_header offset value of the target file header;

[0024] Obtaining the length of the code segment in the target file, and embedding the binary code of the quantum software loader into the address position after the code segment;

[0025] Modify the p_filesz field of the program_header of the target file to the quantum software loader size.

[0026] Furthermore, the data segment includes a fileinfo structure and a streamcihper structure;

[0027] The fileinfo structure stores the size of the target file and the program entry address of the target file;

[0028] The streamcihper structure stores the ID value of the stream key and the length of the code segment.

[0029] Further, sending the ID value of the protection key and the data segment to the cryptographic component so that the cryptographic component obtains the corresponding protection key to encrypt the data segment, including:

[0030] The ID value of the protection key, the fileinfo structure and the streamcihper structure are sent to the cryptographic component, so that the cryptographic component obtains the corresponding protection key based on the ID value of the protection key to encrypt the fileinfo structure and the streamcihper structure to obtain the fileinfo ciphertext and the streamcihper ciphertext.

[0031] Furthermore, after receiving the data segment ciphertext returned by the cryptographic component and writing it into the binary encoding address of the target file, the shelling method further includes:

[0032] Write the version number, manufacturer information and ID value of the protection key of the quantum software loader into the softinfo structure, and insert the softinfo structure after the ciphertext address of the data segment;

[0033] Modify the program entry address in the target file to the first address of the binary code.

[0034] In a second aspect, the present invention proposes a software unpacking method based on a quantum random number entropy source, characterized in that the unpacking method comprises:

[0035] Loading the packed target file, migrating the code segment ciphertext, data segment ciphertext and softinfo structure in the target file from the memory space of the target file to the first memory space;

[0036] Sending the ID value of the protection key carried in the softinfo structure and the data segment ciphertext to the cryptographic component, so that the cryptographic component obtains the corresponding protection key to decrypt the data segment ciphertext to obtain the data segment plaintext;

[0037] Receiving the data segment plaintext, and acquiring a corresponding stream key based on an ID value of the stream key carried in the data segment plaintext;

[0038] The code segment ciphertext is decrypted using the stream key, and the decrypted code segment plaintext is copied to the memory space of the target file.

[0039] Furthermore, the data segment ciphertext includes fileinfo ciphertext and streamcihper ciphertext, and the data segment plaintext includes fileinfo structure and streamcihper structure;

[0040] The fileinfo structure stores the size of the target file and the program entry address of the target file;

[0041] The streamcihper structure stores the ID value of the stream key and the length of the plaintext of the code segment.

[0042] Further, the receiving the data segment plaintext and obtaining the corresponding stream key based on the ID value of the stream key carried in the data segment plaintext includes:

[0043] Based on the ID value of the stream key stored in the streamcihper structure, the stream key is sent to the quantum random number entropy source, so that the quantum random number entropy source obtains the corresponding stream key based on the ID value of the stream key;

[0044] Receive the stream key returned by the quantum random number entropy source.

[0045] Furthermore, when the plaintext acquisition of the data segment fails, the first memory space is released and an error is reported.

[0046] Furthermore, after decrypting the code segment ciphertext by using the stream key and copying the decrypted code segment plaintext to the memory space of the target file, the unpacking method further includes:

[0047] releasing the first memory space;

[0048] Jump back to the program entry address of the target file and execute the plain text of the code segment.

[0049] In a third aspect, the present invention further proposes a quantum cryptographic packer, comprising:

[0050] A key acquisition module, used for acquiring a protection key and a stream key, and storing the protection key in a cryptographic component, wherein both the protection key and the stream key are random numbers;

[0051] A stream encryption module, used for performing stream encryption processing on the plain text of the code segment in the target file using the stream key, and overwriting the plain text of the code segment in the target file with the obtained ciphertext of the code segment;

[0052] A data encryption module, used for sending the ID value of the protection key and the data segment to the cryptographic component, so that the cryptographic component obtains the corresponding protection key to encrypt the data segment;

[0053] The file reconstruction module is used to receive the ciphertext of the data segment returned by the password component and write it into the binary encoding address of the target file.

[0054] In a fourth aspect, the present invention further proposes a software packing system based on a quantum random number entropy source, the system comprising a quantum cryptographic packer, a cryptographic component and a quantum random number entropy source, the cryptographic component and the quantum random number entropy source are both connected to the quantum cryptographic packer, the quantum cryptographic packer comprises

[0055] A key acquisition module, used to acquire a protection key and a stream key from the quantum random number entropy source, and store the protection key in the cryptographic component;

[0056] A stream encryption module, used for performing stream encryption processing on the plain text of the code segment in the target file using the stream key, and overwriting the plain text of the code segment in the target file with the obtained ciphertext of the code segment;

[0057] A data encryption module, used for sending the ID value of the protection key and the data segment to the cryptographic component, so that the cryptographic component obtains the corresponding protection key to encrypt the data segment;

[0058] The file reconstruction module is used to receive the ciphertext of the data segment returned by the password component and write it into the binary encoding address of the target file.

[0059] In a fifth aspect, the present invention further proposes a quantum software loader, comprising:

[0060] A file recording module is used to load the packed target file, and migrate the code segment ciphertext, data segment ciphertext and softinfo structure in the target file from the memory space of the target file to the first memory space;

[0061] A data decryption module, used for sending the ID value of the protection key carried in the softinfo structure and the data segment ciphertext to the cryptographic component, so that the cryptographic component obtains the corresponding protection key to decrypt the data segment ciphertext to obtain the data segment plaintext;

[0062] A stream key request module, configured to receive the data segment plaintext, and obtain a corresponding stream key based on an ID value of the stream key carried in the data segment plaintext;

[0063] The code decryption module is used to decrypt the code segment ciphertext using the stream key, and copy the decrypted code segment plaintext to the memory space of the target file.

[0064] In a sixth aspect, the present invention further proposes a software unpacking system based on a quantum random number entropy source, the system comprising a quantum software loader, a cryptographic component and a quantum random number entropy source, the cryptographic component and the quantum random number entropy source are both connected to the quantum software loader, and the quantum software loader comprises:

[0065] A file recording module is used to load the packed target file, and migrate the code segment ciphertext, data segment ciphertext and softinfo structure in the target file from the memory space of the target file to the first memory space;

[0066] A data decryption module, used for sending the ID value of the protection key carried in the softinfo structure and the data segment ciphertext to the cryptographic component, so that the cryptographic component obtains the corresponding protection key to decrypt the data segment ciphertext to obtain the data segment plaintext;

[0067] A stream key request module, configured to request a corresponding stream key from the quantum random number entropy source based on an ID value of the stream key carried in plain text in the data segment;

[0068] The code decryption module is used to decrypt the code segment ciphertext using the stream key, and copy the decrypted code segment plaintext to the memory space of the target file.

[0069] The advantages of the present invention are:

[0070] (1) The present invention uses random numbers as protection keys and stream keys, and uses the stream keys to perform stream encryption processing on the executable code segments in the target file. The stream keys with symmetric encryption and perfect confidentiality are used to implement encryption protection of the code segments, and the protection keys are used to encrypt the key data information in the target file. The cracking software cannot obtain the location and size of the code segments. In addition, the key information is securely stored, and the key and the software product are separated. The key is protected at a higher level, and the cracking software cannot obtain the key information from the software product.

[0071] (2) It utilizes the principle of "quantum unobservability" to actively detect quantum states and trigger random changes in quantum states. Unobservability means irregularity, and only irregularity can generate true random numbers. It fully utilizes the true randomness of the quantum random number entropy source and the fast random number generation characteristics, combines stream ciphers with software shell technology, and greatly improves the security protection capabilities of executable codes. It meets the generation speed requirements of stream keys, and the random number rate and randomness are better than traditional random number generators.

[0072] (3) The packed information residing in the memory is destroyed to prevent the leakage of key information.

[0073] Additional aspects and advantages of the present invention will be given in part in the following description and in part will be obvious from the following description, or will be learned through practice of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS

[0074] Figure 1 It is a flowchart of a software shelling method based on a quantum random number entropy source proposed by the present invention;

[0075] Figure 2 It is a pseudo code diagram of the data structure of the target file in the present invention;

[0076] Figure 3 It is a schematic diagram of the structure of the target file after shelling and reconstruction in the present invention;

[0077] Figure 4 It is a schematic diagram of the structure of the quantum cryptographic packer proposed by the present invention;

[0078] Figure 5 It is a structural schematic diagram of a software packing system based on a quantum random number entropy source proposed by the present invention;

[0079] Figure 6 It is a flowchart of a software unpacking method based on a quantum random number entropy source proposed by the present invention;

[0080] Figure 7 It is a schematic diagram of the structure of the quantum software loader proposed by the present invention;

[0081] Figure 8 It is a schematic diagram of the working principle of the software unpacking system based on quantum random number entropy source proposed by the present invention. DETAILED DESCRIPTION

[0082] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in combination with the embodiments of the present invention. Obviously, the described embodiments are 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 are within the scope of protection of the present invention.

[0083] Example 1

[0084] like Figure 1 As shown, the first embodiment of the present invention proposes a software shelling method based on a quantum random number entropy source, and the method includes the following steps:

[0085] S101, obtaining a protection key and a stream key, and storing the protection key in a cryptographic component, wherein both the protection key and the stream key are random numbers;

[0086] It should be noted that both the protection key and the stream key are random numbers generated by a quantum random number entropy source, which has the characteristics of true randomness and fast random number generation.

[0087] S102, using the stream key to perform stream encryption processing on the plaintext of the code segment in the target file, and using the obtained ciphertext of the code segment to overwrite the plaintext of the code segment in the target file;

[0088] It should be noted that, in this embodiment, the stream key is bit-wise XORed with the code segment plaintext to obtain the code segment ciphertext; the code segment plaintext is encrypted using the stream key with symmetric encryption and perfect confidentiality to achieve encryption protection of the code segment.

[0089] S103, sending the ID value of the protection key and the data segment to the cryptographic component, so that the cryptographic component obtains the corresponding protection key to encrypt the data segment;

[0090] It should be noted that the cryptographic component has a built-in national secret algorithm SM2, SM3 or SM4, and has a secure storage area function for storing protection keys; the cryptographic component uses symmetric encryption operations such as SM4 to implement symmetric encryption protection on key data structures.

[0091] S104, receiving the data segment ciphertext returned by the cryptographic component and writing it into the binary encoding address of the target file.

[0092] It should be noted that the binary code address is the binary code of the quantum software loader and is pre-inserted into the address position after the code segment in the target file.

[0093] This embodiment uses random numbers as protection keys and stream keys, and uses the stream keys to perform stream encryption processing on the executable code segments in the target file. The stream keys with symmetric encryption and perfect confidentiality are used to implement encryption protection of the code segments, and the protection keys are used to encrypt key data information in the target file. The cracking software cannot obtain the location and size of the code segments. In addition, the key information is securely stored, the key and the software product are separated, the key is protected at a higher level, and the cracking software cannot obtain the key information from the software product.

[0094] In one embodiment, the step S101: obtaining a protection key and a stream key, and storing the protection key in a cryptographic component, specifically includes the following steps:

[0095] S111, obtaining a random number from a quantum random number entropy source as the protection key, and storing the protection key in the cryptographic component;

[0096] It should be noted that the protection key is specifically stored in the secure storage area of ​​the cryptographic component.

[0097] S112, receiving the ID value of the protection key returned by the cryptographic component;

[0098] S113, obtaining a random number having the same length as the code segment in the target file from the quantum random number entropy source as the stream key, and storing the stream key in the quantum random number entropy source;

[0099] It should be noted that the stream key is specifically stored in a large-capacity secure storage area of ​​the quantum random number entropy source.

[0100] S114. Receive the ID value of the stream key returned by the quantum random number entropy source.

[0101] This embodiment makes full use of the true randomness and fast random number generation of the quantum random number entropy source, combines the stream cipher and software shell technology, and greatly improves the security protection capability of the executable code; and the protection key and the stream key are respectively stored in the cryptographic component and the quantum random number entropy source, separating the key from the software product, and the key is protected at a higher level, and the cracking software cannot obtain the key information from the software product.

[0102] In one embodiment, before the step S113: obtaining a random number having the same length as the code segment in the target file from the quantum random number entropy source as the stream key, and storing the stream key in the quantum random number entropy source, the method further comprises the following steps:

[0103] Inserting the section_header information of the quantum software loader into the target file, and moving the section_header information of the target file upward;

[0104] Modify the section_header offset value of the target file header;

[0105] Obtaining the length of the code segment in the target file, and embedding the binary code of the quantum software loader into the address position after the code segment;

[0106] Modify the p_filesz field of the program_header of the target file to the quantum software loader size.

[0107] Specifically, Figure 2 As shown, taking ELF file as the target file as an example, ELF file is used as the file format of binary files, executable files, object code, shared libraries and core dump format files, including file header, section header and program header. The size, position and number of program header and section header in the ELF file are obtained through the file header. The properties of each segment can be obtained through the program header, and the properties of each section can be obtained through the sectionheader.

[0108] Among them, the softinfo structure stores the shell version number, manufacturer information, and key ID value, the fileinfo structure stores the file size and ELF program entry address, and the streamcihper structure stores the stream cipher ID value, code segment length, and code segment offset.

[0109] In one embodiment, the data segment includes a fileinfo structure and a streamcihper structure;

[0110] The fileinfo structure stores the size of the target file and the program entry address of the target file;

[0111] The streamcihper structure stores the ID value of the stream key and the length of the code segment.

[0112] In one embodiment, the step S103: sending the ID value of the protection key and the data segment to the cryptographic component so that the cryptographic component obtains the corresponding protection key to encrypt the data segment, specifically includes the following steps:

[0113] The ID value of the protection key, the fileinfo structure and the streamcihper structure are sent to the cryptographic component, so that the cryptographic component obtains the corresponding protection key based on the ID value of the protection key to encrypt the fileinfo structure and the streamcihper structure to obtain the fileinfo ciphertext and the streamcihper ciphertext.

[0114] Furthermore, before executing step S102: using the stream key to perform stream encryption processing on the code segment plaintext in the target file and overwriting the code segment plaintext in the target file with the obtained code segment ciphertext, this embodiment further includes:

[0115] Initialize the softinfo structure, fileinfo structure and streamcihper structure.

[0116] After the obtained code segment ciphertext overwrites the original code segment plaintext, the stream key used to encrypt the code segment plaintext is stored in the secure storage area of ​​the quantum random number entropy source, and the ID value of the stream key is returned; then the code segment length and the ID value of the stream key are written into the streamcihper structure, and the ELF file program entry address and ELF file size are obtained and written into the fileinfo structure.

[0117] In one embodiment, after the step S104: receiving the data segment ciphertext returned by the cryptographic component and writing it into the binary encoding address of the target file, the shelling method further includes the following steps:

[0118] Write the version number, manufacturer information and ID value of the protection key of the quantum software loader into the softinfo structure, and insert the softinfo structure after the ciphertext address of the data segment;

[0119] The e_entry field of the elf_header is modified to modify the program entry address in the target file to the first address of the binary code.

[0120] It should be noted that the ELF file structure after the packer is reconstructed is as follows Figure 3 shown.

[0121] Example 2

[0122] like Figure 4 As shown, the second embodiment of the present invention proposes a software unpacking method based on a quantum random number entropy source. The unpacking method comprises the following steps:

[0123] S201, loading the packed target file, and migrating the code segment ciphertext, data segment ciphertext and softinfo structure in the target file from the memory space of the target file to the first memory space;

[0124] S202, sending the ID value of the protection key carried in the softinfo structure and the data segment ciphertext to the cryptographic component, so that the cryptographic component obtains the corresponding protection key to decrypt the data segment ciphertext to obtain the data segment plaintext;

[0125] S203, receiving the data segment plaintext, and acquiring a corresponding stream key based on the ID value of the stream key carried in the data segment plaintext;

[0126] S204: Decrypt the code segment ciphertext using the stream key, and copy the decrypted code segment plaintext to the memory space of the target file.

[0127] In this embodiment, after the system loads the shelled target file, the entry address jumps to the initialization segment code, which is responsible for internal data migration, migrating the data from the memory space of the target file to the first memory space, and jumping to the core segment to execute, completing the decryption of the relevant data structure and the decryption of the code segment, and restoring the data in the ELF memory space. In this embodiment, the stream key is "overwritten" on the ciphertext without copying operations to obtain the plaintext, and no underlying interface provided by any third party is called in the process. The key stream can be directly obtained from an independent quantum module. After the "overwrite" is completed, the key stream memory is immediately cleared and released to ensure security.

[0128] In one embodiment, the data segment ciphertext includes fileinfo ciphertext and streamcihper ciphertext, and the data segment plaintext includes fileinfo structure and streamcihper structure;

[0129] The fileinfo structure stores the size of the target file and the program entry address of the target file;

[0130] The streamcihper structure stores the ID value of the stream key and the length of the plaintext of the code segment.

[0131] In one embodiment, the step S203: receiving the data segment plaintext, and obtaining the corresponding stream key based on the ID value of the stream key carried in the data segment plaintext, specifically includes the following steps:

[0132] S231, based on the ID value of the stream key stored in the streamcihper structure, sending it to the quantum random number entropy source, so that the quantum random number entropy source obtains the corresponding stream key based on the ID value of the stream key;

[0133] S232. Receive the stream key returned by the quantum random number entropy source.

[0134] In one embodiment, when the plaintext acquisition of the data segment fails, the first memory space is released, and an error is reported to end the decryption process.

[0135] In one embodiment, after the step S204: decrypting the code segment ciphertext using the stream key and copying the decrypted code segment plaintext to the memory space of the target file, the decompression method further includes the following steps:

[0136] S241, releasing the first memory space;

[0137] S242, jumping back to the program entry address of the target file, and executing the plain text of the code segment.

[0138] Specifically, based on the program entry address of the target file stored in the fileinfo structure, jump back to the program entry address of the target file and execute the plain text of the code segment.

[0139] Example 3

[0140] like Figure 5 As shown, the third embodiment of the present invention proposes a quantum cryptographic packer, which specifically includes:

[0141] A key acquisition module 11 is used to acquire a protection key and a stream key, and store the protection key in a cryptographic component, wherein both the protection key and the stream key are random numbers;

[0142] A stream encryption module 12, used to perform stream encryption processing on the code segment plaintext in the target file using the stream key, and overwrite the code segment plaintext in the target file with the obtained code segment ciphertext;

[0143] The data encryption module 13 is used to send the ID value of the protection key and the data segment to the cryptographic component, so that the cryptographic component obtains the corresponding protection key to encrypt the data segment;

[0144] The file reconstruction module 14 is used to receive the data segment ciphertext returned by the cryptographic component and write it into the binary encoding address of the target file.

[0145] This embodiment uses random numbers as protection keys and stream keys, and uses the stream keys to perform stream encryption processing on the executable code segments in the target file. The stream keys with symmetric encryption and perfect confidentiality are used to implement encryption protection of the code segments, and the protection keys are used to encrypt key data information in the target file. The cracking software cannot obtain the location and size of the code segments. In addition, the key information is securely stored, the key and the software product are separated, the key is protected at a higher level, and the cracking software cannot obtain the key information from the software product.

[0146] In one embodiment, the key acquisition module 11 specifically includes:

[0147] A first key acquisition unit, configured to acquire a random number from a quantum random number entropy source as the protection key, and store the protection key in the cryptographic component;

[0148] A first ID receiving unit, used to receive the ID value of the protection key returned by the password component;

[0149] A second key acquisition unit is used to obtain a random number having the same length as the code segment in the target file from the quantum random number entropy source as the stream key, and store the stream key in the quantum random number entropy source;

[0150] The second ID receiving unit is used to receive the ID value of the stream key returned by the quantum random number entropy source.

[0151] In one embodiment, the quantum cryptographic packer further includes a file modification module, which is specifically used to perform the following steps:

[0152] Inserting the section_header information of the quantum software loader into the target file, and moving the section_header information of the target file upward;

[0153] Modify the section_header offset value of the target file header;

[0154] Obtaining the length of the code segment in the target file, and embedding the binary code of the quantum software loader into the address position after the code segment;

[0155] Modify the p_filesz field of the program_header of the target file to the quantum software loader size.

[0156] In one embodiment, the data segment includes a fileinfo structure and a streamcihper structure;

[0157] The fileinfo structure stores the size of the target file and the program entry address of the target file;

[0158] The streamcihper structure stores the ID value of the stream key and the length of the code segment.

[0159] In one embodiment, the data encryption module 13 is specifically used to: send the ID value of the protection key, the fileinfo structure and the streamcihper structure to the cryptographic component, so that the cryptographic component obtains the corresponding protection key based on the ID value of the protection key to encrypt the fileinfo structure and the streamcihper structure to obtain the fileinfo ciphertext and the streamcihper ciphertext.

[0160] In one embodiment, the file modification module is further used to perform the following steps:

[0161] Write the version number, manufacturer information and ID value of the protection key of the quantum software loader into the softinfo structure, and insert the softinfo structure after the ciphertext address of the data segment;

[0162] Modify the program entry address in the target file to the first address of the binary code.

[0163] It should be noted that other embodiments or implementation methods of the quantum cryptographic packer of the present invention may refer to the above-mentioned method embodiment 1, which will not be repeated here.

[0164] Example 4

[0165] like Figure 6 As shown, the fourth embodiment of the present invention proposes a software packing system based on a quantum random number entropy source, the system includes a quantum cryptographic packer 1, a cryptographic component 3 and a quantum random number entropy source 4, the cryptographic component 3 and the quantum random number entropy source 4 are both connected to the quantum cryptographic packer 1, and the quantum cryptographic packer 1 includes:

[0166] A key acquisition module 11, used to obtain a protection key and a stream key from the quantum random number entropy source, and store the protection key in the cryptographic component;

[0167] A stream encryption module 12, used to perform stream encryption processing on the code segment plaintext in the target file using the stream key, and overwrite the code segment plaintext in the target file with the obtained code segment ciphertext;

[0168] The data encryption module 12 is used to send the ID value of the protection key and the data segment to the cryptographic component, so that the cryptographic component obtains the corresponding protection key to encrypt the data segment;

[0169] The file reconstruction module 14 is used to receive the data segment ciphertext returned by the cryptographic component and write it into the binary encoding address of the target file.

[0170] It should be noted that the quantum random number entropy source is a cryptographic device that provides a high-security, high-performance true random number source, a fast random number generation rate, and a large-capacity secure storage area; the national secret algorithm cryptographic component is a cryptographic device with built-in national secret algorithm SM2 / SM3 / SM4 and a secure storage area function; the quantum cryptographic sheller is in the form of independent executable software, which shells the protected executable files, implements SM4 symmetric encryption protection on the shelled key information, and implements stream encryption protection on the code segments.

[0171] Specifically, the workflow of the software packing system based on quantum random number entropy source is as follows:

[0172] (1) Obtain a 128-bit random number sequence from a quantum random number entropy source.

[0173] (2) Enter the protection key into the password component and return the key ID value.

[0174] (3) Insert the quantum software loader section_header information into ELF and move the original section_header up.

[0175] (4) Modify the section_header offset value of the ELF file header.

[0176] (5) Get the length of the code segment in ELF.

[0177] (6) Embed the binary code of the quantum software loader into the address after the code segment.

[0178] (7) Modify the p_filesz field of program_header and change the value to the size of the quantum software loader.

[0179] (8) Initialize the softinfo structure (to store the shell version number, manufacturer information, key ID value), fileinfo structure (to store the file size, ELF program entry address), and streamcihper (to store the stream cipher ID value and code segment length).

[0180] (9) According to the length of the code segment, a stream key of the same length is obtained from the quantum random number entropy source, and an XOR operation is performed bit by bit with the segment plaintext, and the operation result overwrites the original plaintext.

[0181] (10) The stream key is stored in the secure storage area of ​​the quantum random number entropy source and the stream key ID value is returned.

[0182] (11) Write the code segment length and stream key ID into the streamcihper structure;

[0183] (12) Get the elf entry address and ELF file size and write them into the fileinfo structure;

[0184] (13) Pass the protection key ID value, fileinfo, and streamcihper data structures to the national secret cryptographic component, complete the SM4 encryption operation inside the component, and write the ciphertext returned by the component into the binary encoding address of the quantum software loader.

[0185] (14) Write the quantum software loader version, manufacturer information, and protection key ID value into the softinfo structure, and insert softinfo after the fileinfo and streamcihper ciphertext addresses.

[0186] (15) Modify the e_entry field of elf_header and change the entry address to the first address of the binary code of the quantum software loader.

[0187] It should be noted that other embodiments or implementation methods of the software shell system based on the quantum random number entropy source of the present invention can refer to the above-mentioned embodiment 1 and embodiment 3, which will not be repeated here.

[0188] Example 5

[0189] like Figure 7 As shown, the fifth embodiment of the present invention proposes a quantum software loader, which specifically includes:

[0190] The file recording module 21 is used to load the packed target file and migrate the code segment ciphertext, data segment ciphertext and softinfo structure in the target file from the memory space of the target file to the first memory space;

[0191] The data decryption module 22 is used to send the ID value of the protection key carried in the softinfo structure and the data segment ciphertext to the cryptographic component, so that the cryptographic component obtains the corresponding protection key to decrypt the data segment ciphertext to obtain the data segment plaintext;

[0192] A stream key request module 23, configured to receive the data segment plaintext and obtain a corresponding stream key based on an ID value of the stream key carried in the data segment plaintext;

[0193] The code decryption module 24 is used to decrypt the code segment ciphertext using the stream key, and copy the decrypted code segment plaintext to the memory space of the target file.

[0194] In this embodiment, after the system loads the packed target file, the entry address jumps to the initialization segment code, which is responsible for internal data migration, migrating the data from the memory space of the target file to the first memory space, and jumping to the core segment execution, completing the decryption of the relevant data structure and the decryption of the code segment, and restoring the data in the ELF memory space.

[0195] In one embodiment, the data segment ciphertext includes fileinfo ciphertext and streamcihper ciphertext, and the data segment plaintext includes fileinfo structure and streamcihper structure;

[0196] The fileinfo structure stores the size of the target file and the program entry address of the target file;

[0197] The streamcihper structure stores the ID value of the stream key and the length of the plaintext of the code segment.

[0198] In one embodiment, the stream key request module 23 specifically includes:

[0199] A request unit, configured to send the ID value of the stream key stored in the streamcihper structure to a quantum random number entropy source, so that the quantum random number entropy source obtains the corresponding stream key based on the ID value of the stream key;

[0200] A key receiving unit is used to receive the stream key returned by the quantum random number entropy source.

[0201] In one embodiment, the quantum software loader further includes a space release module, which is specifically used to:

[0202] When the plaintext acquisition of the data segment fails, the first memory space is released and an error is reported.

[0203] In one embodiment, the space release module is further used to release the first memory space after the code segment plaintext is decrypted by the code decryption module 24; jump back to the program entry address of the target file, and execute the code segment plaintext.

[0204] It should be noted that other embodiments or implementation methods of the quantum software loader of the present invention can refer to the above-mentioned method embodiment 2, which will not be repeated here.

[0205] Example 6

[0206] like Figure 8 As shown, the sixth embodiment of the present invention proposes a software unpacking system based on a quantum random number entropy source, the system comprising a quantum software loader 2, a cryptographic component 3 and a quantum random number entropy source 4, the cryptographic component 3 and the quantum random number entropy source 4 are both connected to the quantum software loader 2, and the quantum software loader 2 comprises:

[0207] The file recording module 21 is used to load the packed target file and migrate the code segment ciphertext, data segment ciphertext and softinfo structure in the target file from the memory space of the target file to the first memory space;

[0208] The data decryption module 22 is used to send the ID value of the protection key carried in the softinfo structure and the data segment ciphertext to the cryptographic component, so that the cryptographic component obtains the corresponding protection key to decrypt the data segment ciphertext to obtain the data segment plaintext;

[0209] A stream key request module 23, configured to request a corresponding stream key from the quantum random number entropy source based on an ID value of the stream key carried in plain text in the data segment;

[0210] The code decryption module 24 is used to decrypt the code segment ciphertext using the stream key, and copy the decrypted code segment plaintext to the memory space of the target file.

[0211] It should be noted that the quantum software loader solidifies a binary code sequence into the ELF when it is packed; it is loaded first at runtime, completes the decryption of the packed key information and the restoration of the code segment, and jumps to the real entry address of the ELF file for execution.

[0212] The specific workflow of the software unpacking system based on the quantum random number entropy source proposed in this embodiment is as follows:

[0213] (1) Jump to the entry address of the loader code and execute the code content including steps (2) to (3).

[0214] (2) Memory mmap maps out the first memory space, and migrates the softinfo, fileinfo ciphertext, streamcihper ciphertext, code segment ciphertext, and the core segment code of the loader from the current memory space to the first memory space.

[0215] (3) Jump to the first address of the loader core segment code in the first memory space, and execute the content including: (4) to (8).

[0216] (4) Read the softinfo information, pass the protection key ID value, fileinfo ciphertext, and streamcihper ciphertext to the national secret cryptographic component; use the fileinfo and streamcihper plaintext returned by the cryptographic component to overwrite the original data. If the operation is successful, continue to (5). If the operation fails, release the first memory space, report an error, and end the process.

[0217] (5) Read fileinfo, streamcihper data, pass the stream key ID to the quantum random number entropy source, and read the stream cipher into the first memory space.

[0218] (6) Use the stream cipher to perform bitwise XOR operation on the code segment and copy the result back to the ELF memory space.

[0219] (7) Release the first memory space.

[0220] (8) Jump back to the program entry address of the ELF memory space and execute the code segment.

[0221] It should be noted that other embodiments or implementation methods of the software unpacking system based on the quantum random number entropy source of the present invention can refer to the above-mentioned Embodiment 2 and Embodiment 5, which will not be repeated here.

[0222] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "examples", "specific examples", or "some examples" means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner.

[0223] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In the description of the present invention, the meaning of "plurality" is at least two, such as two, three, etc., unless otherwise clearly and specifically defined.

[0224] Although the embodiments of the present invention have been shown and described above, it is to be understood that the above embodiments are exemplary and are not to be construed as limitations of the present invention. A person skilled in the art may change, modify, replace and vary the above embodiments within the scope of the present invention.

Claims

1. A software shelling method based on quantum random number entropy source, characterized in that: The shelling method comprises: Obtaining a protection key and a stream key, and storing the protection key in a cryptographic component, wherein both the protection key and the stream key are random numbers; Using the stream key to perform stream encryption on the code segment plaintext in the target file, and overwriting the code segment plaintext in the target file with the obtained code segment ciphertext; Sending the ID value of the protection key and the data segment to the cryptographic component, so that the cryptographic component obtains the corresponding protection key to encrypt the data segment; After receiving the data segment ciphertext returned by the cryptographic component and writing it into the binary encoding address of the target file; The obtaining of the protection key and the stream key, and storing the protection key in the cryptographic component, comprises: Obtaining a random number from a quantum random number entropy source as the protection key, and storing the protection key in the cryptographic component; Receiving the ID value of the protection key returned by the cryptographic component; Obtaining a random number having the same length as the code segment in the target file from the quantum random number entropy source as the stream key, and storing the stream key in the quantum random number entropy source; Receive the ID value of the stream key returned by the quantum random number entropy source.

2. The software shelling method based on quantum random number entropy source as claimed in claim 1, characterized in that: Before obtaining a random number having the same length as the code segment in the target file from the quantum random number entropy source as the stream key, the shelling method further includes: Inserting the section_header information of the quantum software loader into the target file, and moving the section_header information of the target file upward; Modify the section_header offset value of the target file header; Obtaining the length of the code segment in the target file, and embedding the binary code of the quantum software loader into the address position after the code segment; Modify the p_filesz field of the program_header of the target file to the quantum software loader size.

3. The software shelling method based on quantum random number entropy source as claimed in claim 1, characterized in that: The data segment includes a fileinfo structure and a streamcihper structure; The fileinfo structure stores the size of the target file and the program entry address of the target file; The streamcihper structure stores the ID value of the stream key and the length of the code segment.

4. The software shelling method based on quantum random number entropy source as claimed in claim 3, characterized in that: Sending the ID value of the protection key and the data segment to the cryptographic component so that the cryptographic component obtains the corresponding protection key to encrypt the data segment includes: The ID value of the protection key, the fileinfo structure and the streamcihper structure are sent to the cryptographic component, so that the cryptographic component obtains the corresponding protection key based on the ID value of the protection key to encrypt the fileinfo structure and the streamcihper structure to obtain the fileinfo ciphertext and the streamcihper ciphertext.

5. The software shelling method based on quantum random number entropy source as claimed in claim 2, characterized in that: After receiving the data segment ciphertext returned by the cryptographic component and writing it into the binary encoding address of the target file, the shelling method further includes: Write the version number, manufacturer information and ID value of the protection key of the quantum software loader into the softinfo structure, and insert the softinfo structure after the ciphertext address of the data segment; Modify the program entry address in the target file to the first address of the binary code.

6. A software unpacking method based on quantum random number entropy source, characterized in that: The deshelling method comprises: Loading the packed target file, migrating the code segment ciphertext, data segment ciphertext and softinfo structure in the target file from the memory space of the target file to the first memory space; Sending the ID value of the protection key carried in the softinfo structure and the data segment ciphertext to the cryptographic component, so that the cryptographic component obtains the corresponding protection key to decrypt the data segment ciphertext to obtain the data segment plaintext, wherein the cryptographic component stores the protection key, and the protection key is a random number obtained from a quantum random number entropy source; Receiving the data segment plaintext, and acquiring a corresponding stream key based on an ID value of the stream key carried in the data segment plaintext; Decrypting the code segment ciphertext using the stream key, and copying the decrypted code segment plaintext to the memory space of the target file; The data segment ciphertext includes fileinfo ciphertext and streamcihper ciphertext, and the data segment plaintext includes fileinfo structure and streamcihper structure; the fileinfo structure stores the size of the target file and the program entry address of the target file; the streamcihper structure stores the ID value of the stream key and the length of the code segment plaintext; The receiving the data segment plaintext and acquiring the corresponding stream key based on the ID value of the stream key carried in the data segment plaintext includes: Based on the ID value of the stream key stored in the streamcihper structure, the stream key is sent to the quantum random number entropy source, so that the quantum random number entropy source obtains the corresponding stream key based on the ID value of the stream key; Receive the stream key returned by the quantum random number entropy source.

7. The software unpacking method based on quantum random number entropy source as claimed in claim 6, characterized in that: When the plaintext acquisition of the data segment fails, the first memory space is released and an error is reported.

8. The software unpacking method based on quantum random number entropy source as claimed in claim 6, characterized in that: After decrypting the code segment ciphertext by using the stream key and copying the decrypted code segment plaintext to the memory space of the target file, the unpacking method further includes: releasing the first memory space; Jump back to the program entry address of the target file and execute the plain text of the code segment.

9. A quantum cryptographic packer, characterized in that: include: A key acquisition module, used for acquiring a protection key and a stream key, and storing the protection key in a cryptographic component, wherein both the protection key and the stream key are random numbers; A stream encryption module, used for performing stream encryption processing on the plain text of the code segment in the target file using the stream key, and overwriting the plain text of the code segment in the target file with the obtained ciphertext of the code segment; A data encryption module, used for sending the ID value of the protection key and the data segment to the cryptographic component, so that the cryptographic component obtains the corresponding protection key to encrypt the data segment; A file reconstruction module, used for receiving the ciphertext of the data segment returned by the cipher component and writing it into the binary encoding address of the target file; The key acquisition module specifically includes: A first key acquisition unit, configured to acquire a random number from a quantum random number entropy source as the protection key, and store the protection key in the cryptographic component; A first ID receiving unit, used to receive the ID value of the protection key returned by the password component; A second key acquisition unit is used to obtain a random number having the same length as the code segment in the target file from the quantum random number entropy source as the stream key, and store the stream key in the quantum random number entropy source; The second ID receiving unit is used to receive the ID value of the stream key returned by the quantum random number entropy source.

10. A software packing system based on quantum random number entropy source, characterized in that: The system comprises the quantum cryptographic packer as claimed in claim 9, a cryptographic component and a quantum random number entropy source, wherein the cryptographic component and the quantum random number entropy source are both connected to the quantum cryptographic packer, and the quantum cryptographic packer comprises A key acquisition module, used to acquire a protection key and a stream key from the quantum random number entropy source, and store the protection key in the cryptographic component; A stream encryption module, used for performing stream encryption processing on the plain text of the code segment in the target file using the stream key, and overwriting the plain text of the code segment in the target file with the obtained ciphertext of the code segment; A data encryption module, used for sending the ID value of the protection key and the data segment to the cryptographic component, so that the cryptographic component obtains the corresponding protection key to encrypt the data segment; The file reconstruction module is used to receive the ciphertext of the data segment returned by the password component and write it into the binary encoding address of the target file.

11. A quantum software loader, characterized in that: include: A file recording module is used to load the packed target file, and migrate the code segment ciphertext, data segment ciphertext and softinfo structure in the target file from the memory space of the target file to the first memory space; A data decryption module, used for sending the ID value of the protection key carried in the softinfo structure and the data segment ciphertext to the cryptographic component, so that the cryptographic component obtains the corresponding protection key to decrypt the data segment ciphertext to obtain the data segment plaintext, wherein the cryptographic component stores the protection key, and the protection key is a random number obtained from a quantum random number entropy source; A stream key request module, configured to receive the data segment plaintext, and obtain a corresponding stream key based on an ID value of the stream key carried in the data segment plaintext; A code decryption module, used to decrypt the code segment ciphertext using the stream key, and copy the decrypted code segment plaintext to the memory space of the target file; The data segment ciphertext includes fileinfo ciphertext and streamcihper ciphertext, and the data segment plaintext includes fileinfo structure and streamcihper structure; the fileinfo structure stores the size of the target file and the program entry address of the target file; the streamcihper structure stores the ID value of the stream key and the length of the code segment plaintext; Wherein, the stream key request module specifically includes: A request unit, configured to send the ID value of the stream key stored in the streamcihper structure to a quantum random number entropy source, so that the quantum random number entropy source obtains the corresponding stream key based on the ID value of the stream key; A key receiving unit is used to receive the stream key returned by the quantum random number entropy source.

12. A software unpacking system based on quantum random number entropy source, characterized in that: The system comprises the quantum software loader, a cryptographic component and a quantum random number entropy source as claimed in claim 11, wherein the cryptographic component and the quantum random number entropy source are both connected to the quantum software loader, and the quantum software loader comprises: A file recording module is used to load the packed target file, and migrate the code segment ciphertext, data segment ciphertext and softinfo structure in the target file from the memory space of the target file to the first memory space; A data decryption module, used for sending the ID value of the protection key carried in the softinfo structure and the data segment ciphertext to the cryptographic component, so that the cryptographic component obtains the corresponding protection key to decrypt the data segment ciphertext to obtain the data segment plaintext; A stream key request module, configured to request a corresponding stream key from the quantum random number entropy source based on an ID value of the stream key carried in plain text in the data segment; The code decryption module is used to decrypt the code segment ciphertext using the stream key, and copy the decrypted code segment plaintext to the memory space of the target file.

Citation Information

Patent Citations

  • Protecting method for packing executable program

    CN102609666A

  • Program code encryption and decryption method and device

    CN112597453A

  • A method and system for program stream secret key encryption in mobile multi-media broadcasting service

    CN101146209A

  • Method and device for protecting source code of executable file

    CN102136053A