Bytecode file encryption deployment method and device, equipment and storage medium

By generating a unique encryption key in the Java running environment and encrypting the bytecode file using the DES encryption algorithm, combined with the decryption and loading mechanism of the customized class loader, the problem of Java bytecode files being easily decompiled is solved, and the correct implementation is achieved. Efficient protection and secure deployment of the company's core business logic.

CN119026093AActive Publication Date: 2024-11-26BEISHANG GUANGSHENG TECHNOLOGY (BEIJING) CO LTD +1

Patent Information

Application Number
CN202411098300.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-12
Publication Date
2024-11-26
Estimated Expiration
2044-08-12

AI Technical Summary

Technical Problem

Java bytecode files are easily decompiled, resulting in leaks and illegal use of corporate core business logic, and lack of effective encryption protection measures.

Method used

Generate a unique encryption key in the Java running environment directory of the target server, encrypt the encrypted bytecode files using the DES data encryption algorithm, and decrypt and load files in JVM memory through a customized class loader to ensure file security .

Benefits of technology

Effectively prevent unauthorized access and use, ensure the uniqueness of encryption keys on each server, enhance the security of Java bytecode files and the security of overall deployment, and protect the core business logic and sensitive information of the enterprise.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119026093A_ABST
    Figure CN119026093A_ABST
Patent Text Reader

Abstract

The invention discloses a bytecode file encryption deployment method, device and equipment and a storage medium, and belongs to the technical field of information security and software encryption, and the method comprises the steps: obtaining the creation time of a secret key file and the physical address of a target server, generating an encryption key, and storing the encryption key in the secret key file; compiling and packaging the Java source file to obtain a target archived file set; determining a to-be-encrypted archived file set and a non-encrypted archived file set; symmetrically encrypting the to-be-encrypted archived file by using a DES data encryption algorithm; copying the non-encrypted archived file set and the encrypted archived file set to a specified directory; and executing data decryption of the target binary file set, and loading the successfully decrypted archived file and the unencrypted archived file into a JVM (Java Virtual Machine) memory of the target server. The technical problem that in the prior art, a Java bytecode file is prone to being decompiled, so that core business logic of an enterprise is likely to be leaked and illegally used is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of information security and software encryption technology, and in particular to a method, device, equipment and storage medium for bytecode file encryption deployment. Background Art

[0002] As a widely used programming language, Java is favored by developers around the world for its high development efficiency, cross-platform, stability, and strong scalability. Its "write once, run anywhere" feature makes Java a common solution for large Internet platforms. The cross-platform nature of Java is mainly reflected in its compilation process: Java source code is not directly compiled into a binary executable file for a specific operating system, but compiled into a bytecode file (i.e., .class file). These bytecode files are executed by the Java Virtual Machine (JVM). As the main provider of the Java language, Oracle provides corresponding JVMs for almost all operating systems, which enables the compiled bytecode files to run in a variety of operating system environments, further strengthening the cross-platform advantage of the Java language.

[0003] Although the Java language has its unique advantages in the development, deployment and operation stages, the defect that Java bytecode files are easily decompiled has brought significant security risks. In the development stage of a Java project, developers write Java source code according to business logic and compile it into bytecode files. Usually, multiple bytecode files are packaged into an archive file (such as a JAR package) for easy management and deployment. In the deployment stage, the enterprise copies these compiled bytecode files to the server. Due to the ubiquity of JVM, there is almost no limit to the types of server operating systems. However, these bytecode files deployed on the server are easily decompiled into the original Java source code, thereby leaking the core business logic of the enterprise. Therefore, how to effectively encrypt and protect Java bytecode files to prevent unauthorized access and use has become a problem that needs to be solved. Summary of the invention

[0004] The present application provides a method, apparatus, device and storage medium for bytecode file encryption deployment, aiming to solve the technical problem in the prior art that Java bytecode files are easily decompiled, which may lead to the leakage and illegal use of the core business logic of the enterprise.

[0005] In view of the above problems, the present application provides a method, apparatus, device and storage medium for bytecode file encryption deployment.

[0006] In a first aspect disclosed in the present application, a method for encrypting and deploying a bytecode file is provided, the method comprising generating a key file in a Java runtime environment directory of a target server, obtaining a creation time of the key file and a physical address of the target server, generating an encryption key based on the creation time and the physical address, and storing the encryption key in the key file, wherein the key file is a 32-bit random character; obtaining a Java source file, compiling and packaging the Java source file, and obtaining a target archive file set, wherein the target archive file includes a plurality of bytecode files; identifying the target archive file set, determining an archive file set to be encrypted and a non-encrypted archive file set, wherein the archive file to be encrypted is an archive file involving a predetermined business indicator; based on the encryption key in the key file, symmetrically encrypting the archive file to be encrypted using a DES data encryption algorithm to obtain an encrypted archive file set; copying the non-encrypted archive file set and the encrypted archive file set to a specified directory of the target server to obtain a target binary file set; performing data decryption of the target binary file set in the specified directory of the target server, and loading the successfully decrypted archive file and the non-encrypted archive file into the JVM memory of the target server using a custom class loader, wherein the custom class loader is written and constructed based on the C++ language.

