A method and device for protecting configuration files
By performing multi-layer encryption processing on the configuration files, including obfuscation of the first key and encryption of the second key, the shortcomings of configuration file protection in the prior art are solved, and high-security configuration file protection is achieved, and the problems of single point of dependence and key leakage are avoided.
Patent Information
- Application Number
- CN201910327878.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2019-04-23
- Publication Date
- 2025-03-18
- Estimated Expiration
- 2039-04-23
AI Technical Summary
The prior art is difficult to effectively protect configuration files, especially in decompilation cases, where attackers can obtain the encryption key of the configuration files through the source files, and there is a single point of dependency problem in a unified online configuration center.
By generating the first key, encrypting the configuration file, obfuscating the first key to generate the first file, and then encrypting the first file with the second key to ensure that the key and its generation and protection methods do not appear in the source and execution files of the program.
Multi-layer encryption protection of configuration files is realized, improving its security, and avoiding the single point of dependency problem in online configuration centers and the risk of decompiling and obtaining keys.
Smart Images

Figure CN111831978B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of Internet, and in particular to a method and device for protecting configuration files. Background Art
[0002] Generally speaking, the configuration file of a program is crucial to the operation of the program. For example, the configuration file contains the configuration information necessary for the program to start or run normally; for example, the configuration information includes sensitive information such as user account and user password. Therefore, in order to prevent attackers from invading the corresponding program by obtaining the configuration information in the configuration file - for example, the program about accessing the database, thereby causing the data information involved in the program to be leaked, certain protection measures need to be taken for the configuration file.
[0003] Currently, there are two common ways to protect configuration files: one is to encrypt the configuration files or the configuration information therein in the application code of the program; the other is to establish a unified online configuration center to dynamically obtain these important configuration information online.
[0004] However, the inventors found in actual application that the above-mentioned method of encrypting the configuration file is difficult to cope with attacks, especially when the server where the program is running is attacked. The attacker can obtain the source file (for example, the source code file ending with .java and written in JAVA language) by decompiling the binary code when the program is running, and then crack the encryption key of the configuration file; and the unified online configuration center usually has the problem of single point dependence, that is, once the configuration center fails, all programs will not be able to run normally. Summary of the invention
[0005] In view of this, an embodiment of the present invention provides a method and device for protecting a configuration file, which implements the protection of the configuration file in an offline manner, that is, the key of the configuration file, the method for generating the key, and the method for protecting the key do not appear in the source file and the execution file of the program, thereby not only avoiding the problem of single-point dependence on the online configuration center, but also avoiding the problem of obtaining the encryption key of the configuration file through the source file in the case of decompilation.
[0006] To achieve the above-mentioned purpose, according to a first aspect of an embodiment of the present invention, a method for protecting a configuration file is provided, and the specific steps include: generating a first key, and using the first key to encrypt the configuration file; obfuscating the first key and generating a first file, wherein the first file indicates how to convert the first key into the obfuscated first key; generating a second key, and using the second key to encrypt the first file.
[0007] Optionally, the first key is discarded, and the original plaintext configuration file is deleted.
[0008] Optionally, the first file is a lookup table file, which records the correspondence between the first key and the obfuscated first key.
[0009] Optionally, the first file is decrypted according to the second key, and the first key is obtained according to the decrypted first file; and the configuration file is decrypted according to the first key.
[0010] Optionally, the second key is a digital summary generated according to the trusted environment information when the program corresponding to the configuration file is running.
[0011] Optionally, the environmental information includes one or more of the following: the programming language used by the program corresponding to the configuration file, the version of the programming language, dependency path information of the programming language, one or more executable files called by the program corresponding to the configuration file, one or more source files used by the program corresponding to the configuration file, and library information loaded by the program corresponding to the configuration file.
[0012] Optionally, the environmental information further includes one or more of the following: an IP address, a MAC address, a name of an operating system, and a version of an operating system when the program corresponding to the configuration file is running.
[0013] Optionally, the environmental information also includes process information when the program corresponding to the configuration file is running, and the process information includes one or more of the following: the user of the process, the permissions of the process, the parent process name of the process, the files involved when the process is running, and the port of the process to which it belongs.
[0014] To achieve the above-mentioned purpose, according to the second aspect of an embodiment of the present invention, there is provided a device for protecting a configuration file, comprising: a first encryption module, a first file generation module, and a second encryption module, wherein: the first encryption module is used to generate a first key, and use the first key to encrypt the configuration file; the first file generation module is used to obfuscate the first key and generate a first file, and the first file indicates how to convert the first key into the obfuscated first key; the second encryption module is used to generate a second key, and use the second key to encrypt the first file.
[0015] Optionally, the first encryption module is further used to discard the first key and delete the original plaintext configuration file.
[0016] Optionally, the first file is a lookup table file, which records the correspondence between the first key and the obfuscated first key.
[0017] Optionally, it also includes: a first decryption module and a second decryption module, wherein the second decryption module is used to decrypt the first file according to the second key and obtain the first key according to the decrypted first file; the first decryption module is used to decrypt the configuration file according to the first key.
[0018] Optionally, the second key is a digital summary generated according to the trusted environment information when the program corresponding to the configuration file is running.
[0019] Optionally, the environmental information includes one or more of the following: the programming language used by the program corresponding to the configuration file, the version of the programming language, dependency path information of the programming language, one or more executable files called by the program corresponding to the configuration file, one or more source files used by the program corresponding to the configuration file, and library information loaded by the program corresponding to the configuration file.
[0020] Optionally, the environmental information further includes one or more of the following: an IP address, a MAC address, a name of an operating system, and a version of an operating system when the program corresponding to the configuration file is running.
[0021] Optionally, the environmental information also includes process information when the program corresponding to the configuration file is running, and the process information includes one or more of the following: the user of the process, the permissions of the process, the parent process name of the process, the files involved when the process is running, and the port of the process.
[0022] To achieve the above-mentioned purpose, according to a third aspect of an embodiment of the present invention, a server for protecting a configuration file is provided, comprising: one or more processors; a storage device for storing one or more programs, and when the one or more programs are executed by the one or more processors, the one or more processors implement any of the methods for protecting the configuration file as described above.
[0023] To achieve the above objective, according to a fourth aspect of an embodiment of the present invention, a computer-readable medium is provided, on which a computer program is stored, and when the program is executed by a processor, any of the above configuration file protection methods is implemented.
[0024] An embodiment of the above invention has the following advantages or beneficial effects: by using multiple encryption protection means such as encrypting the configuration file with a first key, obfuscating the first key and generating a first file, and further encrypting the first file with another key (second key), the security of the configuration file is greatly improved, while avoiding the problem of single-point dependence of the online configuration center in the prior art, and the problem of obtaining the encryption key of the configuration file through the source file in the case of decompilation.
[0025] The further effects of the above-mentioned non-conventional optional manner will be described below in conjunction with the specific implementation manner. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] The accompanying drawings are used to better understand the present invention and do not constitute an improper limitation of the present invention.
[0027] Figure 1 It is a schematic diagram of basic steps of a method for protecting a configuration file provided according to an embodiment of the present invention;
[0028] Figure 2 is a schematic diagram of basic steps of a method for protecting a configuration file provided according to another embodiment of the present invention;
[0029] Figure 3a It is a schematic diagram of an application of encrypting a configuration file provided by an embodiment of the present invention;
[0030] Figure 3b is an application schematic diagram of decryption to obtain a configuration file provided by an embodiment of the present invention;
[0031] Figure 4 is a schematic diagram of the structure of an apparatus for protecting a configuration file provided according to an embodiment of the present invention;
[0032] Figure 5 is an exemplary system architecture diagram to which embodiments of the present invention may be applied;
[0033] Figure 6 It is a schematic diagram of the structure of a computer system of a terminal device or a server suitable for implementing an embodiment of the present invention. DETAILED DESCRIPTION
[0034] The following is a description of exemplary embodiments of the present invention in conjunction with the accompanying drawings, including various details of the embodiments of the present invention to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, for clarity and conciseness, the description of well-known functions and structures is omitted in the following description.
[0035] See also Figure 1 The embodiment of the present invention provides a method for protecting a configuration file, and the specific steps include:
[0036] Step S101: Generate a first key, and use the first key to encrypt a configuration file.
[0037] The configuration file contains necessary information required for the program to run, such as database account, database password, etc., and such information is not suitable to be written directly into the source code in plain text. It is understandable that since the program configuration file contains extremely important and confidential information such as user account and user password, in order to prevent the configuration file from being misappropriated by others and then invading the program and other information involved in the program (for example, database information), certain protection measures need to be taken for the configuration file.
[0038] In this embodiment, the configuration file is encrypted using a first key. Among them, a key in a symmetric encryption algorithm can be used as the first key, that is, the first key is used for both encrypting and decrypting the configuration file. It is understandable that the present application is not limited to this. For example, a public key in an asymmetric encryption algorithm can also be used as the first key, that is, the first key is used to encrypt the configuration file, and accordingly, a private key corresponding to the first key is used to decrypt the configuration file. In the present application, in order to improve the security of the configuration file, preferably, the configuration file is encrypted using a key in a symmetric encryption algorithm. In this case, only the first key used for encryption can be used to decrypt the configuration file. In addition, the security of the configuration file can also be improved by increasing the difficulty of cracking the first key, for example, using a randomly generated random number, a pseudo-random number, etc. that is not easily guessed by others as the first key.
[0039] Step S102: obfuscate the first key and generate a first file, wherein the first file indicates how to convert the first key into the obfuscated first key.
[0040] With the improvement of computing power, the first key may be cracked, especially when an attacker breaks into the server where the program corresponding to the configuration file is running. The configuration file can be obtained by static analysis, for example, by decompiling the binary code when the program is running to obtain the source file, and then cracking the encryption key of the configuration file, that is, the first key in this embodiment, and then obtaining the configuration information in the configuration file to invade the corresponding program. Therefore, in order to deal with attacks and improve the security of the configuration file, it is necessary to further reduce the possibility of the configuration file encryption key being cracked or leaked.
[0041] Based on this, the first key is further processed by white box encryption; the common implementation method of the white box encryption is to confuse the first key with an obfuscation algorithm and generate a first file. The first file indicates the program fragment for obfuscating encryption or decryption of the first key, and different first keys correspond to different generated program fragments, and usually the program fragment exists in the form of a library file. Since the calculation process of generating program fragments is public, this process is also called white box encryption. In one embodiment, the first file is a lookup table file, and the lookup table file records the correspondence between the first key and the first key after obfuscation. In other words, the first key and the output corresponding to it are recorded in the lookup table file, so that the first key can be obtained according to the output; that is, the first file records the correspondence between the input data (for example, the first key) and the output data (the first key after obfuscation). It can be seen that the original key can be completely hidden through this table. Due to the large amount of obfuscation in the first file, it is difficult for an attacker to extract the correct first key from the first file, and the first file caller can obtain the first key by correctly using the first file, thereby decrypting the configuration file, thereby greatly reducing the possibility of the first key being cracked.
[0042] It is understandable that the first file in the present application is not limited to the above-mentioned lookup table file. For example, the first file may also be another program that records an algorithm for how to obfuscate the first key into a corresponding output. For example, the first file may record a function y=f(x), where x represents the first key as input data, f(·) represents the calculation performed on x, and y represents the obfuscated first key as output data.
[0043] Step S103: Generate a second key, and use the second key to encrypt the first file.
[0044] Since the legitimacy of the identity of the caller of the first file cannot be identified, in order to prevent the first file from being illegally called, the second key can be used to encrypt the first file. In one embodiment, the key in the symmetric encryption algorithm can be used as the second key, that is, the second key is used to encrypt the first file and also to decrypt the first file. It can be understood that the present application is not limited to this. For example, the public key in the asymmetric encryption algorithm can also be used as the second key, that is, the second key is used to encrypt the first file, and accordingly, the private key corresponding to the second key is used to decrypt the first file. In the present application, in order to improve the security of the first file, preferably, the key in the symmetric encryption algorithm is used to encrypt the first file. In this case, only the second key used for encryption can be used to decrypt the first file. The second key can be a randomly generated key or a highly secure key calculated according to a set rule. When and only when the caller of the first file obtains the correct second key or the decryption key corresponding to the second key, the first file can be called normally, thereby further improving the security of the first file.
[0045] In one embodiment, the second key is a digital digest generated according to the trusted environment information when the program corresponding to the configuration file is running.
[0046] The digital summary is to convert a message of any length into a short message of fixed length. It is similar to a function whose independent variable is the message. This function is one-way and can "summarize" information of different lengths or contents into a string of short ciphertext information of fixed length. Therefore, the digital summary has a fixed length, and the results of different plaintext summaries into ciphertexts are always different, while the summaries of the same plaintext must be consistent. The trusted environment information refers to the corresponding environment information under normal operation when the user who starts the program is a legitimate user and the program is not attacked by an attacker.
[0047] In an optional implementation, the environment information may include one or more of the following: the programming language used by the program corresponding to the configuration file, the version of the programming language, the dependency path information of the programming language, one or more executable files called by the program corresponding to the configuration file, one or more source files used by the program corresponding to the configuration file, and library information loaded by the program corresponding to the configuration file. Among them, the executable file refers to a file that can be loaded and executed by the operating system. In different operating systems or operating environments, the execution method of the executable program is different.
[0048] Furthermore, taking the programming language used as Java as an example, the information indicated by javaclasspath or javaclasspath in the trusted environment information, such as library information, path information and other file information, can be collected, and the digital summary of the trusted environment information containing the above collected information can be calculated to obtain the second key. Since an illegal attacker usually uses the Java language on the server owned by the attacker to call the first file when attacking in the environment where the program corresponding to the configuration file is running, and the information indicated by javaclasspath and javaclasspath in the current environment information used by the attacker is inconsistent with the information indicated by javaclasspath and javaclasspath in the trusted environment information when generating the second key, the correct second key cannot be obtained. Therefore, this implementation can greatly reduce the possibility of the first file being illegally called.
[0049] In an optional implementation, the environment information also includes one or more of the following: the IP address, MAC address, name of the operating system, and version of the operating system when the program corresponding to the configuration file is running. Specifically, the programming language used is still java as an example for explanation: if the attacker takes the program corresponding to the entire configuration file out of the environment in which the program is running and then attacks, the information indicated by javaclasspath or javaclasspath can be completely copied. Therefore, only by collecting the trusted environment information containing the information indicated by javaclasspath or javaclasspath to obtain the second key, it is impossible to prevent the first file from being illegally called when it is attacked. However, it can be noted that when it is attacked, one or more of the IP address, MAC address, name of the operating system, and version of the operating system corresponding to the program when it is running will change. Therefore, the digital summary of the IP address, MAC address, name of the operating system, and version of the operating system when the program corresponding to the configuration file in the trusted environment information is used as the second key to further prevent the first file from being illegally called.
[0050] In an optional embodiment, the environmental information also includes process information of the program corresponding to the configuration file when it is running, and the process information includes one or more of the following: the user of the process, the permissions of the process, the parent process name of the process, the files involved in the operation of the process, and the port of the process.
[0051] It is understandable that the environment information may also include any combination of one or more of the above environment information. For example, the environment information may include one or more executable files called by the program corresponding to the configuration file, one or more source files used by the program corresponding to the configuration file, and process information when the program corresponding to the configuration file is running.
[0052] In the case of collecting trusted environment information and calculating the digital summary of the trusted environment information as the second key, if an attacker attempts to copy the running program from the memory of the server where it is located to another server to obtain the configuration information included in the configuration file, it will cause one or more information in the environment information when the program is copied and then run to change, that is, the current environment information when the program is running is inconsistent with the trusted environment information when the program is running. Therefore, the attacker cannot obtain the correct second key by calculating the digital summary of the current environment information, and the first file cannot be decrypted by the attacker. In addition, even if the attacker illegally invades the server where the program is running, it is impossible to obtain the complete environment information used to generate the second key, such as one or more executable files called by the program corresponding to the configuration file, etc. Therefore, by using the digital summary of the trusted environment information as the second key, any change in the environment information will result in the inability to correctly decrypt the first file, which can greatly increase the difficulty of cracking the second key.
[0053] It is worth noting that when the configuration file is encrypted and the first key is obfuscated to generate the first file, the randomly generated first key is discarded and the original plaintext configuration file is deleted, so that any subsequent person or attacker cannot obtain the plaintext configuration file or the first key from the program or code, and can only obtain the encrypted configuration file. When the first file is further encrypted, the generated second key is also discarded synchronously. Therefore, anyone, whether a legitimate user or an illegal attacker, who wants to normally start or invade the program corresponding to the configuration file, needs to crack the encryption keys corresponding to the first file and the configuration file one by one to obtain the correct configuration information, and then start the program corresponding to the configuration file.
[0054] In summary, in this embodiment, the configuration file is first encrypted using the first key; then the first key is obfuscated according to the obfuscation algorithm, and the first file, such as a lookup table file, is used to record the correspondence between the first key and the obfuscated first key; finally, the first file is encrypted using the second key. It is worth noting that the generation method of the first file and the second key does not appear at all in the source file and the execution file of the program corresponding to the configuration file, which makes the (first) key of the configuration file, the generation method of the key, and the protection method of the key not appear in the source file and the execution file of the program, thereby greatly improving the security protection of the configuration file. This protection method of encrypting the configuration file twice greatly improves the security of the configuration file under a purely offline protection mechanism, thereby not only avoiding the problem of single-point dependence on the online configuration center, but also avoiding the problem of obtaining the encryption key of the configuration file through the source file in the case of decompilation.
[0055] See also Figure 2 Based on the above embodiment, the embodiment of the present invention provides a method for protecting a configuration file, and the specific steps are as follows:
[0056] Step S201: decrypt the first file according to the second key, and obtain the first key according to the decrypted first file.
[0057] Since the first key, the second key and the original plaintext configuration file are deleted when the configuration file is encrypted for protection, the user needs to obtain the corresponding decryption key, decrypt the first file, and then decrypt the configuration file to start the program corresponding to the configuration file normally. Therefore, the first file caller needs to first collect the current environment information of the program running corresponding to the configuration file and calculate the corresponding digital summary as the decryption key of the first file, and then decrypt the first file. It can be understood that the first file can be encrypted by using a symmetric encryption algorithm or an asymmetric encryption algorithm. In this application, in order to improve the security of the first file, preferably, the first file is encrypted using the key in the symmetric encryption algorithm. In this case, only the second key used for encryption can be used to decrypt the first file, and then the first key confused in the first file can be extracted by correctly using the first file. If the correct first file decryption key cannot be obtained, the first file cannot be decrypted, and the program corresponding to the configuration file fails to start.
[0058] In an optional implementation, one or more of the following information in the current environment information is collected: the programming language used by the program corresponding to the configuration file, the version of the programming language, the dependent path information of the programming language, one or more executable files called by the program corresponding to the configuration file, one or more source files used by the program corresponding to the configuration file, and the library information loaded by the program corresponding to the configuration file, and a digital summary of the collected environment information is calculated as a decryption key to decrypt the first file. Specifically, taking the programming language used as java as an example, the javaclasspath or information indicated by the javaclasspath in the current environment information, such as library information, path information and other file information, can be collected, and a digital summary of the trusted environment information containing the above-collected information is calculated as a decryption key to decrypt the first file. If and only if the decryption key is consistent with the second key, that is, when the current environment information is consistent with the trusted environment information, the decryption key can decrypt the first file, otherwise the program corresponding to the configuration file cannot be started.
[0059] In an optional implementation, one or more of the following information is collected from the current environment information: the IP address, MAC address, name of the operating system, and version of the operating system when the program corresponding to the configuration file is running, and a digital summary of the collected environment information is calculated as a decryption key to decrypt the first file. If and only if the decryption key is consistent with the second key, that is, when the current environment information is consistent with the trusted environment information, the decryption key can decrypt the first file, and then the first key hidden in the first file can be extracted by correctly using the first file, otherwise the program corresponding to the configuration file cannot be started.
[0060] In an optional implementation, the following one or more process information in the current environment information is collected: the user of the process, the authority of the process, the name of the parent process of the process, the files involved in the process running, and the port of the process, and the digital summary of the collected environment information is calculated as a decryption key to decrypt the first file. If and only if the decryption key is consistent with the second key, that is, when the current environment information is consistent with the trusted environment information, the decryption key can decrypt the first file, and then the first key hidden in the first file is extracted by correctly using the first file, otherwise the program corresponding to the configuration file cannot be started.
[0061] It is understandable that the collected current environment information can be a combination of any one or more of the above-mentioned environment information, and the combination method should be consistent with the combination method of the trusted environment information collected when generating the second key. For example, the collected current environment information can include one or more executable files called by the program corresponding to the configuration file, one or more source files used by the program corresponding to the configuration file, and process information when the program corresponding to the configuration file is running.
[0062] Step S202: decrypt the configuration file according to the first key.
[0063] It is understandable that the configuration file can be encrypted using either a symmetric encryption algorithm or an asymmetric encryption algorithm. In the present application, in order to improve the security of the configuration file, preferably, the first file is encrypted using a key in a symmetric encryption algorithm. In this case, only the first key used for encryption can be used to decrypt the configuration file. On the basis of correctly using the first file to extract the decryption key hidden therein, the configuration file is decrypted using the decryption key. When and only when the decryption key is consistent with the first key, configuration information such as user account, user password, etc. can be obtained from the configuration file, and then the program corresponding to the configuration file can be started normally, otherwise the program startup fails.
[0064] See also Figure 3a and 3b ,in, Figure 3a is a schematic diagram of an application for encrypting a configuration file provided by an embodiment of the present invention. Figure 3b This is an application schematic diagram of decrypting to obtain a configuration file provided by an embodiment of the present invention. The program corresponding to the configuration file needs to read the configuration file when it is started for the first time or the configuration information is changed. At this time, the configuration file is a plain text configuration file, that is, the original packaged information. Therefore, in order to ensure the security of the configuration file, when the program corresponding to the configuration file is started normally for the first time, the configuration file is encrypted, and the corresponding plain text configuration file and the encryption key are deleted, so that any subsequent startup can only be carried out normally by decrypting and reading the configuration information in the configuration file.
[0065] See also Figure 3a, when the program corresponding to the configuration file is started normally for the first time, on the one hand, in order to ensure that the encryption key has a low guessability, a first key is randomly generated, and the configuration file is encrypted with the first key to generate an encrypted configuration file. It can be understood that the configuration file can be encrypted by using either a symmetric encryption algorithm or an asymmetric encryption algorithm. In order to improve the security of the configuration file, in this embodiment, preferably, a symmetric encryption algorithm is used to encrypt the configuration file, that is, only the first key can decrypt the configuration file. On the other hand, the first key is obfuscated with an obfuscated encryption algorithm to generate the corresponding first file, that is, the first key used to decrypt the configuration file can only be extracted from the first file when the first file is used correctly. Subsequently, the first key is discarded and the original plaintext configuration file, that is, the original packaging information corresponding to the program is deleted, so that users who start the program later can only see the encrypted configuration file.
[0066] Furthermore, in order to ensure the security of the first file, that is, to prevent the first file from being illegally called, the trusted environment information is collected, and the digital summary of the collected trusted environment information is calculated and used as the second key to encrypt the first file. It can be understood that the configuration file can be encrypted using either a symmetric encryption algorithm or an asymmetric encryption algorithm. In order to improve the security of the first file, in this embodiment, preferably, a symmetric encryption algorithm is used to encrypt the first file, that is, only the second key can decrypt the configuration file.
[0067] The collected trusted environment information includes one or more of the following: the programming language used by the program corresponding to the configuration file, the version of the programming language, the dependency path information of the programming language, one or more executable files called by the program corresponding to the configuration file, one or more source files used by the program corresponding to the configuration file, library information loaded by the program corresponding to the configuration file, the IP address, MAC address, name of the operating system, version of the operating system, and process information when the program corresponding to the configuration file is running. Since the first file is encrypted by a symmetric encryption algorithm, only the second key can decrypt the first file. In this way, when an illegal attacker calls the first file, it will inevitably cause one or more of the collected environment information to change, and thus it is impossible to obtain the correct digital summary as the second key to decrypt the first file.
[0068] See also Figure 3b, because the configuration file is encrypted when the program is started for the first time, when the program is started again, it can only be started normally by decrypting the first file and the configuration file. Therefore, it is necessary to collect the current environment information and calculate the digital summary of the collected current environment information as the decryption key to decrypt the first file. It can be understood that in order to obtain the correct decryption key, the collected current environment information should be Figure 3a The content of the environmental information collected when encrypting the first file is consistent with that shown in , and may include one or more of the execution file, process information, operation address, etc. Subsequently, the decryption result of the first file is verified, that is, the digital summary of the current environmental information is determined to be consistent with Figure 3a The digital summary of the trusted environment information calculated in, that is, whether the second key is consistent: if they are consistent, the decryption check is passed, which means that the current running environment is trusted, and the decrypted first file can be used to obtain the first key to decrypt the configuration file, and then start the program normally; if they are inconsistent, it means that the current environment information is inconsistent with the trusted environment information, that is, the first file is illegally called or there is an illegal attack, therefore, the startup of the program is terminated and the intrusion event is reported to the management system.
[0069] See also Figure 4 An embodiment of the present invention provides a device for protecting a configuration file, comprising: a first encryption module 1, a first file generation module 2, and a second encryption module 3, wherein the first encryption module 1 is used to generate a first key and use the first key to encrypt the configuration file; the first file generation module 2 is used to obfuscate the first key and generate a first file, wherein the first file indicates how to convert the first key into the obfuscated first key; the second encryption module 3 is used to generate a second key and use the second key to encrypt the first file.
[0070] In a preferred embodiment, the first encryption module 1 is further used to discard the first key and delete the original plaintext configuration file.
[0071] In a preferred embodiment, the first file is a lookup table file, and the lookup table file records the corresponding relationship between the first key and the obfuscated first key.
[0072] In a preferred embodiment, it also includes: a first decryption module 5 and a second decryption module 4, wherein the second decryption module 4 is used to decrypt the first file according to the second key, and obtain the first key according to the decrypted first file; the first decryption module 5 is used to decrypt the configuration file according to the first key.
[0073] In a preferred embodiment, the second key is a digital summary generated according to the trusted environment information when the program corresponding to the configuration file is running.
[0074] In an optional embodiment, the environmental information includes one or more of the following: the programming language used by the program corresponding to the configuration file, the version of the programming language, dependency path information of the programming language, one or more executable files called by the program corresponding to the configuration file, one or more source files used by the program corresponding to the configuration file, and library information loaded by the program corresponding to the configuration file.
[0075] In an optional implementation, the environmental information further includes one or more of the following: an IP address, a MAC address, a name of an operating system, and a version of an operating system when the program corresponding to the configuration file is running.
[0076] In an optional embodiment, the environmental information also includes process information of the program corresponding to the configuration file when it is running, and the process information includes one or more of the following: the user of the process, the permissions of the process, the parent process name of the process, the files involved in the operation of the process, and the port of the process.
[0077] It is understandable that the environment information may also include any combination of one or more of the above environment information. For example, the environment information may include one or more executable files called by the program corresponding to the configuration file, one or more source files used by the program corresponding to the configuration file, and process information when the program corresponding to the configuration file is running.
[0078] An embodiment of the present invention also provides a server for protecting configuration files, comprising: one or more processors; a storage device for storing one or more programs, and when the one or more programs are executed by the one or more processors, the one or more processors implement the method provided in any of the above embodiments.
[0079] Figure 5 An exemplary system architecture to which the configuration file protection method or apparatus according to an embodiment of the present invention can be applied is shown, which may include: terminal devices 501, 502, 503, a network 504, and a server 505. The network 504 is a medium for providing a communication link between the terminal devices 501, 502, 503 and the server 505. The network 504 may include various connection types, such as wired or wireless communication links or optical fiber cables, etc.
[0080] Users can use terminal devices 501, 502, 503 to interact with server 505 through network 504 to receive or send messages, etc. Terminal devices 501, 502, 503 can be various electronic devices with display screens and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, desktop computers, etc.
[0081] The server 505 may be a server that provides various services, such as a background management server that provides support for a user's request to start a program or call a first file provided by the terminal devices 501, 502, and 503. The background management server may analyze the received request and feed back the processing result (such as the decrypted configuration file) to the terminal device.
[0082] It should be noted that the configuration file protection method provided in the embodiment of the present invention is generally executed by the server 505 , and accordingly, the device for protecting the configuration file is generally disposed in the server 505 .
[0083] It should be understood that Figure 5 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.
[0084] Reference below Figure 6 , which shows a schematic diagram of the structure of a computer system 600 of a terminal device suitable for implementing an embodiment of the present invention. Figure 6 The terminal device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.
[0085] like Figure 6 As shown, the computer system 600 includes a central processing unit (CPU) 601, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 602 or a program loaded from a storage part 608 into a random access memory (RAM) 603. In the RAM 603, various programs and data required for the operation of the system 600 are also stored. The CPU 601, the ROM 602, and the RAM 603 are connected to each other via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.
[0086] The following components are connected to the I / O interface 605: an input section 606 including a keyboard, a mouse, etc.; an output section 607 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 608 including a hard disk, etc.; and a communication section 609 including a network interface card such as a LAN card, a modem, etc. The communication section 609 performs communication processing via a network such as the Internet. A drive 610 is also connected to the I / O interface 605 as needed. A removable medium 611, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 610 as needed, so that a computer program read therefrom is installed into the storage section 608 as needed.
[0087] In particular, according to the embodiments disclosed in the present invention, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present invention include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 609, and / or installed from the removable medium 611. When the computer program is executed by the central processing unit (CPU) 601, the above-mentioned functions defined in the system of the present invention are executed.
[0088] It should be noted that the computer-readable medium shown in the present invention may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present invention, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present invention, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.
[0089] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present invention. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0090] The modules involved in the embodiments of the present invention may be implemented in software or hardware, and the modules described may also be arranged in a processor.
[0091] As another aspect, the present invention further provides a computer-readable medium, which may be included in the device described in the above embodiment; or may exist independently without being assembled into the device. The above computer-readable medium carries one or more programs, and when the above one or more programs are executed by a device, the device can encrypt the configuration file and the first file.
[0092] According to the technical solution of the embodiment of the present invention, when protecting the configuration file, not only can the multi-layer encryption protection measures for the configuration file and the first file be used to prevent attackers from illegally calling the first file or invading the program corresponding to the configuration file, thereby greatly improving the security of the configuration file, but also avoid the problem of single-point dependence on the online configuration center in the prior art, and the problem of obtaining the encryption key of the configuration file through the source file in the case of decompilation.
[0093] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may occur depending on design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A method for protecting a configuration file, characterized in that: include: Generate a first key, and use the first key to encrypt the configuration file; Obfuscating the first key and generating a first file, wherein the first file indicates how to convert the first key into the obfuscated first key; the first file includes another program recording an algorithm on how to obfuscate the first key into a corresponding output; Generate a second key and use the second key to encrypt the first file; the second key is a digital summary generated according to the trusted environment information when the program corresponding to the configuration file is running; the trusted environment information represents the corresponding environment information under normal operation when the user who starts the program is a legitimate user and the program is not attacked by an attacker.
2. The method for protecting a configuration file according to claim 1, characterized in that: Also includes: The first key is discarded, and the original plaintext configuration file is deleted.
3. The method for protecting a configuration file according to claim 1, characterized in that: The first file is a lookup table file, which records the corresponding relationship between the first key and the obfuscated first key.
4. The method for protecting a configuration file according to claim 1, characterized in that: Also includes: decrypting the first file according to the second key, and obtaining the first key according to the decrypted first file; The configuration file is decrypted according to the first key.
5. The method for protecting a configuration file according to claim 1, characterized in that: The environmental information includes one or more of the following: the programming language used by the program corresponding to the configuration file, the version of the programming language, the dependency path information of the programming language, one or more executable files called by the program corresponding to the configuration file, one or more source files used by the program corresponding to the configuration file, and library information loaded by the program corresponding to the configuration file.
6. The method for protecting a configuration file according to claim 5, characterized in that: The environmental information may also include one or more of the following: an IP address, a MAC address, a name of an operating system, and a version of an operating system when the program corresponding to the configuration file is running.
7. The method for protecting a configuration file according to claim 6, characterized in that: The environment information also includes process information when the program corresponding to the configuration file is running, and the process information includes one or more of the following: the user of the process, the authority of the process, the parent process name of the process, the files involved in the operation of the process, and the port of the process.
8. A device for protecting a configuration file, characterized in that: include: A first encryption module, a first file generation module, and a second encryption module, wherein: The first encryption module is used to generate a first key, and use the first key to encrypt the configuration file; The first file generation module is used to obfuscate the first key and generate a first file, wherein the first file indicates how to convert the first key into the obfuscated first key; the first file includes another program recording an algorithm on how to obfuscate the first key into a corresponding output; The second encryption module is used to generate a second key and use the second key to encrypt the first file; the second key is a digital summary generated based on the trusted environment information when the program corresponding to the configuration file is running; the trusted environment information represents that the user who starts the program is a legitimate user and the program is not attacked by an attacker, and corresponds to the environment information under normal operation.
9. The device for protecting a configuration file according to claim 8, characterized in that: The first encryption module is further used to discard the first key and delete the original plaintext configuration file.
10. The device for protecting a configuration file according to claim 8, characterized in that: The first file is a lookup table file, which records the corresponding relationship between the first key and the obfuscated first key.
11. The device for protecting a configuration file according to claim 8, characterized in that: Also includes: A first decryption module and a second decryption module, wherein The second decryption module is used to decrypt the first file according to the second key, and obtain the first key according to the decrypted first file; The first decryption module is used to decrypt the configuration file according to the first key.
12. The device for protecting a configuration file according to claim 8, characterized in that: The environmental information includes one or more of the following: the programming language used by the program corresponding to the configuration file, the version of the programming language, the dependency path information of the programming language, one or more executable files called by the program corresponding to the configuration file, one or more source files used by the program corresponding to the configuration file, and library information loaded by the program corresponding to the configuration file.
13. The device for protecting a configuration file according to claim 12, characterized in that: The environmental information may also include one or more of the following: an IP address, a MAC address, a name of an operating system, and a version of an operating system when the program corresponding to the configuration file is running.
14. The device for protecting a configuration file according to claim 13, characterized in that: The environment information also includes process information when the program corresponding to the configuration file is running, and the process information includes one or more of the following: the user of the process, the authority of the process, the parent process name of the process, the files involved in the operation of the process, and the port of the process.
15. A server for protecting a configuration file, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 7.
16. A computer readable medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Method and system for protecting information security of smartphone
CN105426775A
Source code encryption and decryption method and apparatus
CN107579962A
Method and device for generating white box library file
CN108134673A
FPGA encryption protection method, system and server
CN109543435A