The content of the invention
The present invention provides guard method and the protection system of a kind of file destination, and obj files are protected, can be increased
The scope of protection, adds the difficulty of decompiling and analysis, substantially increases the security of software.
In order to solve the above-mentioned technical problem, the invention provides a kind of guard method of file destination, it includes:For soft
The function protected the need in each file destination used in part is carried out after dis-assembling, and the instruction to function is deformed, and
Insertion rubbish instruction in function, so as to be protected to form the Global Macros to software to each file destination.
Preferably, specifically including following steps:
S10:The functional symbol in file destination is analyzed, and selects to need the corresponding functional symbol of function to be protected;
S20:According to the coding rule of machine code instruction, to it is described need to function to be protected carry out dis-assembling so that by machine
Device instruction decompiles into assembly language directive;
S30:Using the deformation command template being pre-designed, the flexible instruction in the assembly language directive is carried out
Instruction is replaced;
S40:Rubbish instruction is inserted at select location in the assembly language directive;
S50:Change the functional symbol;
S60:The command byte code of the modification need function to be protected.
If preferably, there is jump instruction inside function, also included between step S40 and step S50:
S41:According between jump instruction and the destination address redirected because instruction deformation and rubbish instruct increased skew
The change occurred, modifies to jump instruction.
If preferably, there is data symbol in file destination, step S10 also includes analyzing the data symbol, and
Also include between step S50 and step S60:
S51:Change the data symbol.
If preferably, resetting bit sign in file destination, step S10 also includes analyzing the reorientation symbol
Number, and also include between step S50 and step S60:
S52:Bit sign is reset described in modification.
Preferably, step S51 is specially:Step S51 is specially:All symbol tables in file destination are swept
Retouch, according to position and the length of rubbish instruction of the length instructed after the position of instruction deformation and deformation, and rubbish instruction insertion
Degree, to change the position of the data symbol.
Preferably, step S52 is specially:Step S52 is specially:All bit signs that reset in file destination are carried out
Scan, instruct what the position of insertion and rubbish were instructed according to the length instructed after the position of instruction deformation and deformation, and rubbish
Length, described bit sign is reset to change.
Preferably, step S50 is specially:Step S50 is specially:All symbol tables in file destination are swept
Retouch, according to position and the length of rubbish instruction of the length instructed after the position of instruction deformation and deformation, and rubbish instruction insertion
Degree, to change position and the length of the functional symbol.
Preferably, step S60 is specially:Instruction, insertion after the presumptive instruction of the function protected as needed, deformation
Rubbish instruction, amended jump instruction, come change the function after being handled through protection command byte code.
Present invention also offers a kind of protection system of the file destination based on above-mentioned method, including:
Analysis module, it is configured to analyze the functional symbol in file destination;
Dis-assembling module, it is configured to the coding rule according to machine code instruction, it would be desirable to which the machine of the function of protection refers to
It is assembly language directive to make decompiling;
Deformation module, it is configured to using the deformation command template being pre-designed to described in dis-assembling module generation
Flexible instruction in assembly language directive carries out instruction replacement;
Rubbish instruction insertion module, it is configured to insertion rubbish at the select location in the assembly language directive and referred to
Order;
Repair module, it is configured to enter the need function to be protected for having carried out instruction deformation and rubbish instruction insertion
Row is repaired and other functional symbols is accordingly repaired;The instruction of function after to being handled through protection is repaired, with life
Into the file destination after protection.
If preferably, there is jump instruction inside function, the repair module is additionally configured to include to be protected to needing
Jump instruction inside function is repaired.
Preferably, the analysis module is additionally configured to analyze the data symbol in file destination, if in file destination
There is data symbol, the repair module is additionally configured to include repairing data symbol.
Preferably, the analysis module, which is additionally configured to analyze in file destination, resets bit sign, if file destination
In reset bit sign, the repair module is additionally configured to include counterweight sprocket bit to be repaired.
Preferably, the mode concrete configuration that the repair module is repaired to functional symbol is:To in file destination
All symbol tables be scanned, according to the length that instructs after the position of instruction deformation and deformation, and rubbish instruction insertion
Position and the length of rubbish instruction, carry out position and the length of repair function symbol.
Preferably, the mode concrete configuration that instruction of the repair module to the function after protection is repaired is:Root
According to instruction, rubbish instruction, the amended jump instruction of insertion after needing the presumptive instruction of function to be protected, deforming, to repair
The command byte code of function after being handled again through protection.
Preferably, the repair module is to needing the mode that the jump instruction inside function to be protected is repaired specific
It is configured to:According between jump instruction and the destination address redirected by instruction deformation and rubbish instruction it is increased skew occurred
Change, to be repaired to jump instruction.
Preferably, the mode concrete configuration that the repair module is repaired to data symbol is:To in file destination
All symbol tables be scanned, according to the position of the length that instructs after the position deformation of instruction deformation, and rubbish instruction insertion
Put and rubbish instruction length, come the position of repair data symbol.
Preferably, the mode concrete configuration that the repair module counterweight sprocket bit is repaired is:To file destination
In all bit signs that reset be scanned, inserted according to the length that instructs after the position deformation of instruction deformation, and rubbish instruction
The position entered and the length of rubbish instruction, bit sign is reset to repair.
Compared with prior art, the guard method of file destination of the invention and the beneficial effect of protection system are:It is logical
Cross the functional symbol analyzed first in obj files, reset bit sign, data symbol, selection needs the corresponding letter of function to be protected
Numerical symbol, dis-assembling is carried out to function, and the instruction to function is deformed, and rubbish instruction, repair function are inserted in the middle of instruction
Jump instruction, repair the functional symbol in obj files, data symbol, reset bit sign, so as to software one entirety of formation
Protection.Obj files are protected, the scope of protection can be increased, the difficulty of decompiling and analysis is added, greatly improves
The security of software.
Embodiment
It is to the guard method of the file destination of embodiments of the invention and protection with specific embodiment below in conjunction with the accompanying drawings
System is described in further detail, but not as a limitation of the invention.
Fig. 1 is the schematic flow sheet of the guard method of the file destination of embodiments of the invention.Embodiments of the invention
The guard method of file destination includes:Dis-assembling is carried out for the function protected the need in each file destination for being used in software
Afterwards, the instruction to function is deformed, and inserts rubbish instruction in function, so as to be protected to be formed to each file destination
To the Global Macros of software.
The method that the embodiment of the present invention is used comprises the following steps:
S10:The functional symbol in file destination is analyzed, and selects to need the corresponding functional symbol of function to be protected;
S20:According to the coding rule of machine code instruction, to needing function to be protected to carry out dis-assembling, so that machine be referred to
Order decompiles into assembly language directive;
S30:Using the deformation command template being pre-designed, the flexible instruction in assembly language directive is instructed
Replace;
S40:Rubbish instruction is inserted at select location in assembly language directive;
S50:Modification growth function symbol;Including needing function to be protected and without the functional symbol protected, understanding thoroughly, do not have
The functional symbol of protection may be protected the influence of function, it is also desirable to change, for example, there may be three connected functors
Number, and need to protect middle function, then the position of the functional symbol of the 3rd function can be changed certainly.
S60:Modification needs the command byte code of function to be protected.
The guard method of the file destination of the present invention, by analyzing the functional symbol in obj files first, selection needs to protect
The functional symbol of shield, dis-assembling is carried out to function, and instruction is deformed, and rubbish instruction, repair function are inserted in the middle of instruction
Jump instruction, repair obj files in functional symbol so as to software formation one integrally protect, to obj files carry out
Protection, can increase the scope of protection, add the difficulty of decompiling and analysis, substantially increase the security of software.
As the improvement of the present invention, if there is jump instruction inside function, gone back between step S40 and step S50
Including:S41:According between jump instruction and the destination address redirected by instruction deformation and rubbish instruction it is increased skew sent out
Raw change, modifies to jump instruction.In actual conditions, if there is jump instruction inside function, due to needing protection
Function in instruction deformed, insert rubbish instruction, cause the skew that jump instruction is redirected to be changed, according to
Between jump instruction and the destination address redirected, due to instructing deformation and the increased skew of rubbish instruction to repair jump instruction
Change.
As a further improvement, if there is data symbol in file destination, step S10 also includes analyze data and accorded with
Number, and also include S51 between step S50 and step S60:Change data symbol.As on the other hand, if had in file destination
Bit sign is reset, then step S10 is also reset including analysis also includes S52 between bit sign, and step S50 and step S60:Modification
Reset bit sign.
Further, with reference to the above, if having data symbol in obj files, to all symbols in file destination
Number table is scanned, according to position and the rubbish of the length instructed after the position of instruction deformation and deformation, and rubbish instruction insertion
The length of rubbish instruction, to change the position of data symbol.On the other hand, if resetting bit sign in obj files, modification weight
All bit signs that reset in file destination are scanned by sprocket bit, according to instruction after the position of instruction deformation and deformation
Length, and rubbish instruction insertion position and rubbish instruction length, reset bit sign to change.
As further improving, step S50 is specially:All symbol tables in file destination are scanned, root
According to position and the length of rubbish instruction of the length instructed after the position of instruction deformation and deformation, and rubbish instruction insertion, come
The position of Modification growth function symbol and length.As the preferred embodiment of the present embodiment, step S60 is specially:Protect as needed
Rubbish instruction, the amended jump instruction of instruction, insertion after the presumptive instruction of the function of shield, deformation, to change through protection
The command byte code of function after processing.
As Fig. 2 for embodiments of the invention file destination protection system each modular structure schematic diagram shown in, this hair
It is bright to additionally provide a kind of protection system of the file destination based on above-mentioned method, including:
Analysis module, it is configured to analyze the functional symbol in file destination, and can be further configured to analyze mesh
Mark in the data symbol in file, and analysis file destination and reset bit sign (illustrating in detail below);
Dis-assembling module, it is configured to the coding rule according to machine code instruction, it would be desirable to which the machine of the function of protection refers to
It is assembly language directive to make decompiling;
Deformation module, it is configured to the assembler language generated using the deformation command template being pre-designed to dis-assembling module
Flexible instruction in instruction carries out instruction replacement;
Rubbish instruction insertion module, it is configured to insert rubbish instruction at the select location in assembly language directive;
Repair module, its function for being configured to protect the need for having carried out instruction deformation and rubbish instruction insertion is repaiied
It is multiple, and according to foregoing teachings, repair module also needs to be configured to accordingly to repair other functional symbols, for example, do not protect
The functional symbol of shield, such as positional information, can also may be influenceed, therefore should be located accordingly by need function to be protected
Reason.Repair module to being handled through protection after the instruction of function repair, to generate the file destination after protection.Wherein, it is right
The mode that functional symbol is repaired can be using being scanned, according to instruction deformation to all symbol tables in file destination
The length instructed behind position and deformation, and the length that the position of rubbish instruction insertion and rubbish are instructed, carry out repair function symbol
Position and length;The mode that instruction to the function after protection is repaired can use the original for the function protected as needed
Rubbish instruction, the amended jump instruction of instruction, insertion after beginning instruction, deformation, to repair the function after being handled through protection
Command byte code.
With reference to the description of foregoing guard method of the invention, due to needing function to be protected to carry out instruction deformation
Instruct and insert with rubbish, repair module is needed to needing the jump instruction inside function to be protected to repair, to functional symbol
Repaired, data symbol is repaired, counterweight sprocket bit is repaired, the instruction to the function after protection is repaiied
It is multiple, the obj files after generation protection.That is:
If there is jump instruction inside function, repair module is additionally configured to include to needing redirecting inside function to be protected
Instruction repaired, concrete mode can use according between jump instruction and the destination address redirected due to instruction deformation and rubbish
The increased skew of rubbish instruction change occurred, to be repaired to jump instruction;
Whether analysis module is also analyzed in file destination has data symbol, if there is data symbol in file destination, repairs
Module is additionally configured to include repairing data symbol, and concrete mode can use to enter all symbol tables in file destination
Go and scan, instruct what the position inserted and rubbish were instructed according to the length instructed after the position deformation for instructing deformation, and rubbish
Length, comes the position of repair data symbol;
Analysis module also analyzes in file destination whether reset bit sign, if resetting bit sign in file destination,
Repair module is additionally configured to include counterweight sprocket bit to be repaired, and concrete mode can be used to all heavy in file destination
Sprocket bit is scanned, according to the length that instructs after the position deformation of instruction deformation, and rubbish instruction insertion position and
The length of rubbish instruction, bit sign is reset to repair.
For the objects, technical solutions and advantages of the present invention are more clearly understood, develop simultaneously embodiment referring to the drawings, right
The present invention is further described.
Below by taking the obj files of lower 32 of Microsoft's Windows systems as an example, to describe to apply for the protection that embodiment is provided
Detailed process.Obj file formats in Microsoft's Windows operating system are coff file forms.COFF is referred to as general object text
Part form, COFF full name is Common Object File Format, and the file destination that the compiler of Microsoft is produced is exactly
Coff file form.
Coff file structure is as shown in figure 3, main header structure (COFF HEADER), section structure (Section
Headers), sector data (Raw Data).The specific definition of coff file various pieces see Microsoft's windows systems
Online Help, excessive introduction is not done herein.
For convenience of explanation, this gives a specific obj file, this paper obj files realize one
The function of string length is sought, file name is strlen.obj.
The C language source code of Obj files is:
As shown in figure 1, the detailed step protected to obj files is:
1. analyzing the functional symbol in obj files, bit sign, data symbol are reset;
Functional symbol in the present embodiment in strlen.obj is strlen, and nothing resets bit sign, no data symbol.
2. selection needs functional symbol to be protected;
The function that protection is selected in the present embodiment is strlen.
3. dis-assembling module is utilized, according to the coding rule of machine code instruction, to needing function to be protected to carry out dis-assembling,
Machine instruction is decompiled into assembler language;
After strlen function dis-assemblings, the assembler language of generation is as follows:
The assembly code of strlen functions is in strlen.obj files:
4. utilizing deformation module, the instruction for the function protected as needed utilizes the instruction mould after the deformation being pre-designed
Version, is replaced to instruction;
In the present embodiment, ret instructions are deformed, ret instructions code of equal value is:
5. using rubbish instruction insertion module, needing inside function to be protected, position, insertion rubbish instruction are selected;
In the present embodiment rubbish is all inserted into strlen.obj files behind every assembly instruction of strlen functions
Rubbish instruction is not inserted into behind instruction, the last item assembly instruction.
In the present embodiment, the rubbish of insertion, which is instructed, is
If 6. there is jump instruction inside function, jump instruction is changed using repair module, due to needing letter to be protected
Instruction in number is deformed, and is inserted rubbish instruction, is caused the skew that jump instruction is redirected to be changed, according to redirecting
Because instruction deformation and the increased skew of rubbish instruction are repaiied to jump instruction between the destination address centre for instructing and redirecting
Change;
Needed in the present embodiment modification first jump instruction be
7. all symbols in obj files are scanned by Modification growth function symbol, according to the position of instruction deformation and rubbish
The position of insertion is instructed, position and the length of symbol is changed;
The position of strlen functional symbols is constant in the present embodiment, and length increase, increased length instructs for the flower of insertion
Length and because deformation ret instructs increased length.
If 8. having data symbol in obj files, be scanned to all symbol tables in obj files, become according to instruction
The length instructed behind the position of shape and deformation, instructs the length that the position of insertion and rubbish are instructed according to rubbish, changes data symbols
Number position;
In the present embodiment without data symbol, it is not necessary to change.
9. if reset bit sign in obj files, modification resets bit sign, to all reorientations in obj files
Symbol is scanned, and the position of insertion is instructed according to the position of instruction deformation and rubbish, and modification resets bit sign;
Bit sign is not reset in the present embodiment, it is not necessary to changed.
10. modification needs function instruction bytecode to be protected, after the presumptive instruction of the function protected as needed, deformation
Instruction, rubbish instruction, the amended jump instruction of insertion, the instruction of the function after modification protection;
In the present embodiment, according to the presumptive instruction of strlen functions, the ret instructions after deformation, the rubbish instruction of insertion
And two amended jump instructions, the instruction of the strlen functions after modification protection.
Analysis module, analyzes the functional symbol in obj files, resets bit sign, data symbol;
Dis-assembling module, is assembly language directive by machine instruction decompiling according to the machine instruction of function;
Deformation module, to needing function to be protected, dis-assembling is carried out using dis-assembling module, assembly language directive is generated,
Instruction replacement is carried out to the instruction that can be deformed using the deformation command template being pre-designed;
Rubbish instruction insertion module, to needing function to be protected, dis-assembling, generation compilation language are carried out using dis-assembling module
Speech instruction, is being needed inside function to be protected, selects position, insertion rubbish instruction;
Repair module, due to needing function to be protected to carry out instruction deformation and rubbish instruction insertion, it is necessary to needs
Jump instruction inside the function of protection is repaired, and functional symbol is repaired, and data symbol is repaired, to resetting
Bit sign is repaired, and the instruction to the function after protection is repaired, the obj files after generation protection.
Compared with prior art, the guard method of file destination of the invention and the beneficial effect of protection system are:It is logical
Cross the functional symbol analyzed first in obj files, reset bit sign, data symbol, selection needs functional symbol to be protected, to letter
Number carries out dis-assembling, and instruction is deformed, and rubbish instruction is inserted in the middle of instruction, and obj is repaired in the jump instruction of repair function
Functional symbol, data symbol in file, reset bit sign, thus to software formation one integrally protect, obj files are entered
Row protection, can increase the scope of protection, add the difficulty of decompiling and analysis, substantially increase the security of software.
Above example is only the exemplary embodiment of the present invention, is not used in the limitation present invention, protection scope of the present invention
It is defined by the claims.Those skilled in the art can make respectively in the essence and protection domain of the present invention to the present invention
Modification or equivalent substitution are planted, this modification or equivalent substitution also should be regarded as being within the scope of the present invention.