CN-121980547-A - Java application program generation and running methods, devices, equipment and media
Abstract
The application discloses a Java application program generation and operation method, device, equipment and medium, which are used for enhancing the capability of Java application program reverse analysis prevention, and have safe and efficient protection effect and good service compatibility. The method comprises the steps of obtaining Java byte code files to be encrypted from a target naming space, generating encryption parameters for each Java byte code file to be encrypted, encrypting the Java byte codes by utilizing the encryption parameters to obtain Java byte code ciphertext, clearing function bodies of all functions in the Java byte code file, reserving declarations of all functions, filling default return values of the functions according to return types of the functions for each function, encrypting the encryption parameters to obtain encryption parameter ciphertext, utilizing the Java byte code ciphertext and the encryption parameter ciphertext to generate Java byte code encryption files, and generating Java application ciphertext program packages based on all Java byte code encryption files.
Inventors
- ZHANG JIANQING
- LI CHAO
Assignees
- 浙江大华技术股份有限公司
Dates
- Publication Date
- 20260505
- Application Date
- 20260122
Claims (10)
- 1. A Java application generation method, the method comprising: acquiring at least one Java byte code file to be encrypted from a target name space; Generating encryption parameters corresponding to the file, encrypting Java byte codes in the file by utilizing the encryption parameters to obtain Java byte code ciphertext, clearing function bodies of all functions in the file, reserving declarations of the functions, and filling default return values of the functions according to the return types of the functions for each function; and generating a Java application ciphertext program package based on all the Java byte code encryption files.
- 2. The method of claim 1, wherein generating a Java bytecode encrypted file using the Java bytecode ciphertext and the encryption parameter ciphertext comprises: setting a first static class variable and a second static class variable in a Java byte code file to be encrypted currently; The Java bytecode ciphertext is stored in the first static class variable, and the encryption parameter ciphertext is stored in the second static class variable.
- 3. The method of claim 1, wherein the encryption parameters are randomly generated, including an encryption algorithm type, an encryption key, and an initial vector.
- 4. A method for running a Java application, the method comprising: loading Java byte codes through a Java Virtual Machine (JVM); resolving the currently loaded Java byte codes; When the Java byte code ciphertext field and the encryption parameter ciphertext field exist through the analysis, acquiring the Java byte code ciphertext and the encryption parameter ciphertext; Decrypting the encrypted parameter ciphertext by using a preset application key to obtain an encrypted parameter; Decrypting the Java byte code ciphertext by utilizing the encryption parameter to obtain a Java byte code plaintext; loading the Java byte code plaintext through the JVM.
- 5. The method of claim 4, wherein when it is determined by the parsing that the Java bytecode ciphertext field and the encryption parameter ciphertext field are present, obtaining the Java bytecode ciphertext and the encryption parameter ciphertext comprises: And when the first static class variable and the second static class variable exist in the Java byte code which is loaded currently through the analysis, extracting Java byte code ciphertext and encryption parameter ciphertext from the first static class variable and the second static class variable respectively.
- 6. The method of claim 4, wherein the encryption parameters include an encryption algorithm type, an encryption key, and an initial vector.
- 7. A Java application generation apparatus, the apparatus comprising: the Java byte code plaintext acquisition module is used for acquiring at least one Java byte code file to be encrypted from the target naming space; The Java byte code encryption module is used for: Generating encryption parameters corresponding to the file, encrypting Java byte codes in the file by utilizing the encryption parameters to obtain Java byte code ciphertext, clearing function bodies of all functions in the file, reserving declarations of the functions, and filling default return values of the functions according to the return types of the functions for each function; and generating a Java application ciphertext program package based on all the Java byte code encryption files.
- 8. The Java application program running device is characterized by comprising a Java virtual machine JVM and a Java byte code decryption and restoration module, or comprising the Java virtual machine JVM, wherein the Java virtual machine JVM is provided with the Java byte code decryption and restoration module, and the Java application program running device comprises the following components: The Java virtual machine JVM is used for loading Java byte codes; the Java byte code decryption and restoration module is used for: resolving the Java bytecode loaded currently: When the Java byte code ciphertext field and the encryption parameter ciphertext field exist through the analysis, acquiring the Java byte code ciphertext and the encryption parameter ciphertext; Decrypting the encrypted parameter ciphertext by using a preset application key to obtain an encrypted parameter; Decrypting the Java byte code ciphertext by utilizing the encryption parameter to obtain a Java byte code plaintext; the Java virtual machine JVM is also used for loading the Java byte code plaintext.
- 9. An electronic device, comprising: A memory for storing program instructions; A processor for invoking program instructions stored in said memory to perform the method of any of claims 1 to 6 in accordance with the obtained program.
- 10. A computer-readable storage medium storing computer-executable instructions for causing a computer to perform the method of any one of claims 1 to 6.
Description
Java application program generation and running methods, devices, equipment and media Technical Field The present application relates to the field of information processing technologies, and in particular, to a method, an apparatus, a device, and a medium for generating and running a Java application. Background Java becomes a main stream development language of enterprise-level application by the advantages of strong ecosystem, cross-platform property, safety, stability, reliability and the like, and obtains extremely wide application. However, java is a compiled language, but unlike the C/c++ language, its compiled result is Java bytecodes that conform to the definition of the Java specification, which retains very rich semantic information so that decompilation tools can restore the original code structure. Disclosure of Invention The embodiment of the application provides a Java application program generation and operation method, device, equipment and medium, which are used for enhancing the reverse analysis prevention capability of the Java application program, ensuring that the protection effect is safe and efficient, having good service compatibility, realizing the construction and operation of the safe and efficient Java application ciphertext program and meeting the encryption requirements in more application scenes. The Java application program generation method provided by the embodiment of the application comprises the following steps: acquiring at least one Java byte code file to be encrypted from a target name space; Generating encryption parameters corresponding to the file, encrypting Java byte codes in the file by utilizing the encryption parameters to obtain Java byte code ciphertext, clearing function bodies of all functions in the file, reserving declarations of the functions, and filling default return values of the functions according to the return types of the functions for each function; and generating a Java application ciphertext program package based on all the Java byte code encryption files. It can be seen that the Java application program generation method provided by the embodiment of the application can further carry out the following processing on each Java byte code file to be encrypted by acquiring at least one Java byte code file to be encrypted from a target naming space, generating encryption parameters corresponding to the Java byte code file, encrypting the Java byte codes in the Java byte code file by utilizing the encryption parameters to obtain Java byte code ciphertext, clearing function bodies of all functions in the Java byte code file, reserving declarations of all functions, filling default return values of the functions according to the return types of the functions for each function, so that the encrypted Java byte codes are completely compatible with various application development frameworks, and further encrypting the encryption parameters by a preset application key to obtain encryption parameter ciphertext, and generating the Java byte code encryption file by utilizing the Java byte code ciphertext and the encryption parameter ciphertext. Finally, based on all the Java byte code encryption files processed by the method, the Java application ciphertext program package is generated by repacking, so that the construction of the Java application ciphertext program package is completed, wherein a two-stage key system is formed by the application key and the encryption parameters, the reverse analysis prevention capability of the Java application program is greatly enhanced, the protection effect is safe and efficient, the service compatibility is good, and the construction and the operation of the safe and efficient Java application ciphertext program are realized. In addition, the application keys with different security levels can be flexibly selected according to the key security requirements in different application scenes, and further, the requirements of more application scenes can be greatly met. In some embodiments, generating the Java bytecode encrypted file using the Java bytecode ciphertext and the encryption parameter ciphertext includes: setting a first static class variable and a second static class variable in a Java byte code file to be encrypted currently; The Java bytecode ciphertext is stored in the first static class variable, and the encryption parameter ciphertext is stored in the second static class variable. Therefore, the embodiment of the application stores the Java byte code ciphertext and the encryption parameter ciphertext in the newly added static class variable in the current Java byte code file, so that the Java byte code ciphertext can be integrally decrypted at one time without loading an additional ciphertext file when decrypting and restoring the Java byte code in the execution stage of the Java application program, the original Java byte code can be quickly restored without reassembling, and the execution performance los