CN101957903A - Method and device for protecting class files - Google Patents

Method and device for protecting class files Download PDF

Info

Publication number
CN101957903A
CN101957903A CN2010102794939A CN201010279493A CN101957903A CN 101957903 A CN101957903 A CN 101957903A CN 2010102794939 A CN2010102794939 A CN 2010102794939A CN 201010279493 A CN201010279493 A CN 201010279493A CN 101957903 A CN101957903 A CN 101957903A
Authority
CN
China
Prior art keywords
file
class file
key
class
sign indicating
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN2010102794939A
Other languages
Chinese (zh)
Inventor
郭宏泰
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
ZTE Corp
Original Assignee
ZTE Corp
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by ZTE Corp filed Critical ZTE Corp
Priority to CN2010102794939A priority Critical patent/CN101957903A/en
Publication of CN101957903A publication Critical patent/CN101957903A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Storage Device Security (AREA)

Abstract

The invention discloses a method and device for protecting class files. The method comprises the following steps: an encryption unit reads the byte codes of a class file to be encrypted, a key pair is used to encrypt the byte codes of the class file to obtain an encrypted byte code file; a compilation unit fills the verification code and key pair used for verifying the user in a local application program, a file protection device is obtained by compiling the source codes of the local application program; and the file protection device uses the key pair to decrypt the encrypted byte code file. In the method of the invention, the file encryption unit is adopted to encrypt the byte codes of the class file and the file protection device generated in the encryption process is used to decrypt the byte codes, thus the class file is effectively prevented from decompiling, the cross-platform characteristic of the program can be maintained and the operation of the user can be more convenient.

Description