[0007] The second aspect disclosed in the present application provides a device for encrypting and deploying bytecode files, the device comprising an encryption key generation module: used to generate a key file in the Java runtime environment directory of the target server, obtain the creation time of the key file and the physical address of the target server, generate an encryption key based on the creation time and the physical address, and store it in the key file, wherein the key file is a 32-bit random character; a compilation and packaging module: used to obtain a Java source file, compile and package the Java source file, and obtain a target archive file set, wherein the target archive file includes multiple bytecode files; an archive file set identification module: used to identify the target archive file set, determine the archive file set to be encrypted and the non-encrypted archive file A set of archive files to be encrypted is an archive file involving a predetermined business indicator; a symmetric encryption module: used to symmetrically encrypt the archive file to be encrypted using a DES data encryption algorithm based on an encryption key in the secret key file to obtain an encrypted archive file set; a binary file set acquisition module: used to copy the non-encrypted archive file set and the encrypted archive file set to a specified directory of a target server to obtain a target binary file set; a data decryption module: used to perform data decryption of the target binary file set in a specified directory of the target server, and use a customized class loader to load the successfully decrypted archive file and the unencrypted archive file into the JVM memory of the target server, wherein the customized class loader is written and constructed based on the C++ language.

[0008] In a third aspect, the present application also provides an electronic device, comprising: a memory for storing executable instructions; and a processor for executing the executable instructions stored in the memory to implement a method for encrypting and deploying bytecode files provided by the present application.

[0009] In a fourth aspect, the present application also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements a method for encrypting and deploying bytecode files provided in the present application.

[0010] One or more technical solutions provided in this application have at least the following technical effects or advantages:

[0011] The technical solution of generating a key file in the Java runtime environment directory of the target server and generating an encryption key based on the creation time of the key file and the physical address of the target server solves the problem of possible reuse and leakage of encryption keys in traditional methods, ensuring that the encryption keys on each server are unique. In this way, the generated encryption key is tightly bound to the specific server environment, achieving the technical effect of enhancing the security of Java bytecode files. This solution effectively prevents unauthorized access and use, making the application highly secure and complete when deployed on different servers, and protecting the core business logic and sensitive information of the enterprise.

[0012] The above description is only an overview of the technical solution of the present application. In order to more clearly understand the technical means of the present application, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present application more obvious and easy to understand, the specific implementation methods of the present application are listed below. BRIEF DESCRIPTION OF THE DRAWINGS

[0013] Figure 1 A flowchart of a method for encrypting and deploying bytecode files in this application.

[0014] Figure 2 This is a schematic diagram of the structure of a device for bytecode file encryption deployment in the present application.

[0015] Figure 3 This is a schematic diagram of the structure of an exemplary electronic device of the present application.

[0016] Figure 4 The present invention discloses a decryption and loading flowchart of an encrypted bytecode file of a method for encrypting and deploying a bytecode file.

[0017] Explanation of the accompanying drawings: encryption key generation module 11, compilation and packaging module 12, archive file set identification module 13, symmetric encryption module 14, binary file set acquisition module 15, data decryption module 16, processor 31, memory 32, input device 33, output device 34. DETAILED DESCRIPTION

[0018] The overall idea of ​​the technical solution provided by this application is as follows:

[0019] The embodiments of the present application provide a method, apparatus, device and storage medium for bytecode file encryption deployment. First, a Java source file is obtained and compiled to generate a target archive file set, which includes multiple bytecode files. Then, the archive files to be encrypted and non-encrypted are identified and distinguished according to business needs. For the files to be encrypted, the generated encryption key and DES algorithm are used for encryption processing. Subsequently, the encrypted and non-encrypted file sets are deployed to the specified directory of the target server. On the server, a custom class loader is used to perform the decryption and loading process of the encrypted file. The loader supports the decryption of encrypted files and the loading of standard files, thereby ensuring file security and the normal operation of the application.

[0020] After introducing the basic principles of the present application, various non-limiting implementation methods of the present application will be specifically described below in conjunction with the drawings in the specification.

[0021] Embodiment 1, as Figure 1 As shown, the embodiment of the present application provides a method for encrypting and deploying a bytecode file, the method comprising:

[0022] Step S100: Generate a key file in the Java runtime environment directory of the target server, obtain the creation time of the key file and the physical address of the target server, generate an encryption key based on the creation time and physical address, and store it in the key file, wherein the key file is 32-bit random characters.

