CN104200139B - The generation method of instruction code in a kind of Java software watermark void method - Google Patents
The generation method of instruction code in a kind of Java software watermark void method Download PDFInfo
- Publication number
- CN104200139B CN104200139B CN201410467066.1A CN201410467066A CN104200139B CN 104200139 B CN104200139 B CN 104200139B CN 201410467066 A CN201410467066 A CN 201410467066A CN 104200139 B CN104200139 B CN 104200139B
- Authority
- CN
- China
- Prior art keywords
- instruction
- code
- class
- java
- embedded
- 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.)
- Active
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F21/00—Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
- G06F21/10—Protecting distributed programs or content, e.g. vending or licensing of copyrighted material ; Digital rights management [DRM]
- G06F21/16—Program or content traceability, e.g. by watermarking
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F21/00—Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
- G06F21/10—Protecting distributed programs or content, e.g. vending or licensing of copyrighted material ; Digital rights management [DRM]
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Multimedia (AREA)
- Technology Law (AREA)
- Computer Hardware Design (AREA)
- Computer Security & Cryptography (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Stored Programmes (AREA)
Abstract
本发明涉及一种Java软件水印虚方法中指令代码的生成方法,基于BCEL类库,包括如下步骤:1)通过BCEL类库载入待嵌入指令的Java类文件,对所述类文件进行解析,转化成符合BCEL处理要求的Java类文件对象;2)从所述Java类文件对象中获取类文件的参数信息,所述参数信息包括类中的方法,再从获取的方法中找到并取出虚方法;3)根据获取的虚方法与参数信息创建一个新的虚方法,用于取代原先的虚方法;4)产生用于嵌入水印信息的指令代码,将它们添加到所述新虚方法的指令集合中;5)将所述新虚方法套入所述Java类文件中。有益效果为:利用本发明,可以通过计算机程序在虚方法中自动产生用于嵌入水印信息的指令代码,解决了以往需要专业人员人工编写,不具通用性,不便实际应用的问题。
The invention relates to a method for generating instruction codes in a Java software watermark virtual method, based on a BCEL class library, comprising the following steps: 1) loading a Java class file to be embedded with an instruction through the BCEL class library, and parsing the class file, Convert into a Java class file object that meets the BCEL processing requirements; 2) Obtain the parameter information of the class file from the Java class file object, the parameter information includes the method in the class, and then find and take out the virtual method from the obtained method ;3) Create a new virtual method based on the obtained virtual method and parameter information to replace the original virtual method; 4) Generate instruction codes for embedding watermark information, and add them to the instruction set of the new virtual method Middle; 5) Put the new virtual method into the Java class file. Beneficial effects are: the invention can automatically generate instruction codes for embedding watermark information in the virtual method through computer programs, which solves the problems of needing to be manually written by professionals in the past, lacking versatility, and inconvenient for practical application.
Description
技术领域technical field
本发明涉及软件水印,尤其涉及一种Java软件水印虚方法中指令代码的生成方法。The invention relates to a software watermark, in particular to a method for generating instruction codes in a Java software watermark virtual method.
背景技术Background technique
软件产业近年来迅猛发展,成为每年具有数千亿产值的重大产业。与此同时,软件产品的非法复制和盗用问题也变得非常严重,受到业内外广泛关注。软件水印是近年来出现的保护软件产品知识产权的一项技术,它在不影响软件功能的前提下在软件作品中嵌入版权保护信息或身份认证信息(即水印),当程序遭到非法复制或盗用时,可以通过提取这些信息来证明软件作品的所有权。The software industry has developed rapidly in recent years and has become a major industry with an annual output value of hundreds of billions. At the same time, the problem of illegal duplication and misappropriation of software products has also become very serious and has attracted widespread attention from both inside and outside the industry. Software watermarking is a technology that has emerged in recent years to protect the intellectual property rights of software products. It embeds copyright protection information or identity authentication information (ie watermark) in software works without affecting software functions. When the program is illegally copied or In case of misappropriation, this information can be extracted to prove the ownership of the software work.
目前,Java语言得到广泛应用,用Java语言开发的软件占有很大的比重。Java语言具有跨平台的可移植性,使用便利,同时也带来程序容易被复制和盗用的问题。研究和开发用于Java语言程序版权保护的软件水印技术具有十分重要的现实意义和应用价值。在现有的Java软件水印技术中,由Akito Monden等人最先提出的基于虚方法和类文件字节码的软件水印算法具有较好的实用性和可实现性,可用于保护Java类文件。该算法的基本思想是,在需要保护的Java程序中植入永不执行的方法,称为虚方法。由于虚方法实际不会执行,我们可以根据需要编写虚方法中的程序代码。然后在虚方法对应的字节码中,对指令的操作数进行修改或者对指令的操作码进行编码,以此来嵌入水印信息。At present, the Java language is widely used, and the software developed with the Java language occupies a large proportion. The Java language has cross-platform portability and is easy to use, but it also brings the problem that the program is easy to be copied and stolen. Research and development of software watermark technology for copyright protection of Java language programs has very important practical significance and application value. Among the existing Java software watermarking techniques, the software watermarking algorithm based on virtual method and class file bytecode first proposed by Akito Monden et al. has good practicability and realizability, and can be used to protect Java class files. The basic idea of the algorithm is to implant a method that will never be executed in the Java program that needs to be protected, which is called a virtual method. Since the virtual method will not actually be executed, we can write the program code in the virtual method as needed. Then, in the bytecode corresponding to the virtual method, modify the operand of the instruction or encode the operation code of the instruction to embed the watermark information.
对Akito Monden等提出的上述算法,现有研究的重点和成果是如何在虚方法的指令代码中通过修改操作数和编码操作码来嵌入和提取水印信息。对于虚方法中的程序代码如何产生,尚未有很好的研究。一般需要根据所嵌入的水印信息,由专业人员通过人工的方法来编写,不具有通用性,也不方便,使得该算法的实际应用受到限制。本发明提出一种通过计算机程序在虚方法中自动生成用于嵌入水印信息的指令代码的方法和技术。基于本发明,用户只要给出需要嵌入的水印信息,系统会在虚方法中自动生成相应的指令代码,无需人工介入。这样就可以设计开发出方便实用的Java软件水印应用系统。For the above algorithm proposed by Akito Monden et al., the focus and achievement of the existing research is how to embed and extract watermark information by modifying the operand and encoding the operation code in the instruction code of the virtual method. How the program code in virtual methods is generated has not been well studied. Generally, according to the embedded watermark information, it needs to be written manually by professionals, which is not universal and inconvenient, so that the practical application of the algorithm is limited. The invention proposes a method and technology for automatically generating instruction codes for embedding watermark information in virtual methods through computer programs. Based on the present invention, as long as the user provides the watermark information to be embedded, the system will automatically generate the corresponding instruction code in the virtual method without manual intervention. In this way, a convenient and practical Java software watermarking application system can be designed and developed.
发明内容Contents of the invention
本发明目的在于克服上述现有技术之不足,提供一种Java软件水印虚方法中指令代码的自动生成方法。该方法利用Apache Web服务软件提供的用于操作Java类文件的BCEL类库对给定的Java类文件进行操作。具体有以下技术方案实现:The purpose of the present invention is to overcome the above-mentioned deficiencies in the prior art, and provide a method for automatically generating instruction codes in a Java software watermark virtual method. This method uses the BCEL class library provided by Apache Web service software for manipulating Java class files to operate on given Java class files. Specifically, the following technical solutions are implemented:
所述Java软件水印虚方法中指令代码的生成方法,基于BCEL类库,具体包括如下步骤:The generation method of instruction code in the described Java software watermark virtual method, based on BCEL class storehouse, specifically comprises the steps:
1)通过BCEL类库载入待嵌入指令的Java类文件,对所述类文件进行解析,转化成符合BCEL处理要求的Java类文件对象;1) Load the Java class file of the instruction to be embedded through the BCEL class library, analyze the class file, and convert it into a Java class file object meeting the BCEL processing requirements;
2)从所述Java类文件对象中获取类文件的参数信息,所述参数信息包括类中的方法,再从获取的方法中找到并取出虚方法;2) obtain the parameter information of class file from described Java class file object, described parameter information comprises the method in the class, then finds and takes out virtual method from the method obtained;
3)根据获取的虚方法与参数信息创建一个新的虚方法,用于取代原先的虚方法;3) Create a new virtual method based on the obtained virtual method and parameter information to replace the original virtual method;
4)产生用于嵌入水印信息的指令代码,将它们添加到所述新虚方法的指令集合中;4) generate instruction codes for embedding watermark information, and add them to the instruction set of the new virtual method;
5)将所述新虚方法套入所述Java类文件中。5) Put the new virtual method into the Java class file.
所述Java软件水印虚方法中指令代码的生成方法的进一步设计在于,所述参数信息还包括所述Java类文件的类文件名与常量池。A further design of the instruction code generation method in the Java software watermark virtual method is that the parameter information also includes the class file name and constant pool of the Java class file.
所述Java软件水印虚方法中指令代码的生成方法的进一步设计在于,所述用于嵌入水印信息的指令代码的产生包括:The further design of the generation method of the instruction code in the virtual method of the Java software watermark is that the generation of the instruction code used to embed the watermark information includes:
修改操作数,对通过修改操作数嵌入水印信息的指令,进行配置操作数,组合成完整的指令,将所述指令代码添加到类中新虚方法的指令集合中;Modifying the operands, configuring the operands to embed the watermark information by modifying the operands, combining them into a complete instruction, adding the instruction code to the instruction set of the new virtual method in the class;
编码操作码,生成操作码编码码本,根据需嵌入的编码,选择相应的操作码,配置操作数,组合成完整的指令,将所述指令代码添加到类中新虚方法的指令集合中。Encode the operation code, generate the operation code code book, select the corresponding operation code according to the code to be embedded, configure the operand, combine into a complete instruction, and add the instruction code to the instruction set of the new virtual method in the class.
所述Java软件水印虚方法中指令代码的生成方法的进一步设计在于,所述修改操作数的过程可以根据嵌入水印信息的大小,通过循环语句实现与嵌入水印信息的大小对应数量的指令。The further design of the method for generating instruction codes in the Java software watermark virtual method is that the process of modifying the operands can implement a number of instructions corresponding to the size of the embedded watermark information through a loop statement according to the size of the embedded watermark information.
所述Java软件水印虚方法中指令代码的生成方法的进一步设计在于,所述修改操作数的过程具体包括如下步骤:The further design of the generation method of instruction code in the virtual method of the Java software watermark is that the process of modifying the operand specifically includes the following steps:
A)利用随机函数生成用于嵌入水印信息的指令所需的操作数;A) Utilize a random function to generate the required operands for the instruction to embed the watermark information;
B)将操作码与操作数组合成指令,存放于一临时集合中;B) Combining the operation code and the operand into an instruction and storing it in a temporary collection;
C)将所述临时集合中的指令复制到类中所述新虚方法的指令集合中。C) Copy the instructions in the temporary set to the instruction set of the new virtual method in the class.
所述Java软件水印虚方法中指令代码的生成方法的进一步设计在于,所述编码操作码的过程具体包括如下步骤:The further design of the generation method of instruction code in described Java software watermark virtual method is that, the process of described encoding operation code specifically comprises the following steps:
Ⅰ)通过映射生成码本,所述码本中的每一编码与一条指令操作码成一一映射关系;1) generate a codebook by mapping, each encoding in the codebook forms a one-to-one mapping relationship with an instruction opcode;
Ⅱ)根据需要嵌入的编码,从所述码本中找到对应的指令操作码;Ⅱ) Find the corresponding instruction opcode from the codebook according to the code to be embedded;
Ⅲ)通过随机函数产生上述指令操作码的操作数;Ⅲ) Generate the operand of the above-mentioned instruction opcode by a random function;
Ⅳ)将操作码与操作数组合成指令,存放于一临时集合中;Ⅳ) Combining the opcode and the operand into an instruction and storing it in a temporary collection;
Ⅴ)将临时集合中的指令复制到所述新虚方法的指令集合中。V) Copy the instructions in the temporary set into the instruction set of the new virtual method.
本发明提出的Java软件水印虚方法中指令代码的生成方法,可以通过计算机程序在虚方法中自动产生用于嵌入水印信息的指令代码,解决了以往需要专业人员人工编写,不具通用性,不便实际应用的问题。利用本发明,用户只要给出需要嵌入的水印信息,系统会在虚方法中自动生成相应的指令代码,无需人工介入。在此基础上,可设计开发出方便实用的Java软件水印应用系统。The method for generating instruction codes in the Java software watermark virtual method proposed by the present invention can automatically generate instruction codes for embedding watermark information in the virtual method through computer programs, which solves the need for professionals to manually write in the past, which has no versatility and is inconvenient for practice. application problem. With the present invention, as long as the user provides the watermark information to be embedded, the system will automatically generate corresponding instruction codes in the virtual method without manual intervention. On this basis, a convenient and practical Java software watermark application system can be designed and developed.
附图说明Description of drawings
图1为所述Java软件水印虚方法中指令代码的生成方法的原理框图。Fig. 1 is a functional block diagram of a method for generating instruction codes in the Java software watermark virtual method.
图2为用于测试的类文件的示意图。Figure 2 is a schematic diagram of the class files used for testing.
图3为虚方法中的指令示意图。Fig. 3 is a schematic diagram of instructions in a virtual method.
图4为虚方法中添加指令前后的对比的示意图。FIG. 4 is a schematic diagram of the comparison before and after adding instructions in the virtual method.
图5为添加指令后虚方法中的指令的示意图。FIG. 5 is a schematic diagram of instructions in a virtual method after adding instructions.
具体实施方式detailed description
下面结合附图对本发明方案进行详细说明。The solution of the present invention will be described in detail below in conjunction with the accompanying drawings.
本实施例提供的Java软件水印虚方法中指令代码的生成方法,参见图1,如下:The generation method of instruction code in the Java software watermark virtual method provided by this embodiment, referring to Fig. 1, is as follows:
第一步:通过BCEL类库载入待嵌入指令的Java类文件。假设该Java类文件的文件名为TestClass.class,路径为“D:\\测试文件\\TestClass.class”,存放这个类文件的绝对路径的字符串为targetClassfile,则载入Java类文件的实现代码为:Step 1: Load the Java class file of the instruction to be embedded through the BCEL class library. Assuming that the file name of the Java class file is TestClass.class, the path is "D:\\test file\\TestClass.class", and the character string storing the absolute path of this class file is targetClassfile, then the implementation of the Java class file is loaded The code is:
String targetClassfile="D:\\测试文件\\TestClass.class";String targetClassfile="D:\\test file\\TestClass.class";
调用BCEL类库的类文件解析器ClassParser对载入的Java类文件进行解析,以便获取其类文件名、常量池、方法等信息。相关实现代码为:Call the class file parser ClassParser of the BCEL class library to parse the loaded Java class file in order to obtain its class file name, constant pool, method and other information. The relevant implementation code is:
JavaClass jc=new ClassParser(targetClassfile).parse();JavaClass jc = new ClassParser(targetClassfile). parse();
其中,jc为解析后生成的类文件对象。Among them, jc is the file-like object generated after parsing.
将解析后的类文件对象jc包装转化成BCEL类库中ClassGen类的对象,以便调用ClassGen类的方法来获取类文件的有关信息。相关实现代码为:The parsed class file object jc package is transformed into an object of the ClassGen class in the BCEL class library, so as to call the method of the ClassGen class to obtain the relevant information of the class file. The relevant implementation code is:
ClassGen cg=new ClassGen(jc);ClassGen cg = new ClassGen(jc);
其中,cg为转化后的Java类文件对象,下面将直接使用jc和cg这两个对象。Among them, cg is the converted Java class file object, and the two objects jc and cg will be directly used below.
第二步:获取载入的Java类文件的有关信息,包括类文件名、常量池和类中的方法,从方法中找到和取出虚方法。The second step: obtain the relevant information of the loaded Java class file, including the class file name, the constant pool and the method in the class, and find and take out the virtual method from the method.
类文件名和常量池通过cg对象获取。类文件名通过调用ClassGen类的getClassName()方法获得:The class file name and constant pool are obtained through the cg object. The class file name is obtained by calling the getClassName() method of the ClassGen class:
String cname=cg.getClassName();String cname = cg. getClassName();
常量池通过调用ClassGen类的getConstantPool()方法取得:The constant pool is obtained by calling the getConstantPool() method of the ClassGen class:
ConstantPoolGen cpg=cg.getConstantPool();ConstantPoolGen cpg = cg.getConstantPool();
类中的方法通过jc对象获取,从jc对象中获取类中所有方法的代码为:The methods in the class are obtained through the jc object, and the code to obtain all the methods in the class from the jc object is:
Method[]methods=jc.getMethods();Method[] methods = jc.getMethods();
根据虚方法名从所有方法中找到虚方法,假定虚方法名为“dummy”,相关实现代码为:Find the virtual method from all methods according to the virtual method name. Assume that the virtual method name is "dummy", and the relevant implementation code is:
将虚方法从类中取出也是通过cg对象进行,调用ClassGen类的removeMethod(method)方法:The virtual method is also taken out of the class through the cg object, and the removeMethod(method) method of the ClassGen class is called:
cg.removeMethod(method);cg. removeMethod(method);
其中,method表示的是上面找到的虚方法methods[index],此处即名为“dummy”的方法。Among them, method represents the virtual method methods[index] found above, here is the method named "dummy".
第三步:根据上面获得的类文件名、常量池和虚方法的信息创建一个新的虚方法,用于取代原先的虚方法。这通过调用BCEL类库中用于处理方法的MethodGen类实现:Step 3: Create a new virtual method based on the class file name, constant pool and virtual method information obtained above to replace the original virtual method. This is achieved by calling the MethodGen class in the BCEL class library for processing methods:
MethodGen mg=new MethodGen(method,cname,cpg);MethodGen mg = new MethodGen(method,cname,cpg);
其中,cname、cpg是原类文件名和常量池,method为原虚方法,mg为生成的MethodGen类的对象。Among them, cname and cpg are the original class file name and constant pool, method is the original virtual method, and mg is the object of the generated MethodGen class.
第四步:获取新建虚方法的指令集合,通过上述MethodGen类的对象mg获得:Step 4: Obtain the instruction set of the newly created virtual method through the object mg of the above MethodGen class:
InstructionList lst=mg.getInstructionList();InstructionList lst = mg. getInstructionList();
然后向该指令集合中添加用于嵌入水印信息的指令。可以通过调用MethodGen类的insert()方法向指令集合中插入指令。以添加一条“bipush”指令为例,实现代码为:Then add instructions for embedding watermark information to the instruction set. Instructions can be inserted into the instruction set by calling the insert() method of the MethodGen class. Take adding a "bipush" instruction as an example, the implementation code is:
lst.insert(newBIPUSH((byte)1));lst.insert(newBIPUSH((byte)1));
实际添加的指令与嵌入的水印信息有关,需要通过专门的方法产生,后面单独说明。在得到这些指令后,将它们复制到上述新建虚方法的指令集合中。The actual added instructions are related to the embedded watermark information and need to be generated by a special method, which will be described separately later. After getting these instructions, copy them to the instruction set of the above-mentioned new virtual method.
第五步:将新建的包含用于嵌入水印信息的指令代码的虚方法恢复到原来的类中,通过调用ClassGen类的addMethod方法和MethodGen类的getMethod方法实现。实现代码为:Step 5: restore the newly created virtual method containing the instruction code for embedding the watermark information to the original class, and implement it by calling the addMethod method of the ClassGen class and the getMethod method of the MethodGen class. The implementation code is:
cg.addMethod(mg.getMethod());cg. addMethod(mg. getMethod());
其中,getMethod方法没有参数,恢复后的虚方法名仍为原来的名称,此处即为dummy。Among them, the getMethod method has no parameters, and the restored virtual method name is still the original name, which is dummy here.
下面给出一具体实例进行说明,假定测试的类文件取名为TestClass.class,如图2所示,类中含有四个方法,方法名分别为:func1、func2、func3和dummy(注意<init>是Java类文件自有的方法,不是用户定义的方法)。其中,dummy方法为虚方法,点击“[0]Code”,可查看dummy方法中的指令,如图3所示。A specific example is given below to illustrate, assuming that the test class file is named TestClass.class, as shown in Figure 2, the class contains four methods, and the method names are: func1, func2, func3 and dummy (note that <init > is a Java class file's own method, not a user-defined method). Among them, the dummy method is a virtual method. Click "[0]Code" to view the instructions in the dummy method, as shown in Figure 3.
此处以添加一条“bipush”指令为例进行测试,实现上述各步骤功能的程序如下所示,有关注释说明附在程序语句中。Here we take adding a "bipush" instruction as an example to test. The program to realize the functions of the above steps is as follows, and the relevant notes are attached to the program statement.
运行测试程序,完成虚方法中指令代码自动生成的各个步骤。再次查看类文件中虚方法中的指令,并与原来的指令进行对比,可见在原有4条指令的基础上,增加了一条“bipush”指令,参见图4,图中左侧部分为原有的指令,右侧是新增指令后。测试结果正确,实现了预期的功能。Run the test program to complete the steps of automatic generation of instruction codes in the virtual method. Check the instructions in the virtual method in the class file again and compare them with the original instructions. It can be seen that on the basis of the original 4 instructions, a "bipush" instruction has been added. See Figure 4. The left part of the figure is the original command, the right side is after the new command. The test results are correct and the expected functions are realized.
下面进一步说明用于嵌入水印信息的指令代码的产生。根据基于字节码的Java软件水印算法,水印信息可以通过修改指令的操作数和编码指令的操作码两种方式嵌入。The generation of instruction codes for embedding watermark information will be further described below. According to the bytecode-based Java software watermarking algorithm, watermark information can be embedded in two ways by modifying the operand of the instruction and encoding the opcode of the instruction.
修改操作数:本实施例中通过修改操作数嵌入水印信息的指令有3条:bipush、sipush、iinc,其中iinc带有2个操作数。为这3条指令配置操作数,组合成完整的指令代码,然后将这些指令代码添加到类中新建虚方法的指令集合中。具体实现步骤如下:Modification of operands: In this embodiment, there are three instructions for embedding watermark information by modifying operands: bipush, sipush, iinc, wherein iinc has 2 operands. Configure operands for these three instructions, combine them into complete instruction codes, and then add these instruction codes to the instruction set of the new virtual method in the class. The specific implementation steps are as follows:
第一步,利用随机函数生成这三条指令所需的操作数。实现代码为:In the first step, a random function is used to generate the required operands for these three instructions. The implementation code is:
第二步,将操作码与操作数组合成指令,存放于一临时集合中,实现代码为:In the second step, the operation code and the operand array are synthesized into instructions and stored in a temporary collection. The implementation code is:
第三步,将临时集合中的指令复制到类中新建虚方法的指令集合中。实现代码为:The third step is to copy the instructions in the temporary collection to the instruction collection of the new virtual method in the class. The implementation code is:
for(intn=0;n<instructionList.size();n++){for(intn=0;n<instructionList.size();n++){
lst.add(instructionList.get(n)); lst.add(instructionList.get(n));
}}
其中,lst是类中新建虚方法的指令集合。Among them, lst is a set of instructions for creating a new virtual method in the class.
进一步的,上述代码在指令集合中只生成了三条可嵌入水印的指令,在实际应用中可以根据嵌入水印信息的大小,利用循环语句生成更多的指令。Furthermore, the above code only generates three watermark-embeddable instructions in the instruction set, and in practical applications, more instructions can be generated by using loop statements according to the size of the embedded watermark information.
编码操作码:使用指令的操作码对水印信息进行编码来嵌入水印信息,编码包括英文字母与阿拉伯数字。本实施例中,假定水印信息由小写英文字母组成,从Java虚拟机指令中选取26条指令,用其操作码对26个英文字母进行编码,码本如表1所示。Encoding operation code: Use the operation code of the instruction to encode the watermark information to embed the watermark information, and the encoding includes English letters and Arabic numerals. In this embodiment, it is assumed that the watermark information is composed of lowercase English letters, 26 instructions are selected from the Java virtual machine instructions, and the 26 English letters are encoded with their operation codes. The codebook is shown in Table 1.
表1 用操作码对26个英文字母进行编码Table 1 Encode 26 English letters with operation code
根据需要嵌入的英文信息,对每个字母,按照上述码本选择相应的操作码编写指令。具体实现步骤如下:According to the English information to be embedded, for each letter, select the corresponding operation code according to the above codebook to write instructions. The specific implementation steps are as follows:
第一步,通过映射(Map)生成表1所示的码本。表中码本的每一编码与一条指令操作码成一一映射关系,故有26条映射语句。本实施例中为节省篇幅,此处假设需要嵌入的水印信息为“ntu”,下面仅给出编码n、t、u这三个字母(对应的操作码是fmul、arraylength和anewarray)的实现代码,其它23条Map映射语句类似,予以省略:In the first step, the codebook shown in Table 1 is generated through mapping (Map). Each code in the codebook in the table forms a one-to-one mapping relationship with an instruction operation code, so there are 26 mapping statements. In this embodiment, in order to save space, it is assumed that the watermark information to be embedded is "ntu", and only the implementation codes for encoding the three letters n, t, and u (the corresponding operation codes are fmul, arraylength, and anewarray) are given below , the other 23 Map mapping statements are similar and omitted:
Map<Character,String>HELPER=new HashMap();Map<Character, String>HELPER=new HashMap();
HELPER.put(Character.valueOf('n'),"FMUL");HELPER. put(Character. valueOf('n'), "FMUL");
HELPER.put(Character.valueOf('t'),"ARRAYLENGTH");HELPER. put(Character. valueOf('t'), "ARRAYLENGTH");
HELPER.put(Character.valueOf('u'),"ANEWARRAY");HELPER. put(Character. valueOf('u'), "ANEWARRAY");
第二步,根据需要嵌入的英文字母,从上述码本中找到对应的指令操作码。实现代码为:The second step is to find the corresponding instruction opcode from the above codebook according to the English letters to be embedded. The implementation code is:
第三步,通过随机函数产生上述指令的操作数。实现代码为:In the third step, the operands of the above instructions are generated through a random function. The implementation code is:
第四步,将操作码与操作数组合成指令,存放于一临时集合中。以嵌入“ntu”为例,相应的实现代码为:The fourth step is to combine the operation code and the operand into an instruction, and store it in a temporary collection. Take embedding "ntu" as an example, the corresponding implementation code is:
上述代码中省略了组合其它23条指令的if语句,在此不再赘述。The if statement combining the other 23 instructions is omitted in the above code, and will not be repeated here.
第五步,将临时集合中的指令复制到类中新建虚方法的指令集合中。实现代码与前面修改操作数的相同,不再重复给出。The fifth step is to copy the instructions in the temporary collection to the instruction collection of the new virtual method in the class. The implementation code is the same as that of modifying the operand above, and will not be repeated here.
在将上述生成的指令复制到类中新建虚方法的指令集合后,再次运行程序进行测试,查看类中虚方法中的指令,参见图5,可见在原有4条指令的基础上增加了3条对“ntu”进行编码的指令,结果正确,实现了预期的功能。After copying the above-mentioned generated instructions to the instruction set of the new virtual method in the class, run the program again for testing, and check the instructions in the virtual method in the class. See Figure 5, it can be seen that 3 instructions have been added on the basis of the original 4 instructions The instruction to encode "ntu", the result is correct, and achieves the expected function.
Claims (5)
- A kind of 1. generation method of instruction code in Java software watermark void method, based on BCEL class libraries, it is characterised in that including Following steps:1) the java class file of instruction to be embedded, and the class file resolver for passing through BCEL class libraries are loaded into by BCEL class libraries ClassParser is parsed to the class file, and the class file object jc packagings after parsing are changed into BCEL class libraries The object of ClassGen classes;2) parameter information of class file is obtained from the java class file object, the parameter information includes the method in class, Found again from the method for acquisition and take out empty method, the method in the class is led to by jc object acquisitions, the acquisition of empty method The removeMethod methods for crossing ClassGen classes are realized;3) according to one new empty method of empty method and parameter information creating of acquisition, for substituting original empty method;The step Suddenly by calling the MethodGen classes in BCEL class libraries for processing method to realize;4) instruction code for being embedded in watermark information is produced, the instruction code is added to the instruction set of the new empty method In conjunction;The instruction set of the new empty method is obtained by the object mg of the MethodGen classes;Then into the instruction set Add the instruction for being embedded in watermark information;5) the new empty method is inserted in the java class file;In step 4), include for being embedded in the generation of instruction code of watermark information:Operand is changed, the instruction to being embedded in watermark information by changing operand, carries out configuration operand, is combined into complete Instruction, the instruction code is added in class in the instruction set of new empty method;Encoding operation code, generation command code coding code book, according to the coding that need to be embedded in, select corresponding command code, configuration operation Number, is combined into complete instruction, the instruction code is added in class in the instruction set of new empty method.
- 2. the generation method of instruction code in Java software watermark void method according to claim 1, it is characterised in that institute Stating parameter information also includes the class file name and constant pool of the java class file.
- 3. the generation method of instruction code in Java software watermark void method according to claim 1, it is characterised in that institute The process of modification operand is stated according to the size of embedded watermark information, the size with embedded watermark information is realized by Do statement The instruction of respective amount.
- 4. the generation method of instruction code in Java software watermark void method according to claim 1, it is characterised in that institute The process for stating modification operand specifically comprises the following steps:A random function) is utilized to generate the operand for being embedded in needed for the instruction of watermark information;B command code) is synthesized into instruction with groups of operands, deposited in an interim set;C) instruction in the interim set is copied to described in class in the instruction set of new empty method.
- 5. the generation method of instruction code in Java software watermark void method according to claim 3, it is characterised in that institute The process for stating encoding operation code specifically comprises the following steps:I) code book is generated by mapping, each coding and an instruction operation code in the code book are into mapping relations one by one;II) coding being embedded in as needed, finds corresponding instruction operation code from the code book;III) operand of above-mentioned instruction operation code is produced by random function;IV) command code is synthesized into instruction with groups of operands, deposited in an interim set;V) instruction in interim set is copied in the instruction set of the new empty method.
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201410467066.1A CN104200139B (en) | 2014-09-12 | 2014-09-12 | The generation method of instruction code in a kind of Java software watermark void method |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201410467066.1A CN104200139B (en) | 2014-09-12 | 2014-09-12 | The generation method of instruction code in a kind of Java software watermark void method |
Publications (2)
| Publication Number | Publication Date |
|---|---|
| CN104200139A CN104200139A (en) | 2014-12-10 |
| CN104200139B true CN104200139B (en) | 2017-11-24 |
Family
ID=52085432
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN201410467066.1A Active CN104200139B (en) | 2014-09-12 | 2014-09-12 | The generation method of instruction code in a kind of Java software watermark void method |
Country Status (1)
| Country | Link |
|---|---|
| CN (1) | CN104200139B (en) |
Families Citing this family (3)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN108363910B (en) * | 2018-01-23 | 2020-01-10 | 南通大学 | Webpage watermark embedding and extracting method based on HTML (Hypertext markup language) code |
| CN108509776B (en) * | 2018-04-11 | 2020-04-17 | 北京指掌易科技有限公司 | Page processing method and device and electronic terminal |
| CN115202735B (en) * | 2022-07-21 | 2026-02-03 | 中国平安人寿保险股份有限公司 | Asset list generation method, device, equipment and storage medium |
Citations (1)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN103714271A (en) * | 2013-09-30 | 2014-04-09 | 南通大学 | Contradictory construction method of Java-software watermark-embedding dummy method |
Family Cites Families (1)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| JP2004362532A (en) * | 2002-10-25 | 2004-12-24 | Matsushita Electric Ind Co Ltd | Watermark insertion device and watermark extraction device |
-
2014
- 2014-09-12 CN CN201410467066.1A patent/CN104200139B/en active Active
Patent Citations (1)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN103714271A (en) * | 2013-09-30 | 2014-04-09 | 南通大学 | Contradictory construction method of Java-software watermark-embedding dummy method |
Non-Patent Citations (2)
| Title |
|---|
| 一种Java软件水印植入虚方法的永假式构造;李奎等;《计算机科学》;20131215;第40卷(第12期);第211-214页 * |
| 基于字节码的Java软件水印的研究与实现;王春红等;《微电子学与计算机》;20090905;第26卷(第9期);第146-149页 * |
Also Published As
| Publication number | Publication date |
|---|---|
| CN104200139A (en) | 2014-12-10 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| TWI648648B (en) | Protection method of executable program on android platform | |
| US10409966B2 (en) | Optimizing and protecting software | |
| Boespflug et al. | The λΠ-calculus Modulo as a Universal Proof Language. | |
| CN102136053B (en) | Method and device for protecting source code of executable file | |
| CN104091100A (en) | Software protection method based on intermediate result compiling | |
| CN112163195B (en) | A method of virtual machine software protection based on stack hiding | |
| CN107729725A (en) | A kind of Android applications hardened system and method based on virtual machine instructions modification | |
| CN108363911B (en) | Python script obfuscating and watermarking method and device | |
| CN107632832B (en) | A dalvik-oriented bytecode control flow obfuscation method | |
| BRPI0614089A2 (en) | method to prevent software reverse engineering, unauthorized modification and interception of runtime data | |
| CN106682460A (en) | Code obfuscation method based on two transformations | |
| CN104200139B (en) | The generation method of instruction code in a kind of Java software watermark void method | |
| KR101536920B1 (en) | Method of Obfuscating Files Based on Advanced RISC Machine Processor | |
| CN116611032A (en) | Method, system and storage medium for embedding and extracting software watermark in JAR package | |
| Andrey et al. | A Technique for Analyzing Bytecode in a Java Project for the Purpose of an Automated Assessment of the Possibility and Effectiveness of the Hidden Investment of Information and its Volumes in a Java Project | |
| CN104572102A (en) | Chinese garbled solution in JAVA | |
| CN107533614B (en) | Device for storing data and storage medium | |
| CN103106356A (en) | Method for generating code in safe environment and improving software protection intensity | |
| Jeon et al. | A robust steganography-based software watermarking | |
| Arnold et al. | Specifying and verifying sparse matrix codes | |
| Chionis et al. | Evaluating the WaterRpg software watermarking model on Java application programs | |
| CN103714271B (en) | A kind of Java software watermark implants the contradiction building method of empty method | |
| Jang et al. | Protecting Android applications with steganography-based software watermarking | |
| CN104765986A (en) | Steganography-based code protecting and restoring method | |
| CN102902548A (en) | Method and device for generating assembly level memory duplicate standard library function |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| C06 | Publication | ||
| PB01 | Publication | ||
| C10 | Entry into substantive examination | ||
| SE01 | Entry into force of request for substantive examination | ||
| GR01 | Patent grant | ||
| GR01 | Patent grant |