A kind of method and apparatus of protecting class file
Technical field
The present invention relates to the security protection technology of class file, particularly a kind of method and apparatus of protecting class file.
Background technology
Java language can be cross-platform, be because the Java source code has been translated into class file by compiler, and class file is to preserve with a kind of form of and platform independence as intermediate code.Class file has a shortcoming, can utilize the disassembler javap among the JDK that class file is carried out dis-assembling exactly, and then utilizes the decompiling instrument that the result of dis-assembling is carried out decompiling, draws such source code.This is very disadvantageous concerning needs prevent programmer that the Java source code plagiarized or attack.
The method of existing class file protection mainly contains following several: bytecode obfuscation, native compile technology, bytecode digital watermark and JVM Classloader encryption technology.
The bytecode obfuscation is to utilize the obfuscator instrument to take precautions against the compiling of decompiler, its objective is and make decompiler indigestion class method, to such an extent as to reverse-engineering will spend more time and energy is translated class file, most of obfuscator instrument is upset the identifier in byte code files, and a significant name replaces with the skimble-skamble name that produces in proper order or at random.But this technology has just been accomplished lip-deep fuzzy, and its interior business logic is but still constant, if the cracker is patient, is still and can breaks through.
The native compile technology is meant java application is compiled into local application program, convert the literal code program to local binary file, not only can improve program operation speed, take internal memory still less, also can make its security reach the degree of local executable application programs.But this technology makes application program lose cross-platform feature, and because native compile device immature do not fit into large-scale application program.
The bytecode digital watermark is the same with embed watermark in picture sound, in java applet, also can embed transparent, safety and information robustness, can provide effective evidences confirming whether some program belong to when plagiarizing, but can not stop class file to be reused or by decompiling.
Java Virtual Machine JVM Classloader encryption technology at first adopts certain cryptographic algorithm to encrypt class file, again this type of file transfer is arrived destination host, loads and resolve the class file of encrypting then with specific self defined class loader.This technology had both kept the professional platform independence of java applet, had increased the security of class file again, but used inconvenient concerning the user.
Summary of the invention
The object of the present invention is to provide a kind of method and apparatus of protecting class file, be used for solving the prevention class file by decompiling, the convenience problem that keeps cross-platform characteristic and user to use.
According to an aspect of the present invention, provide a kind of method of protecting class file, may further comprise the steps:
A, ciphering unit read the class file bytecode of required encryption, and utilize key to encrypting the class file bytecode, obtain encrypted byte sign indicating number file;
B, compilation unit will be used for verifying user's identifying code and key to being filled into local application, obtain file protection device through the source code of compiling local application;
C, file protection device utilize key to the enabling decryption of encrypted byte code files.
According to a further aspect in the invention, provide a kind of device of protecting class file, having comprised:
Ciphering unit is used to read the class file bytecode of required encryption, and utilizes key to encrypting the class file bytecode, obtains encrypted byte sign indicating number file;
Compilation unit will be used for verifying user's identifying code and key to being filled into local application, obtain file protection device through the source code of compiling local application; And
File protection device utilizes key to the enabling decryption of encrypted byte code files.
Compared with prior art; beneficial effect of the present invention is: the present invention adopts the bytecode in the document encrypting apparatus encryption class file; and adopt the file protection device that in ciphering process, generates to decipher bytecode; stoped class file by decompiling effectively; the cross-platform characteristic that has kept program simultaneously, and the user uses also more convenient.
Description of drawings
Fig. 1 is the method flow diagram of protection class file provided by the invention;
Fig. 2 is the structure drawing of device of protection class file provided by the invention;
Fig. 3 is the schematic flow sheet based on document encrypting apparatus encryption class file that the embodiment of the invention provides;
Fig. 4 is the schematic flow sheet based on file protection device deciphering class file that the embodiment of the invention provides.
Embodiment
, should be appreciated that following illustrated preferred embodiment only is used for description and interpretation the present invention, and be not used in qualification the present invention a preferred embodiment of the present invention will be described in detail below in conjunction with accompanying drawing.
Fig. 1 has shown the method flow of protection class file provided by the invention, as shown in Figure 1:
Step S101, ciphering unit read the class file bytecode of required encryption, and utilize the public key encryption class file bytecode of cipher key pair, obtain encrypted byte sign indicating number file.
Before this, need the class file that imports is carried out the judgement of file type, if the file type that can not support then finishes cryptographic operation, if supported file type then the key generation unit to obtain key by built-in algorithm right, this key is to comprising PKI that is used to encrypt and the private key that is used to decipher.Wherein, built-in algorithm is not unique, but should be able to encrypt class file, and can realize bidirectional encipher.
Class file is preserved with the form of bytecode, and ciphering unit reads the bytecode of this class file, utilizes this bytecode of public key encryption that generates in advance again.
Step S102, compilation unit will be used for verifying that user's identifying code and private key are filled into local application, obtain file protection device through the source code that compiles local application.
The authorization information acquiring unit obtains after the user environment information, utilizes predefined algorithm that its conversion is obtained being used to verify user's identifying code again, and wherein, user environment information is the hardware information of main frame, and this information should satisfy the characteristics of uniqueness.
After compiling is finished and is obtained file protection device, the former class file that deletion is read.
Step S103, file protection device utilize private key that encrypted byte sign indicating number file is decrypted.
Before deciphering, start initialized operation by JVM; call back function in the operating file protective device; call back function obtains user environment information and whether judgement mates with identifying code, does not then finish decryption oprerations if match, if coupling is then carried out dynamic load to the class file of required deciphering.Its detailed process is: by call back function self-defining local agent is registered on the defined method, when calling corresponding Java method, then tackles and call local agent to load corresponding class file.
Fig. 2 is the apparatus structure of protection class file provided by the invention, and as shown in Figure 2, this device comprises that key generation unit, ciphering unit, authorization information acquiring unit, compilation unit, file delete unit, file load unit and file protection device constitute.
It is right that the key generation unit adopts built-in algorithms to obtain key to the class file that imports, and wherein key is to comprising PKI that is used to encrypt and the private key that is used to decipher.
Ciphering unit utilizes the bytecode of the class file that public key encryption reads, and obtains encrypted byte sign indicating number file.
The authorization information acquiring unit obtains user environment information, utilizes predefined algorithm to transform the identifying code that obtains being used to verify the user again.
Compilation unit will be used for verifying that user's identifying code and private key are filled into local application, obtain file protection device through the source code that compiles local application.
The file delete unit class file that the deleted file reading unit reads after encryption is finished.
When needs are deciphered, the file load unit before deciphering be the user of user environment information and authentication code matches with encrypted byte sign indicating number file load to file protection device.
File protection device utilizes private key that encrypted byte sign indicating number file is decrypted.
Wherein, the common configuration file encryption device in key generation unit, ciphering unit, authorization information acquiring unit, compilation unit and file delete unit, document encrypting apparatus are a kind ofly can encrypt class file, and can carry out the Software tool of bidirectional encipher.
Fig. 3 has shown the flow process signal based on document encrypting apparatus encryption class file that the embodiment of the invention provides, as shown in Figure 3:
Step S301 imports to the class file that needs in the java application to encrypt in the document encrypting apparatus.
Step S302, document encrypting apparatus read the class file information of importing.
Whether the class file that step S303, document encrypting apparatus judge to import is supported file type, if not supported file type end operation then, if supported file type execution in step S304 then.
Step S304, document encrypting apparatus obtains encrypted public key and private key by built-in algorithm.
Step S305, document encrypting apparatus read the bytecode of class file.
Step S306, document encrypting apparatus utilize the bytecode of public key encryption class file, obtain encrypted byte sign indicating number file.
Step S307, document encrypting apparatus obtain user environment information, utilize predefined algorithm to transform and are verified sign indicating number.
Step S308, document encrypting apparatus is filled into identifying code and private key in the local application, and the source code of compiling local program obtains file protection device.
Step S309, the class file that the document encrypting apparatus deletion is read.
Step S310 returns encrypted byte sign indicating number file and file protection device.
Step S311, document encrypting apparatus obtain the JDK version information, replace JDK core rt.jar.
The specific implementation of the defineClass method of the ClassLoader among the rt.jar is modified, it was tackled it before system call defineClass1 nation method, make system utilize self-defined local nation method deciphering bytecode earlier, generate the Class object with the bytecode after the deciphering then and pass to system again, the work that to decipher is placed in the local code and realizes like this, thereby encryption method is reached at the local application level of security, also need not revise the JVM source code simultaneously.
Fig. 4 has shown the flow process signal based on file protection device deciphering class file that the embodiment of the invention provides, as shown in Figure 4:
Step S401 increases in start-up parameter before the java application operation :-agentlib:, the back connects the title of file protection device, does not comprise .lib or .so suffix.
Step S402, the operation java application, JVM enters initial phase, triggers the call back function of JVM initialization event in the operating file protective device.
Step S403, call back function obtain user environment information.
Step S404; judge in call back function whether this user is the authorized user of file protection device; that is to say; whether environmental information and the identifying code of judging this user mate; the then file protection device execution in step S414 end operation if not authorized user does not promptly match is if authorized user promptly mates then execution in step S405.
Step S405, the RegisterNatives function that call back function is quoted the JNI technology is registered to self-defining local agent on the defineClass1 method, like this when the corresponding Java method of system call, tackle and call local agent, rather than directly call defineClass1 nation method in the original dynamic link libraries.
Step S406, java application carry out corresponding function, and ClassLoader carries out dynamic load to encrypted byte sign indicating number file when needs call method in the encrypted byte sign indicating number file.
Step S407 loads in the encrypted byte sign indicating number file process, calls the local agent of registering in the file protection device;
Step S408 passes to proxy function automatically with encrypted byte sign indicating number file when calling local agent;
Step S409 utilizes private key to carry out the byte arrays deciphering in proxy function;
Step S410, the defineClass1 method of calling after deciphering in the dynamic link libraries generates the Class object.Wherein, if windows platform, then call and be the java_java_lang_ClassLoader_defineClass1@32 method in the dynamic link library of jvm.dll, if Linux or Unix platform then call and are the java_java_lang_ClassLoader_defineClass1 method in the dynamic link library of libjava.so.
Step S411 judges whether successfully to generate the Class object in the defineClass1 method, if successfully do not generate then end operation of Class object, then continue execution in step S412 if successfully generate the Class object.
Step S412 returns the Class object and passes to JVM, carries out function corresponding.
To realize among the Java that the interception of nation method can adopt JNI and JVMTI technology, when one of JVM loading is acted on behalf of, JVM can call the Agent_OnLoad function, if in this function, registered the VMInit incident, after the virtual machine initialization, will move the call back function of VMInit incident so, and in this call back function, obtain the JNI environment.In order to make system call defineClass1 function, in call back function, utilize the RegisterNatives method in the JNI technology defineClass1 method in the ClassLoader class to be registered as a proxy function that oneself defines, this proxy function will be called by system when moving the defineClass1 method for the Class object that generates certain class like this, this proxy function is a local function, it mainly realizes the deciphering to bytecode, and the function that calls after deciphering in the dynamic link libraries of jvm.dll or libjava.so generates the Class object.In this way, decrypting process can be placed in the local code and realize.
In sum; the present invention has following technique effect: the present invention has overcome defective and the obstacle of existing protection class file; prevent that better the Java source code from being plagiarized or attacking; the cross-platform feature that both can keep class file; make the security of protection class file reach the local application rank, need not revise again the JVM source code and regenerate Java.exe.
Although above the present invention is had been described in detail, the invention is not restricted to this, those skilled in the art can carry out various modifications according to principle of the present invention. Therefore, all modifications of doing according to the principle of the invention all should be understood to fall into protection scope of the present invention.