[0023] Specifically, the target server refers to a computer or server running a Java application, which is used to store and execute Java bytecode files. The Java runtime environment directory refers to the installation path of the Java runtime environment, which usually includes JVM, Java class libraries, and related configuration files. The key file is a file used to store the generated encryption key, which is an indispensable element in encryption and decryption operations. This file is identified by 32-bit random characters to ensure that the key file generated on each server is unique. The creation time refers to the timestamp when the key file is generated, which can record the specific creation date and time to ensure the uniqueness and timeliness of the file. The physical address is the MAC address (Media Access Control Address), which is the hardware address of the network interface card and is used to uniquely identify a network device. The encryption key uses the password string generated by the creation time and physical address to encrypt the Java bytecode file. The encryption key ensures the confidentiality of the bytecode file. The 32-bit random character refers to the identifier of the key file, which consists of 32 randomly generated characters to increase security and unpredictability.

[0024] First, a key file is generated in the Java runtime environment directory of the target server. The file is named with 32 random characters. Next, the creation time of the key file and the physical address (MAC address) of the target server are obtained. These information (creation time and physical address) are concatenated into a string and then encrypted using the MD5 encryption algorithm to generate a unique encryption key.

[0025] In summary, this method enhances the security of Java bytecode files by generating unique encryption keys and using a variety of technical tools to ensure the security and effectiveness of the encryption process.

[0026] Step S200: Obtain a Java source file, compile and package the Java source file, and obtain a target archive file set, wherein the target archive file includes multiple bytecode files.

[0027] Specifically, the target archive file set refers to the final generated set of multiple bytecode files, which are usually packaged into one or more JAR files for deployment and execution.

[0028] First, developers write Java source files, which contain specific business logic and functional implementation.

[0029] Java source files are compiled into bytecode files using the Java compiler (javac). For example, running the command javacMyApp.java will generate a bytecode file called MyApp.class. Compilation is usually performed in a command line environment or an integrated development environment (IDE). Common IDEs include Eclipse, IntelliJ IDEA, NetBeans, etc. These tools automate the compilation process. The compiler converts the source code into bytecode. These bytecode files can be executed across platforms because they rely on the JVM rather than the operating system.

[0030] Use the Java Archive Tool (jar) to package multiple bytecode files into a JAR file. Running the command jarcvfMyApp.jarMyApp.class generates an archive file named MyApp.jar, which contains MyApp.class. JAR files may contain multiple files and directories, similar to ZIP files. The directory structure is preserved during the packaging process so that package dependencies between classes are not lost. In addition to bytecode files, JAR files can also contain other resources such as configuration files, icons, and documentation. These files are compressed and stored together with the bytecode when packaged.

[0031] Through this step, developers can successfully convert Java source files into a set of target archive files that can be executed in various environments, thereby achieving cross-platform deployment and operation of applications.

[0032] Step S300: Identify the target archive file set, determine the archive file set to be encrypted and the non-encrypted archive file set, wherein the archive file to be encrypted is an archive file involving a predetermined business indicator.

[0033] Specifically, the archive file set to be encrypted refers to a set of files selected from the target archive file set. These files contain key business logic or sensitive information and need to be encrypted for protection. The non-encrypted archive file set refers to a set of files that do not involve sensitive information. These files do not need to be encrypted and can be directly deployed and executed. The predetermined business indicators are used to determine the standards or rules for which archive files need to be encrypted, which usually involve the core business logic, proprietary algorithms, or sensitive data processing of the enterprise.

[0034] Use Java decompilation tools (such as JD-GUI, CFR) and archive management tools (such as jar command) to analyze the contents of JAR files. Use decompilation tools to view the various classes and packages in the JAR file to understand its functions and business logic.

[0035] Define which functions or data require special protection based on the business needs and data security policies of the enterprise. Use business indicators (such as sensitive data processing, algorithm implementation) to identify key files in the target archive file set. Divide the files into encrypted and non-encrypted file sets based on the identified business criticality. You can use scripts (such as Python or Bash) to automate the process and automatically identify and classify by file name or package name rules. Generate a list of files to be encrypted and record which files need to be encrypted. You can save it in the form of a text file or configuration file.

[0036] By identifying and classifying files in the target archive set, enterprises can ensure that sensitive business logic is effectively protected and reduce potential risks caused by code leakage. In this process, reasonable business indicator definition is the key to ensure the accuracy and efficiency of the identification process.

[0037] Step S400: Based on the encryption key in the key file, the archive file to be encrypted is symmetrically encrypted using the DES data encryption algorithm to obtain an encrypted archive file set.

[0038] Specifically, the DES data encryption algorithm is a symmetric encryption algorithm, that is, the same key is used for encryption and decryption. DES encrypts data by performing multiple permutation and substitution operations on data. Symmetric encryption is a type of encryption method that uses the same key for encryption and decryption, and is mainly used to protect the confidentiality of data. An encrypted archive file set refers to a collection of encrypted files that contain sensitive information in the archive file set to be encrypted and cannot be directly read or decompiled without authorization.

[0039] Use the javax.crypto package in Java to implement DES encryption. First, initialize a DES key object and use the generated encryption key to create an encryption key object through SecretKeySpec. Use the Cipher class to configure the DES encryption algorithm and encrypt the bytecode files to be encrypted one by one. Save the encrypted data as a new encrypted archive file. The encrypted files are packaged into an encrypted archive file set, which can be safely deployed on the server to prevent unauthorized access and reverse engineering.

[0040] By utilizing the encryption key in the secret key file and the DES data encryption algorithm, enterprises can effectively protect archive files containing sensitive information in Java applications. This encryption process ensures the secure transmission and deployment of files, reducing the risk of information leakage and unauthorized access.

[0041] Step S500: copy the non-encrypted archive file set and the encrypted archive file set to a designated directory of a target server to obtain a target binary file set.

[0042] Specifically, the specified directory refers to a specific file path on the target server for storing Java archive files, usually the working directory or deployment directory of the application. The target binary file set refers to the set of all Java archive files in the specified directory, ready to be executed in the Java Virtual Machine (JVM).

[0043] Create a designated directory on the target server to store the archive files. Use a file transfer tool (such as scp, rsync, or an FTP client) to upload the local non-encrypted archive file set and the encrypted archive file set to the designated directory on the target server. Ensure that all archive files (encrypted and non-encrypted) have been correctly copied to the target directory to form a complete target binary file set. Check the integrity and correctness of the files to ensure that all necessary files are present and not corrupted. This can be verified by using file hash checksums (such as md5sum or sha256sum). On the target server, set appropriate permissions on the archive files to ensure that the Java application can correctly access and execute these files. Use the Linux command line to set file permissions and set more restrictive access permissions on encrypted files containing sensitive information to prevent unauthorized users from accessing them. After the files are copied, perform a simple test run to ensure that all files can be loaded and executed correctly. Review the application log to ensure that there are no loading or execution errors.

[0044] Enterprises can effectively deploy Java applications by copying non-encrypted and encrypted archive file sets to the specified directory of the target server. This process includes steps such as preparing the target directory, uploading files, verifying file integrity, setting permissions, and test running. It can ensure the security and reliability of the application and reduce possible errors and security risks during the deployment process.

[0045] Step S600: Execute data decryption of the target binary file set in the specified directory of the target server, and use a customized class loader to load the successfully decrypted archive files and unencrypted archive files into the JVM memory of the target server, wherein the customized class loader is written and constructed based on the C++ language.

[0046] Specifically, use the javax.crypto library in Java or a third-party library to implement the decryption operation of DES encrypted files. It is necessary to generate a decryption key by reading the secret key file and decrypt the encrypted .class.sec file. Read the contents of the encrypted file into memory, and use the generated decryption key to decrypt the file content through the DES decryption algorithm to restore the original bytecode data. Use the information in the secret key file, such as the creation time and physical address, to generate a decryption key through MD5.

[0047] Since the target JVM is a customized version, the customized class loader is written in C++ and is compatible with loading encrypted .class.sec and ordinary .class files. The customized class loader interacts with the C++ code through JNI (Java Native Interface) to implement the decryption and loading logic of encrypted files. The class loader determines whether the file is encrypted based on the file extension. If it is an encrypted file, it will first perform decryption and then load the decrypted bytecode into the JVM memory.

[0048] Use a custom class loader to load and execute a Java application. Load all required class files through a custom ClassLoader instance. The custom class loader supports loading unencrypted plain bytecode files, ensuring compatibility with standard Java class loaders. Start the application and test key functions to ensure that all class files (encrypted and unencrypted) can be loaded and executed correctly.

[0049] By performing data decryption on the target server and using a custom class loader to load Java bytecode files, enterprises can effectively protect the security of their Java applications. Custom class loaders are compatible with standard class loaders while adding decryption capabilities, allowing applications to take advantage of Java's cross-platform features while ensuring the security of their core logic.

[0050] Furthermore, generating an encryption key includes: obtaining the creation time of the key file in the Java runtime environment directory, reading the physical address of the target server; splicing the creation time and the physical address, encrypting the spliced ​​content using the MD5 encryption algorithm, and generating an encryption key.

[0051] Specifically, the MD5 encryption algorithm is a hash algorithm used to convert input data into a hash value of fixed length, which is usually used for data integrity verification.

[0052] In the process of secure deployment of Java applications, in order to generate a unique encryption key, you first need to obtain the creation time of the key file in the Java runtime directory and the physical address of the server from the target server. The creation time can be obtained through file attributes or operating system commands. For example, on a Linux system, you can use the stat command to view detailed information about the file, and the physical address can be obtained through system commands such as ipconfig / all (Windows) or ifconfig (Linux). Assume that the creation time of the key file is "2024-08-0110:30:45" and the physical address is "00:1A:2B:3C:4D:5E".