Claims (10)

1. a method of protecting class file is characterized in that, may further comprise the steps:
A, ciphering unit read the class file bytecode of required encryption, and utilize key to encrypting described class file bytecode, obtain encrypted byte sign indicating number file;
B, compilation unit will be used for verifying user's identifying code and key to being filled into local application, obtain file protection device through the source code of the described local application of compiling; And
C, described file protection device utilize key to deciphering described encrypted byte sign indicating number file.
2. a kind of method of protecting class file according to claim 1 is characterized in that, and is before described steps A, further comprising the steps of:
It is right that the key generation unit produces key.
3. a kind of method of protecting class file according to claim 2 is characterized in that described key is to comprising:
PKI is used to encrypt described class file bytecode; And
Private key is used to decipher described encrypted byte sign indicating number file.
4. a kind of method of protecting class file according to claim 3, it is characterized in that obtaining of described identifying code may further comprise the steps: the authorization information acquiring unit obtains user environment information, utilizes predefined algorithm to transform again and is verified sign indicating number.
5. a kind of method of protecting class file according to claim 4 is characterized in that, after described step C, and the class file that the deleted file reading unit reads.
6. a kind of method of protecting class file according to claim 5; it is characterized in that; before described step D, whether file load unit judges user environment information and identifying code mate, and for the coupling the user with described encrypted byte sign indicating number file load to file protection device.
7. a device of protecting class file is characterized in that, comprising:
Ciphering unit is used to read the class file bytecode of required encryption, and utilizes key to encrypting described class file bytecode, obtains encrypted byte sign indicating number file;
Compilation unit will be used for verifying user's identifying code and key to being filled into local application, obtain file protection device through the source code of the described local application of compiling; And
File protection device utilizes key to deciphering described encrypted byte sign indicating number file.
8. a kind of device of protecting class file according to claim 7 is characterized in that described device also comprises:
The key generation unit, it is right to be used to produce key; And
The file delete unit is used for the class file that the deleted file reading unit reads after encryption is finished.
9. a kind of device of protecting class file according to claim 8 is characterized in that described device also comprises: the authorization information acquiring unit, be used to obtain user environment information, and utilize predefined algorithm to transform again and be verified sign indicating number.
10. a kind of device of protecting class file according to claim 9; it is characterized in that; described device also comprises: the file load unit, judge before deciphering whether user environment information and identifying code mate, and to the coupling the user with described encrypted byte sign indicating number file load to file protection device.
CN2010102794939A 2010-09-13 2010-09-13 Method and device for protecting class files Pending CN101957903A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN2010102794939A CN101957903A (en) 2010-09-13 2010-09-13 Method and device for protecting class files

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN2010102794939A CN101957903A (en) 2010-09-13 2010-09-13 Method and device for protecting class files