[0053] Next, the creation time and physical address are concatenated into a string: "2024-08-0110:30:4500:1A:2B:3C:4D:5E". This concatenated string combines the time and the hardware identification information of the device to ensure its uniqueness. Then, the string is encrypted using the MD5 encryption algorithm to generate a 32-bit character hash value as the encryption key. The use of the MD5 algorithm can be implemented through library functions in various programming languages. For example, in Java, the java.security.MessageDigest class can be used to implement MD5 encryption. Assume that the generated MD5 hash value is "e99a18c428cb38d5f260853678922e03", this value is the key used to encrypt the bytecode file.

[0054] By obtaining the creation time of the key file and the physical address of the server and using the MD5 algorithm to generate an encryption key, enterprises can generate a unique and secure encryption key for their Java applications, ensuring the security and protection capabilities of the application and preventing unauthorized access and use.

[0055] Furthermore, determining the archive file set to be encrypted and the non-encrypted archive file set includes: configuring predetermined business indicators based on the target enterprise business logic; screening the target archive file set according to the predetermined business indicators, setting the target archive files involving the predetermined business indicators as archive files to be encrypted, and setting the target archive files not involving the predetermined business indicators as non-encrypted archive files, to obtain the archive file set to be encrypted and the non-encrypted archive file set.

[0056] Specifically, target enterprise business logic refers to the specific functions and operating rules that an enterprise implements in its applications. These logics are usually closely related to the enterprise's core business and competitiveness.

[0057] Analyze the core business processes and application architecture of the enterprise to identify which functions and logic are critical or sensitive, such as transaction processing modules and customer information management modules in financial software.

[0058] Based on the analysis results, define which files need to be encrypted and protected. Business indicators may include: modules involving financial calculations, user authentication and authorization modules, data encryption and decryption algorithms, etc.

[0059] Automate the screening process using code analysis tools or scripts. For example, use Java analysis tools such as JDepend or SonarQube to identify files involving specific packages or classes. Scan and analyze the bytecode files in the target archive file set and mark the files that match the predetermined business indicators. Use tools such as regular expressions to search file names or package names to help identify files that need to be encrypted.

[0060] Mark the files that match the business indicators as files to be encrypted. Mark the files that do not meet the business indicators as non-encrypted files. Record the list of files to be encrypted and non-encrypted for subsequent encryption and deployment. Based on the generated list of files to be encrypted, use the encryption key generated previously to encrypt the files to be encrypted. Prepare the encrypted and non-encrypted file sets for deployment to the target server.

[0061] For example, in an online payment system, the enterprise identified modules involved in transaction processing and customer authentication as sensitive components. The bytecode files of these modules were screened as files to be encrypted to ensure protection during deployment. A medical software company developed an electronic health record management system, in which the logic for processing patient data and medical decision support was identified as requiring encryption protection. By analyzing the business logic, the company screened out these key modules for encryption to ensure patient privacy and data security.

[0062] By configuring predetermined business indicators based on the enterprise business logic and screening the target archive file set, enterprises can effectively identify and encrypt bytecode files that need to be protected. This process ensures that the enterprise's key business logic and sensitive information are protected during the deployment process, reducing the risk of code leakage. With automated tools and clear business indicators, enterprises can efficiently implement this protection measure to ensure the security and reliability of their Java applications.

[0063] Further, such as Figure 4 As shown, a customized class loader is used to load successfully decrypted archive files and unencrypted archive files into the JVM memory of the target server, including: in a specified directory of the target server, a plurality of target binary files in the target binary file set are respectively judged whether to be encrypted; if the target binary file is an encrypted archive file, the encrypted archive file is decrypted, and the successfully decrypted archive file is loaded into the JVM memory of the target server according to the encrypted loading method using a customized class loader, wherein the customized class loader is written and constructed based on the C++ language, and can execute the original loading method and the encrypted loading method.

[0064] Specifically, ensure that all target binary files (including encrypted and unencrypted files) are stored in the designated directory of the server. Determine whether the file is an encrypted archive file by file extension (such as .class.sec) or file header identification. This can be achieved through simple file traversal and extension checking.

[0065] Use encryption libraries in Java or C++ (such as OpenSSL, Bouncy Castle, etc.) to implement data decryption. By reading the contents of the encrypted file, use the generated encryption key to decrypt it into raw bytecode. After reading the encrypted file, use a customized decryption algorithm to convert the data into a loadable raw bytecode form so that it can be loaded by a customized class loader.

[0066] The custom class loader is written in C++ and uses JNI to interact with the JVM. It can select the appropriate loading strategy based on the encryption status of the file. For encrypted files, the custom class loader first calls the decryption function and then loads the decrypted bytecode into the JVM memory.

[0067] By using a custom class loader to load encrypted Java bytecode files on the target server, enterprises can ensure the security and functionality of applications. The custom class loader combines decryption and loading capabilities, allowing applications to run securely in different environments.

[0068] Further, such as Figure 4 As shown, if the target binary file is an unencrypted archive file, the unencrypted archive file is loaded into the JVM memory of the target server according to the original loading method using a customized class loader.

[0069] Specifically, for unencrypted files, the custom class loader directly calls the standard loading method to load the bytecode into the JVM memory. Among them, the original loading method is the loading process of the standard Java class loader, which is used to load unencrypted bytecode files.

[0070] Further, such as Figure 4 As shown, data decryption of the encrypted archive file includes: reading the second creation time of the key file in the Java runtime environment directory and the second physical address of the current server; splicing the second creation time and the second physical address, encrypting the second spliced ​​content using the MD5 encryption algorithm, and generating a decryption key; based on the decryption key, using the DES data encryption algorithm to decrypt the encrypted archive file data, if the decryption fails, reporting an error and exiting.

[0071] Specifically, the second creation time refers to the last creation or modification time of the key file on the server, which is usually used to generate a decryption key. The second physical address refers to the MAC address of the current network interface card of the target server, providing a hardware unique identifier.

[0072] On the target server, read the key file in the Java runtime directory to obtain the second creation time and the physical address of the current server. This information is used to generate the decryption key. To obtain the second creation time, you can use the file system command or programming interface to read the file attributes. For example, on Linux, you can use the stat command to obtain the creation or modification time of a file. To obtain the second physical address, use the system command or API to obtain the MAC address of the server. On Windows, you can use ipconfig / all, and on Linux, you can use ifconfig or ip addr commands.

[0073] Concatenate the second creation time and the second physical address into a string, and use the MD5 algorithm to encrypt the concatenated content to generate a 32-bit hash value as the decryption key. Concatenation format: For example, assuming the creation time is "2024-08-01 10:30:45" and the physical address is "00:1A:2B:3C:4D:5E", the concatenation result is "2024-08-01 10:30:4500:1A:2B:3C:4D:5E".

[0074] Use Java's java.security.MessageDigest or a hash library of another programming language to perform MD5 encryption on the concatenated string and generate a decryption key (for example, "e99a18c428cb38d5f260853678922e03").

[0075] Decrypt the encrypted bytecode file using the DES algorithm and restore its original content for loading. Use Java's javax.crypto package or other encryption libraries (such as OpenSSL) to perform the decryption operation. When decrypting, ensure that the key length and format meet the requirements of the DES algorithm. Read the encrypted file, pass its content to the decryption function, and use the decryption key to restore it to unencrypted bytecode.

[0076] If the decryption process fails, the system needs to report an error and exit to ensure that files in unauthorized or erroneous environments cannot be loaded. Catch exceptions during the decryption process (such as key mismatch, file corruption, etc.), record logs, and terminate the loading operation. Ensure that the application does not continue to load incomplete or erroneous bytecode files when decryption fails.

[0077] Through the decryption process of encrypted archive files, this solution ensures the secure deployment and execution of Java applications on the target server. The decryption key is generated by using the creation time of the key file and the physical address of the server, combined with the DES decryption algorithm, providing a flexible and secure loading solution. Through rigorous decryption process and error handling, enterprises can reduce the risk of code leakage and unauthorized access while ensuring application security. This solution effectively enhances the security and deployment flexibility of Java applications and is suitable for a variety of complex enterprise environments.

[0078] In summary, the method for encrypting and deploying bytecode files provided in the embodiments of the present application has the following technical effects:

[0079] 1. By generating a key file in the Java runtime environment directory of the target server and generating an encryption key based on the file creation time and physical address, the uniqueness of the key for each server is ensured, thereby increasing the security of the application. This method can effectively prevent the reuse and leakage of encryption keys, and improve the security of the system, especially when deployed between different servers. Its technical effect is to provide a unique encryption key for each deployment environment, preventing unauthorized environments from accessing and using the bytecode files of the application, and enhancing the security and reliability of the overall deployment.

[0080] 2. By concatenating the creation time of the key file and the physical address of the target server, and using the MD5 algorithm to generate the encryption key, the generation process is automated and unique. Using the hash value generated by MD5 as the encryption key ensures the uniqueness and security of the key, and effectively prevents key collision and forgery. This technical effect binds the encryption key to a specific server, increasing the difficulty of unauthorized access, thereby ensuring the secure deployment of Java bytecode files on different servers and improving the confidentiality of the application.