Publications (1)

Publication Number Publication Date
CN101957903A true CN101957903A (en) 2011-01-26

Family

ID=43485228

Family Applications (1)

Application Number Title Priority Date Filing Date
CN2010102794939A Pending CN101957903A (en) 2010-09-13 2010-09-13 Method and device for protecting class files

Country Status (1)

Country Link
CN (1) CN101957903A (en)

Cited By (15)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102236757A (en) * 2011-06-30 2011-11-09 北京邮电大学 Software protection method and system applicable to Android system
CN103745141A (en) * 2013-12-02 2014-04-23 上海斐讯数据通信技术有限公司 Method for preventing application program in intelligent terminal android system from being decompiled
CN104504311A (en) * 2015-01-19 2015-04-08 炫彩互动网络科技有限公司 Safe SDK production and operation method
CN104657635A (en) * 2013-11-20 2015-05-27 方正信息产业控股有限公司 Application processing method, device and server
CN105335151A (en) * 2014-08-14 2016-02-17 优视科技有限公司 Installation file protection method and apparatus
CN106096336A (en) * 2016-06-13 2016-11-09 北京京东尚科信息技术有限公司 Software anti-crack method and system
CN106909810A (en) * 2015-12-22 2017-06-30 北京奇虎科技有限公司 A kind of method and device for realizing APK file protection
CN107545189A (en) * 2017-06-26 2018-01-05 新华三技术有限公司 A kind of file preparation method and device
CN107888565A (en) * 2017-10-19 2018-04-06 厦门集微科技有限公司 The method and apparatus of safe handling and the method and apparatus of encryption
CN108959953A (en) * 2018-03-06 2018-12-07 李明霞 The anti-amending method of intelligent computer file
CN109784007A (en) * 2018-12-04 2019-05-21 厦门中控智慧信息技术有限公司 A kind of method of byte code encryption, the method and terminal of bytecode decryption
CN110232570A (en) * 2019-05-29 2019-09-13 深圳市元征科技股份有限公司 A kind of information monitoring method and device
WO2019223094A1 (en) * 2018-05-22 2019-11-28 深圳壹账通智能科技有限公司 Block chain-based file protection method, and terminal device
CN112395564A (en) * 2020-11-17 2021-02-23 平安普惠企业管理有限公司 Protection and operation method, device, equipment and storage medium of class file
CN112631622A (en) * 2020-12-29 2021-04-09 Oppo广东移动通信有限公司 Application installation method and device, server and computer readable medium

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH10161864A (en) * 1996-11-28 1998-06-19 Nippon Telegr & Teleph Corp <Ntt> Software protection system
WO1999041651A2 (en) * 1998-02-13 1999-08-19 National Computer Board, Acting Through Its R & D Division, The Information Technology Institute Method for protecting bytecode

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH10161864A (en) * 1996-11-28 1998-06-19 Nippon Telegr & Teleph Corp <Ntt> Software protection system
WO1999041651A2 (en) * 1998-02-13 1999-08-19 National Computer Board, Acting Through Its R & D Division, The Information Technology Institute Method for protecting bytecode