[0081] 3. By identifying and classifying the archived files to be encrypted and non-encrypted in Java applications, enterprises can centrally protect key business logic and sensitive information. Files that need to be encrypted are screened according to predetermined business indicators to ensure that the core functions and proprietary algorithms of the enterprise are not leaked. The technical effect of this method is to optimize the use of encryption resources, reduce the processing overhead of encryption and decryption, ensure that sensitive information is effectively protected, and improve the security and performance of applications.

[0082] 4. By using a custom class loader to decrypt and load encrypted archive files, ensure that only authorized files are loaded and executed in the correct environment. The custom class loader can identify encrypted files and automatically decrypt them, making the deployment process more secure and automated. The technical effect is to improve the security of the application by increasing the transparency and control of the decryption process, avoiding unauthorized file loading and execution, and ensuring the safe operation of Java applications in different environments.

[0083] Embodiment 2 is based on the same inventive concept as the method for encrypting and deploying a bytecode file in the above embodiment. Figure 2 As shown, an embodiment of the present application provides a device for encrypting and deploying a bytecode file, the device comprising:

[0084] Encryption key generation module: used to generate a key file in the Java runtime environment directory of the target server, obtain the creation time of the key file and the physical address of the target server, generate an encryption key based on the creation time and the physical address, and store it in the key file, wherein the key file is a 32-bit random character;

[0085] Compiling and packaging module: used to obtain Java source files, compile and package the Java source files, and obtain a target archive file set, wherein the target archive file includes multiple bytecode files;

[0086] Archive file set identification module: used to identify the target archive file set, determine the archive file set to be encrypted and the non-encrypted archive file set, wherein the archive file to be encrypted is the archive file involving the predetermined business indicator;

[0087] Symmetric encryption module: used to symmetrically encrypt the archived file to be encrypted using the DES data encryption algorithm based on the encryption key in the secret key file to obtain an encrypted archived file set;

[0088] A binary file set acquisition module is used to copy the non-encrypted archive file set and the encrypted archive file set to a specified directory of a target server to obtain a target binary file set;

[0089] Data decryption module: used to perform data decryption of the target binary file set in the specified directory of the target server, and use a customized class loader to load the successfully decrypted archive files and unencrypted archive files into the JVM memory of the target server, where the customized class loader is written and built based on the C++ language.

[0090] Embodiment 3, Figure 3 The schematic diagram of the structure of the electronic device provided in the third embodiment of the present invention shows a block diagram of an exemplary electronic device suitable for implementing the implementation mode of the present invention. Figure 3The electronic device shown is only an example and should not limit the functions and scope of use of the embodiments of the present invention. Figure 3 As shown, the electronic device includes a processor 31, a memory 32, an input device 33 and an output device 34; the number of processors 31 in the electronic device can be one or more. Figure 3 Taking a processor 31 as an example, the processor 31, memory 32, input device 33 and output device 34 in the electronic device can be connected through a bus or other means. Figure 3 The example of connecting through bus is taken in the following.

[0091] The memory 32, as a computer-readable storage medium, can be used to store software programs, computer executable programs and modules, such as program instructions / modules corresponding to a method for encrypting and deploying bytecode files in an embodiment of the present invention. The processor 31 executes various functional applications and data processing of the computer device by running the software programs, instructions and modules stored in the memory 32, that is, implementing the above-mentioned method for encrypting and deploying bytecode files.

[0092] The present application provides a method for encrypting and deploying bytecode files, wherein the method is applied to a device for encrypting and deploying bytecode files, wherein the method first obtains a Java source file and compiles and packages it into a target archive file set, and then identifies the file set that needs to be encrypted according to predetermined business indicators. The files are encrypted using the encryption key and DES algorithm in the secret key file, and the encrypted and unencrypted files are deployed to the target server. A custom class loader is used to load these files on the server, which can perform decryption and loading operations according to the encryption status of the files. By reading the creation time of the secret key file and the physical address of the server, the system generates a decryption key to securely decrypt the file, ensuring that these bytecode files can only be accessed and executed in the correct environment. This solution effectively protects the key business logic and sensitive information of the enterprise, prevents unauthorized access and reverse engineering, and enhances the security and deployment flexibility of the application.

[0093] Note that the above are only preferred embodiments of the present invention and the technical principles used. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and that various obvious changes, readjustments and substitutions can be made by those skilled in the art without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in more detail through the above embodiments, the present invention is not limited to the above embodiments, and may include more other equivalent embodiments without departing from the concept of the present invention, and the scope of the present invention is determined by the scope of the appended claims.

Claims

1. A method for encrypting and deploying bytecode files, characterized in that: include: Generate a key file in the Java runtime environment directory of the target server, obtain the creation time of the key file and the physical address of the target server, generate an encryption key based on the creation time and physical address, and store it in the key file, wherein the key file is a 32-bit random character; Obtaining a Java source file, compiling and packaging the Java source file to obtain a target archive file set, wherein the target archive file includes a plurality of bytecode files; Identify the target archive file set, determine the archive file set to be encrypted and the non-encrypted archive file set, wherein the archive file to be encrypted is an archive file related to a predetermined business indicator; Based on the encryption key in the secret key file, the archived file to be encrypted is symmetrically encrypted using the DES data encryption algorithm to obtain an encrypted archived file set; Copying the non-encrypted archive file set and the encrypted archive file set to a specified directory of a target server to obtain a target binary file set; The data decryption of the target binary file set is performed in the specified directory of the target server, and the successfully decrypted archive files and unencrypted archive files are loaded into the JVM memory of the target server using a customized class loader, wherein the customized class loader is written and constructed based on the C++ language.

2. According to the method for encrypting and deploying bytecode files as described in claim 1, it is characterized in that: Generate encryption keys, including: Obtain the creation time of the key file in the Java runtime environment directory and read the physical address of the target server; The creation time and the physical address are concatenated, and the concatenated content is encrypted using the MD5 encryption algorithm to generate an encryption key.

3. According to the method for bytecode file encryption and deployment as described in claim 1, it is characterized in that: Determine the archive file set to be encrypted and the archive file set not to be encrypted, including: Configure predetermined business indicators based on the target enterprise's business logic; The target archive file set is screened according to the predetermined business indicator, the target archive files related to the predetermined business indicator are set as archive files to be encrypted, and the target archive files not related to the predetermined business indicator are set as non-encrypted archive files, to obtain an archive file set to be encrypted and a non-encrypted archive file set.

4. According to the method for bytecode file encryption and deployment as described in claim 1, it is characterized in that: Use a custom class loader to load the successfully decrypted archive files and unencrypted archive files into the JVM memory of the target server, including: In a designated directory of a target server, determining whether to encrypt or not for each of the plurality of target binary files in the target binary file set; If the target binary file is an encrypted archive file, the data of the encrypted archive file is decrypted, and the successfully decrypted archive file is loaded into the JVM memory of the target server according to the encrypted loading method using a customized class loader. The customized class loader is written and built based on the C++ language and can execute the original loading method and the encrypted loading method.

5. According to the method for encrypting and deploying bytecode files as described in claim 4, it is characterized in that: If the target binary file is an unencrypted archive file, the unencrypted archive file is loaded into the JVM memory of the target server according to the original loading method using a customized class loader.

6. According to the method for encrypting and deploying bytecode files as claimed in claim 4, it is characterized in that: Decrypt data from encrypted archive files, including: Read the second creation time of the key file in the Java runtime environment directory and the second physical address of the current server; Concatenate the second creation time and the second physical address, encrypt the second concatenated content using the MD5 encryption algorithm, and generate a decryption key; Based on the decryption key, the encrypted archive file is decrypted using the DES data encryption algorithm. If the decryption fails, an error is reported and the program exits.

7. A device for encrypting and deploying bytecode files, characterized in that: For executing the method according to any one of claims 1 to 6, the device comprises: Encryption key generation module: used to generate a key file in the Java runtime environment directory of the target server, obtain the creation time of the key file and the physical address of the target server, generate an encryption key based on the creation time and the physical address, and store it in the key file, wherein the key file is a 32-bit random character; Compiling and packaging module: used to obtain Java source files, compile and package the Java source files, and obtain a target archive file set, wherein the target archive file includes multiple bytecode files; Archive file set identification module: used to identify the target archive file set, determine the archive file set to be encrypted and the non-encrypted archive file set, wherein the archive file to be encrypted is the archive file involving the predetermined business indicator; Symmetric encryption module: used to symmetrically encrypt the archived file to be encrypted using the DES data encryption algorithm based on the encryption key in the secret key file to obtain an encrypted archived file set; A binary file set acquisition module is used to copy the non-encrypted archive file set and the encrypted archive file set to a specified directory of a target server to obtain a target binary file set; Data decryption module: used to perform data decryption of the target binary file set in the specified directory of the target server, and use a customized class loader to load the successfully decrypted archive files and unencrypted archive files into the JVM memory of the target server, where the customized class loader is written and built based on the C++ language.

8. An electronic device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.

9. A storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.

Citation Information

Patent Citations

  • Protection method and protection system of file

    CN103166958A

  • Data encryption and decryption processing method and device and related equipment

    CN109359472A

  • Encrypted source code file processing method and device, computer equipment and storage medium

    CN111177749A

  • Data encryption transmission method and device, electronic equipment and storage medium

    CN115589316A

  • Jar file protection method and Jar program operation method

    CN115618405A

Cited By

  • Scoring card model analysis processing method and system, electronic equipment and storage medium

    CN120744885A

  • Scoring card model analysis processing method, system, electronic device and storage medium

    CN120744885B

  • Method and device for automatically compiling and uploading java file

    CN121658011A