Cited By (17)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102236757A (en) * 2011-06-30 2011-11-09 北京邮电大学 Software protection method and system applicable to Android system
CN104657635A (en) * 2013-11-20 2015-05-27 方正信息产业控股有限公司 Application processing method, device and server
CN103745141A (en) * 2013-12-02 2014-04-23 上海斐讯数据通信技术有限公司 Method for preventing application program in intelligent terminal android system from being decompiled
CN105335151A (en) * 2014-08-14 2016-02-17 优视科技有限公司 Installation file protection method and apparatus
CN104504311A (en) * 2015-01-19 2015-04-08 炫彩互动网络科技有限公司 Safe SDK production and operation method
CN106909810A (en) * 2015-12-22 2017-06-30 北京奇虎科技有限公司 A kind of method and device for realizing APK file protection
CN106096336B (en) * 2016-06-13 2019-01-29 北京京东尚科信息技术有限公司 Software anti-crack method and system
CN106096336A (en) * 2016-06-13 2016-11-09 北京京东尚科信息技术有限公司 Software anti-crack method and system
CN107545189A (en) * 2017-06-26 2018-01-05 新华三技术有限公司 A kind of file preparation method and device
CN107888565A (en) * 2017-10-19 2018-04-06 厦门集微科技有限公司 The method and apparatus of safe handling and the method and apparatus of encryption
CN108959953A (en) * 2018-03-06 2018-12-07 李明霞 The anti-amending method of intelligent computer file
WO2019223094A1 (en) * 2018-05-22 2019-11-28 深圳壹账通智能科技有限公司 Block chain-based file protection method, and terminal device
CN109784007A (en) * 2018-12-04 2019-05-21 厦门中控智慧信息技术有限公司 A kind of method of byte code encryption, the method and terminal of bytecode decryption
CN109784007B (en) * 2018-12-04 2021-03-12 厦门熵基科技有限公司 Byte code encryption method, byte code decryption method and terminal
CN110232570A (en) * 2019-05-29 2019-09-13 深圳市元征科技股份有限公司 A kind of information monitoring method and device
CN112395564A (en) * 2020-11-17 2021-02-23 平安普惠企业管理有限公司 Protection and operation method, device, equipment and storage medium of class file
CN112631622A (en) * 2020-12-29 2021-04-09 Oppo广东移动通信有限公司 Application installation method and device, server and computer readable medium

Similar Documents

Publication Publication Date Title
CN101957903A (en) Method and device for protecting class files
CN101872404B (en) Method for protecting Java software program
KR101471589B1 (en) Method for Providing Security for Common Intermediate Language Program
CN111656345B (en) Software module enabling encryption in container files
CN105681039A (en) Method and device for secret key generation and corresponding decryption
CN109992987B (en) Script file protection method and device based on Nginx and terminal equipment
KR101284676B1 (en) Cryptography-based copy protection system and method for android apps
CN104298932A (en) Method and device for calling SO file
CN102087605A (en) Android-based platform application installation control method and system
CN109284585B (en) Script encryption method, script decryption operation method and related device
CN102236757A (en) Software protection method and system applicable to Android system
CN104268444A (en) Cloud OS Java source code protection method
CN1960363A (en) Method and equipment for implementing remote updating information security devices through network
CN111191195A (en) Method and device for protecting APK
CN103971034A (en) Method and device for protecting Java software
CN107430650A (en) Computer program is protected to resist reverse-engineering
CN102289632A (en) Method for encrypting executable file under condition of unknown software source code
JP2009075720A (en) Information processor and information processing program
CN111159658B (en) Byte code processing method, system, device, computer equipment and storage medium
CN104200137A (en) Method for guaranteeing self-security of JAVA program
Ozkan et al. Security analysis of mobile authenticator applications
JP2013045277A (en) Program obfuscation method and remote debug system
CN113542303B (en) Software importing system and method for secret key in non-trusted environment
CN115168873A (en) Software anti-cracking method based on C + + language
CN107688729B (en) Application program protection system and method based on trusted host

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C12 Rejection of a patent application after its publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20110126