CN109409036A - Control stream based on redundant code obscures method and device, storage medium and terminal - Google Patents
Control stream based on redundant code obscures method and device, storage medium and terminal Download PDFInfo
- Publication number
- CN109409036A CN109409036A CN201811091895.9A CN201811091895A CN109409036A CN 109409036 A CN109409036 A CN 109409036A CN 201811091895 A CN201811091895 A CN 201811091895A CN 109409036 A CN109409036 A CN 109409036A
- Authority
- CN
- China
- Prior art keywords
- basic
- redundant code
- basic block
- piece
- code segment
- 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
Links
- 238000000034 method Methods 0.000 title claims abstract description 31
- 230000006870 function Effects 0.000 claims description 52
- 238000003780 insertion Methods 0.000 claims description 50
- 230000037431 insertion Effects 0.000 claims description 50
- 230000004048 modification Effects 0.000 claims description 7
- 238000012986 modification Methods 0.000 claims description 7
- 239000004744 fabric Substances 0.000 claims description 3
- 241000208340 Araliaceae Species 0.000 claims 1
- 235000005035 Panax pseudoginseng ssp. pseudoginseng Nutrition 0.000 claims 1
- 235000003140 Panax quinquefolius Nutrition 0.000 claims 1
- 235000008434 ginseng Nutrition 0.000 claims 1
- 238000010586 diagram Methods 0.000 description 6
- 238000005516 engineering process Methods 0.000 description 2
- 230000009286 beneficial effect Effects 0.000 description 1
- 238000010276 construction Methods 0.000 description 1
- 235000013399 edible fruits Nutrition 0.000 description 1
- 230000000694 effects Effects 0.000 description 1
- 239000012634 fragment Substances 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR 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/12—Protecting executable software
- G06F21/14—Protecting executable software against software analysis or reverse engineering, e.g. by obfuscation
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)
- Storage Device Security (AREA)
Abstract
A kind of control stream based on redundant code obscures method and device, storage medium and terminal, which comprises preset redundant code segment is inserted into source code, to the corresponding original control levelling exhibition of the source code;Be inserted into redundant code segment is controlled to execute at random in the control stream after open and flat.Above-mentioned scheme can increase the reversed analysis difficulty for controlling stream after obscuring, improve the protection of software.
Description
Technical field
The present invention relates to software technology fields, obscure method and dress more particularly to a kind of control stream based on redundant code
It sets, storage medium and terminal.
Background technique
Many software applications operate in the environment of attacker fully controls the operation of software application, and attacker can taste
It tries to carry out reverse engineering to the code of software application, to obtain access to security information or even to understand the operation of software
To reappear or modify the function of software application.A variety of reverse engineering tools can be used in attacker, such as, code analysis instrument and
Debugger, to obtain information relevant to software application.Therefore, multiple technologies are developed to be difficult to attacker to software
Carry out reverse engineering.
Code obfuscation is one of the mode of a variety of reverse engineering difficulties for making code.Code obfuscation is wanted creation and is difficult to
Code obfuscation, can be used to hide the purpose or logic of software application, to prevent to software by the obfuscated codes for allowing people to understand
Using being distorted or reverse engineering.
Controlling levelling exhibitionization is a kind of for resisting this effective and known technology reversely analyzed.But it is existing
Levelling exhibitionization is controlled, although the basic block after obscuring is difficult intuitively to analyze its sequence that executes, the execution of basic block is suitable
Sequence be it is fixed, this allows for that sequence can be executed by dynamic debugging or semiology analysis analysis come obtain basic block, obtains
Execution sequence after taking further according to basic block further rebuilds original control stream, can achieve the effect that antialiasing, deposits
In the low problem of reversed analysis difficulty.
Summary of the invention
Present invention solves the technical problem that be how to increase obscure after control the reversed analysis difficulty of stream, improve the guarantor of software
Shield dynamics.
In order to solve the above technical problems, the embodiment of the invention provides a kind of control stream side of obscuring based on redundant code
Method, which comprises
Preset redundant code segment is inserted into source code, to the corresponding original control levelling exhibition of the source code;
Be inserted into redundant code segment is controlled to execute at random in the control stream after open and flat.
Optionally, described that preset redundant code segment is inserted into source code, with corresponding to the source code
Original control levelling exhibition, comprising:
Obtain the information of the basic block of the source code;
Acquired basic block is analyzed, determines insertion position of the redundant code segment in acquired basic block
It sets;
The redundant code segment is inserted into identified insertion position;
The basic block of the redundant code segment will be not inserted into as a basic piece, and the redundant code segment will be inserted into
Basic block is divided into corresponding two basic pieces by boundary of identified insertion position;
The state value and attribute value of obtained basic piece are identified respectively;
Sequence is executed in the corresponding original control flow chart of the source code according to basic block, after the basic piece
Be identified after basic piece, obtain it is open and flat after control stream.
Optionally, acquired basic block is analyzed when described, determines the redundant code segment acquired
Insertion position in basic block, comprising:
Judge the basic block whether called with existence function in the basic block of the source code;
When determining the basic block that there is existence function to call, first language of the basic block that identified existence function is called
The insertion position is used as before sentence.
Optionally, described that acquired basic block is divided when the determining basic block called without existence function
Analysis, determines insertion position of the redundant code segment in acquired basic block, further includes:
At least one basic block in the basic block is revised as to the basic block of existence function calling, and will be obtained after modification
The insertion position is used as before the first statement of basic block.
It is optionally, described to be inserted into the redundant code segment in identified insertion position, comprising:
Construct the redundant code segment;The redundant code segment is for creating the first variable, and use is in the insertion position
The second active structure's variable expression formula is set to obtain first variable progress assignment;
A nuisance parameter is added in the basic block that the existence function calls, and modifies the basic block that the existence function calls
In parameter list when calling corresponding function, be passed to using first variable as parameter.
Optionally, the subsequent basic piece to the basic piece is identified, comprising:
The state value and branch's Boolean of the subsequent basic piece of the basic piece are identified respectively;Branch's Boolean is used
Branch where the subsequent basic piece for identifying the basic piece.
Optionally, the be inserted into redundant code segment of the control executes at random in open and flat control stream, comprising:
Branch's Boolean of attribute value and subsequent basic piece based on previous basic piece determines the subsequent basic of previous basic piece
Piece, as incoming current basic piece;
Based on the attribute value of current basic piece, judge current basic piece as basic block or the redundant code segment;
When determining current basic piece is basic block, the state value of corresponding basic block is returned;
It is random to generate the first numerical value and second value when determining current basic piece is redundant code segment;
When the numerical value generated at random is the first numerical value, the state value of the redundant code segment is returned;
When the numerical value generated at random is second value, based on the current basic attribute value of piece and its branch's cloth of subsequent basic piece
Value of determines the subsequent basic piece of current basic block, stops as incoming next basic piece, when until returning to a state value.
The embodiment of the invention also provides a kind of control stream obfuscator based on redundant code, described device include:
Open and flat unit, suitable for being inserted into preset redundant code segment in source code, to the corresponding original of the source code
Begin to control levelling exhibition;
Control unit, the redundant code segment suitable for controlling be inserted into execute at random in the control stream after open and flat.
Optionally, the open and flat unit, the information of the basic block suitable for obtaining the source code;To acquired basic
Block is analyzed, and determines insertion position of the redundant code segment in acquired basic block;In identified insertion position
Set the insertion redundant code segment;The basic block of the redundant code segment will be not inserted into as a basic piece, and will be inserted
The basic block for entering the redundant code segment is divided into corresponding two basic pieces by boundary of identified insertion position;Respectively
The state value and attribute value of obtained basic piece are identified;According to basic block in the corresponding original control of the source code
Execute sequence in flow chart processed, the subsequent basic piece of the basic piece be identified, obtain it is open and flat after control stream.
Optionally, whether the open and flat unit has existence function tune in the basic block suitable for judging the source code
Basic block;When determining the basic block that there is existence function to call, basic block that identified existence function is called
The insertion position is used as before first statement.
Optionally, the open and flat unit is further adapted for when the determining basic block called without existence function, by the base
At least one basic block in this block is revised as the basic block of existence function calling, and by the first of the basic block obtained after modification
The insertion position is used as before sentence.
Optionally, the open and flat unit is suitable for constructing the redundant code segment;The redundant code segment is for creating
First variable, and assignment is carried out to first variable using the second structure's variable expression formula active on the insertion position
It obtains;A nuisance parameter is added in the basic block that the existence function calls, and modifies the basic of the existence function calling
Parameter list in block when calling corresponding function is passed to using first variable as parameter.
Optionally, the open and flat unit, suitable for the state value and branch's cloth respectively to the subsequent basic piece of the basic piece
Value of is identified;Branch's Boolean is used to identify the branch where the subsequent basic piece of the basic piece.
Optionally, described control unit, the branch boolean suitable for attribute value and subsequent basic piece based on previous basic piece
Value, determines the subsequent basic piece of previous basic piece, as incoming current basic piece;Based on the attribute value of current basic piece, sentence
Disconnected current basic piece is basic block or the redundant code segment;When determining current basic piece is basic block, returns and correspond to
Basic block state value;It is random to generate the first numerical value and second value when determining current basic piece is redundant code segment;
When the numerical value generated at random is the first numerical value, the state value of the redundant code segment is returned;When the numerical value generated at random is
When second value, based on the current basic attribute value of piece and its branch's Boolean of subsequent basic piece, current basic block is determined
Subsequent basic piece stops as incoming next basic piece, when until returning to a state value.
The embodiment of the invention also provides a kind of computer readable storage mediums, are stored thereon with computer instruction, special
Sign is that the computer instruction executes the control stream described in any of the above embodiments based on redundant code when running and obscures method
Step.
The embodiment of the invention also provides a kind of terminal, including memory and processor, energy is stored on the memory
Enough computer instructions run on the processor, when the processor runs the computer instruction described in any of the above-described
The control stream based on redundant code the step of obscuring method.
Compared with prior art, the technical solution of the embodiment of the present invention has the advantages that
Above-mentioned scheme, by being inserted into preset redundant code segment in source code, with corresponding to the source code
Original control levelling exhibition, and control be inserted into redundant code segment and executed at random in the control stream after open and flat, so that open and flat
The execution sequence of the basic block in control stream afterwards has a variety of versions, the fixed control stream phase with basic block execution sequence
Than the reversed analysis difficulty for controlling stream after obscuring can be increased, so as to improve the protection of software.
Detailed description of the invention
Fig. 1 is that a kind of control stream based on redundant code of the embodiment of the present invention obscures the flow diagram of method;
Fig. 2 is the flow diagram that redundant code segment how is inserted into source code of the embodiment of the present invention;
Fig. 3 is that the redundant code segment for how controlling insertion of the embodiment of the present invention executes at random in the control stream after open and flat
Flow diagram;
Fig. 4 is the structural schematic diagram of control stream obfuscator of one of the embodiment of the present invention based on redundant code.
Specific embodiment
Technical solution in the embodiment of the present invention in source code by being inserted into preset redundant code segment, to institute
State the corresponding original control levelling exhibition of source code, and control be inserted into redundant code segment in the control stream after open and flat with
Machine executes, so that the execution sequence of the basic block in the control stream after open and flat has a variety of versions, executes with basic block suitable
The fixed control stream of sequence is compared, and can increase reversed analysis difficulty, so as to improve the protection of software.
It is understandable to enable above-mentioned purpose of the invention, feature and beneficial effect to become apparent, with reference to the accompanying drawing to this
The specific embodiment of invention is described in detail.
Fig. 1 is that a kind of control stream based on redundant code of the embodiment of the present invention obscures the flow diagram of method.Referring to
Fig. 1, a kind of control stream based on redundant code obscure method, may include:
Step S101: being inserted into preset redundant code segment in source code, to the corresponding original control of the source code
Levelling exhibition processed.
Step S102: the be inserted into redundant code segment of control executes at random in the control stream after open and flat.
Above-mentioned scheme, by being inserted into preset redundant code segment in source code, to the source code pair
The original control levelling exhibition answered, and control be inserted into redundant code segment and executed at random in the control stream after open and flat, so that
The execution sequence of the basic block in control stream after open and flat has a variety of versions, the fixed control with basic block execution sequence
Stream is compared, and can increase reversed analysis difficulty, so as to improve the protection of software.
Preset redundant code segment is inserted into source code in the embodiment of the present invention below in conjunction with Fig. 2, it is right
The method of the corresponding original control levelling exhibition of the source code is described in detail.
As shown in Fig. 2, the method for the corresponding original control levelling exhibition of one of embodiment of the present invention source code, specifically
It can be realized using following operation:
Step S201: the information of the basic block of the source code is obtained.
In specific implementation, in compiler construction, basic block is straight-line code sequence, does not have branch other than entrance, is removed
Exit does not have a branch.This limited form makes basic block be very suitable to analyze.As the first step of analytic process, compiling
Broken down into program would generally be its basic block by device.Basic block forms vertex or node in controlling stream graph.
Step S202: analyzing acquired basic block, determines the redundant code segment acquired basic
Insertion position in block.
In specific implementation, can whether be deposited first with one or more in the basic block for constituting the source code
Judged in the basic block of function call.Wherein:
When having basic block in the multiple basic blocks for determining the source code, the basic block note of function call can will be present
For basic block R;
When determining the basic block called without existence function, then can by the basic block for constituting the source code extremely
A few basic block, is denoted as basic block S, is revised as the basic block of existence function calling, i.e., basic block S is revised as basic block R.
Specifically, the function that basic block S is realized can be realized using an independent function, and basic block is revised as calling this solely
Vertical function, so that basic block S is revised as basic block R.
When determining basic block R, it can will be used as the insertion position before the first statement of basic block R, also will
The redundant code segment is placed in front of the basic block R.
Step S203: the redundant code segment is inserted into identified insertion position.
In specific implementation, when the redundant code segment is inserted into identified insertion position, institute can be constructed first
State redundant code segment.In an embodiment of the present invention, when constructing the redundant code segment, can be become by creation first
Amount is denoted as variable m, and carries out assignment operation to variable m using the second variable active on insertion position.Then, base is modified
Calling function in this block R adds a nuisance parameter for it, which does not influence the execution knot of the function in basic block
Fruit, and parameter list when calling the function in basic block R is modified, it is passed to using variable m as parameter.
Be finished aforesaid operations when, the redundant code segment can be inserted in corresponding insertion position, namely
It is inserted into before the first statement of the basic block R.
Step S204: will be not inserted into the basic block of the redundant code segment as a basic piece, and will be described in insertion
The basic block of redundant code segment is divided into corresponding two basic pieces by boundary of identified insertion position.
It in specific implementation, can be with when insertion position before redundant code to be inserted into one or more basic block R
Fragment is carried out to obtained basic block after being inserted into the redundant code.Specifically, the redundant code can will be inserted into
The basic block of segment is divided into corresponding two basic pieces by boundary of identified insertion position.In other words, obtained two
A basic piece includes the basic piece that redundant code segment before being inserted in the first statement of the basic block R is constituted and described
The basic piece that basic block R is constituted.
Other of the source code described for composition are not inserted into the basic block of the redundant code segment, then are directly made
For corresponding one basic piece.
Step S205: the state value and attribute value of obtained basic piece are identified respectively.
In specific implementation, the state value of basic piece is the unique identification of basic piece, and inherence implies between basic piece
Context can be mapped to obtain between state value and basic piece using default rule.
In specific implementation, it is the basic of composition source code that the attribute value of the basic piece, which is used to identify the basic piece,
Block or the redundant code segment.For example, set N for the attribute for the basic block for constituting original control stream, and by redundancy generation
The attribute value for the basic piece that chip segment is constituted is set as R.In this way, can be determined basic by the attribute value for obtaining basic block
Piece is basic block or redundant code segment.
Step S206: executing sequence in the corresponding original control flow chart of the source code according to basic block, right
The subsequent basic piece of the basic piece is identified, obtain it is open and flat after control stream.
In specific implementation, suitable according to execution of the basic block in the corresponding original control flow chart of the source code
Sequence is identified the subsequent basic piece of the basic piece, is according to basic in the corresponding original controlling stream graph of source code
The context of piece is identified the subsequent basic piece of each basic piece using subsequent label, such as PNe.Wherein, Mei Geji
The subsequent number of this film can be 0,1,2.For example, corresponding branch's Boolean can be set when the number of subsequent basic piece is 1
It is set to 1;When the number of subsequent basic piece is 2, respectively using branch's Boolean 0 and 1 indicate two of the basic piece it is different
Individual path.
By execute above-mentioned operation can obtain it is open and flat after control stream.
In specific implementation, execute it is open and flat after control stream when, can attribute value based on previous basic piece and subsequent
Branch's Boolean of basic piece, when determining the subsequent basic piece of previous basic piece, such as can by creating a dispenser configuration,
And by constantly update Distribution status value come control it is open and flat after control stream execution.In other words, basic piece can each will make
For a distribution node, the distributor carries out the distribution of current basic piece according to Distribution status value, and in current basic piece point
When distributing complete, branch's Boolean of attribute value and subsequent basic piece based on previous basic piece determines next pending shape
State value, and next pending state value is set by Distribution status value, above-mentioned operation is recycled, until returning to a state
Stop when value, specifically refers to Fig. 3.
Fig. 3 shows one of embodiment of the present invention control redundant code and holds at random in the control stream after open and flat
The flow diagram of capable method.Referring to Fig. 3, control of the redundant code after open and flat can be controlled using following operation
It is executed at random in stream:
Step S301: branch's Boolean of attribute value and subsequent basic piece based on previous basic piece determines previous basic piece
Subsequent basic piece, as incoming current basic piece.
Wherein, the subsequent basic piece is the subsequent basic piece of previous basic piece, namely current basic piece.
Step S302: the attribute value based on current basic piece judges current basic piece as basic block or the redundancy generation
Chip segment;When the judgment result is yes, step S303 can be executed;Conversely, can then execute step S304.
In specific implementation, when determining the state value of current pending current basic piece, basic piece can be based on
Corresponding relationship between state value determines pending current basic piece, and by obtaining the corresponding attribute of current basic piece
Value judges current basic piece as basic block or redundant code segment.
For example, redundant code segment is constituted basic when setting N for the attribute for constituting the basic block of original control stream
When the attribute value of piece is set as R, by judging that the attribute value of current basic piece is N or R, it can determine that current basic piece is
Basic block or redundant code segment.
Step S303: the state value of corresponding basic block is returned.
In specific implementation, when the attribute value based on acquired current basic piece, determine that current basic piece is basic block
When, then the current basic state value of piece namely the state value of corresponding basic block are returned to, and execution is current basic in main flow
Piece.
Step S304: random to generate the first numerical value or the second number when determining current basic piece is redundant code segment
Value, and judge the numerical value generated at random as the first numerical value or second value;It, can when the numerical value generated at random is the first numerical value
To execute step S305;Conversely, can then execute step S306.
In specific implementation, when the attribute value based on acquired current basic piece, determine that current basic piece is redundancy generation
When chip segment, then it can use random function and generate the first numerical value or second value, such as 0 or 1.
Step S305: the state value of the redundant code is returned.
In specific implementation, when the numerical value generated at random is the first numerical value, such as 0, then it can return to the redundant code
State value.
It in specific implementation,, can be based on working as when such as second value being 1 when the numerical value generated at random is second value
Branch's Boolean of the attribute value of preceding basic piece and its subsequent basic piece determines the subsequent basic piece of current basic block, as biography
The next pending basic piece entered, namely restart to execute from step S301.
From the above description it can be seen that in runs software, through the redundant code segment of control insertion after open and flat
Executed at random in control stream, can to have a certain difference between the execution sequence of basic piece every time, it is open and flat after control
Stream basic piece execution sequence variation pattern quantity with insertion redundant code segment number increase exponentially
The growth of type, therefore the difficulty reversely analyzed can be increased, improve the dynamics of software protection.
The above-mentioned method in the embodiment of the present invention is described in detail, below will be to the above-mentioned corresponding dress of method
It sets and is introduced.
Fig. 4 shows the structural representation of control stream obfuscator of one of the embodiment of the present invention based on redundant code
Figure.Control stream obfuscator 40 based on redundant code as shown in Figure 4, may include open and flat unit 401 and control unit
402, in which:
The open and flat unit 401, suitable for being inserted into preset redundant code segment in source code, to the source code pair
The original control levelling exhibition answered;
Described control unit 402, the redundant code segment suitable for controlling be inserted into execute at random in the control stream after open and flat.
In specific implementation, the open and flat unit 401, the information of the basic block suitable for obtaining the source code;To institute
The basic block of acquisition is analyzed, and determines insertion position of the redundant code segment in acquired basic block;Really
The redundant code segment is inserted into fixed insertion position;The basic block for being not inserted into the redundant code segment is basic as one
Piece, and the basic block for being inserted into the redundant code segment is divided into corresponding two bases by boundary of identified insertion position
This film;The state value and attribute value of obtained basic piece are identified respectively;According to basic block in the source code pair
Execute sequence in the original control flow chart answered, the subsequent basic piece of the basic piece be identified, obtain it is open and flat after
Control stream.
In an embodiment of the present invention, the open and flat unit 401, in the basic block suitable for judging the source code whether
The basic block called with existence function;When determining the basic block that there is existence function to call, by identified existence function
The insertion position is used as before the first statement of the basic block of calling.
In an embodiment of the present invention, the open and flat unit 401 is further adapted for when the determining base called without existence function
When this block, at least one basic block in the basic block is revised as to the basic block of existence function calling, and will obtain after modification
The insertion position is used as before the first statement of the basic block arrived.
In an embodiment of the present invention, the open and flat unit 401 is suitable for constructing the redundant code segment;The redundancy
Code snippet uses the second structure's variable expression formula active on the insertion position to described for creating the first variable
First variable carries out assignment and obtains;A nuisance parameter is added in the basic block that the existence function calls, and is deposited described in modification
Parameter list in the basic block of function call when calling corresponding function is passed to using first variable as parameter.
In an embodiment of the present invention, the open and flat unit 401, suitable for respectively to the subsequent basic piece of the basic piece
State value and branch's Boolean are identified;Branch's Boolean is used to identify where the subsequent basic piece of the basic piece
Branch.
In specific implementation, described control unit 402, suitable for attribute value and subsequent basic piece based on previous basic piece
Branch's Boolean determines the subsequent basic piece of previous basic piece, as incoming current basic piece;Category based on current basic piece
Property value, judge current basic piece as basic block or the redundant code segment;When determining current basic piece is basic block, return
Return the state value of corresponding basic block;It is random to generate the first numerical value and the when determining current basic piece is redundant code segment
Two numerical value;When the numerical value generated at random is the first numerical value, the state value of the redundant code segment is returned;When what is generated at random
When numerical value is second value, based on the current basic attribute value of piece and its branch's Boolean of subsequent basic piece, current base is determined
The subsequent basic piece of this block stops as incoming next basic piece, when until returning to a state value.
The embodiment of the invention also provides a kind of computer readable storage mediums, are stored thereon with computer instruction, described
The step of control stream based on redundant code obscures method is executed when computer instruction is run.Wherein, it is described based on
The control stream of redundant code obscures method and refers to being discussed in detail for preceding sections, repeats no more.
The embodiment of the invention also provides a kind of terminal, including memory and processor, energy is stored on the memory
Enough computer instructions run on the processor, the processor executed when running the computer instruction it is described based on
The step of control stream of redundant code obscures method.Wherein, the control stream based on redundant code is obscured method and is referred to
Being discussed in detail for preceding sections, repeats no more.
Using the above scheme in the embodiment of the present invention, by being inserted into preset redundant code segment in source code,
With to the corresponding original control levelling exhibition of the source code, and control control of the be inserted into redundant code segment after open and flat
It is executed at random in stream, so that the execution sequence of the basic block in the control stream after open and flat has a variety of versions, with basic block
The fixed control stream of execution sequence is compared, and can increase the reversed analysis difficulty that stream is controlled after obscuring, so as to improve software
Protection.
Those of ordinary skill in the art will appreciate that all or part of the steps in the various methods of above-described embodiment is can
It is completed with instructing relevant hardware by program, which can store in computer readable storage medium, and storage is situated between
Matter may include: ROM, RAM, disk or CD etc..
Although present disclosure is as above, present invention is not limited to this.Anyone skilled in the art are not departing from this
It in the spirit and scope of invention, can make various changes or modifications, therefore protection scope of the present invention should be with claim institute
Subject to the range of restriction.
Claims (16)
1. a kind of control stream based on redundant code obscures method characterized by comprising
Preset redundant code segment is inserted into source code, to the corresponding original control levelling exhibition of the source code;
Be inserted into redundant code segment is controlled to execute at random in the control stream after open and flat.
2. the control stream according to claim 1 based on redundant code obscures method, which is characterized in that described in original generation
It is inserted into preset redundant code segment in code, to the corresponding original control levelling exhibition of the source code, comprising:
Obtain the information of the basic block of the source code;
Acquired basic block is analyzed, determines insertion position of the redundant code segment in acquired basic block
It sets;
The redundant code segment is inserted into identified insertion position;
The basic block of the redundant code segment will be not inserted into as a basic piece, and the redundant code segment will be inserted into
Basic block is divided into corresponding two basic pieces by boundary of identified insertion position;
The state value and attribute value of obtained basic piece are identified respectively;
Sequence is executed in the corresponding original control flow chart of the source code according to basic block, after the basic piece
Be identified after basic piece, obtain it is open and flat after control stream.
3. the control stream according to claim 2 based on redundant code obscures method, which is characterized in that when described to being obtained
The basic block taken is analyzed, and determines insertion position of the redundant code segment in acquired basic block, comprising:
Judge the basic block whether called with existence function in the basic block of the source code;
When determining the basic block that there is existence function to call, first language of the basic block that identified existence function is called
The insertion position is used as before sentence.
4. the control stream according to claim 3 based on redundant code obscures method, which is characterized in that when determination does not have
It is described that acquired basic block is analyzed when the basic block that existence function calls, determine the redundant code segment in institute
Insertion position in the basic block of acquisition, further includes:
At least one basic block in the basic block is revised as to the basic block of existence function calling, and will be obtained after modification
The insertion position is used as before the first statement of basic block.
5. the control stream according to claim 3 based on redundant code obscures method, which is characterized in that described to determine
Insertion position be inserted into the redundant code segment, comprising:
Construct the redundant code segment;The redundant code segment is for creating the first variable, and use is in the insertion position
The second active structure's variable expression formula is set to obtain first variable progress assignment;
A nuisance parameter is added in the basic block that the existence function calls, and modifies the basic block that the existence function calls
In parameter list when calling corresponding function, be passed to using first variable as parameter.
6. the control stream according to any one of claims 2 to 5 based on redundant code obscures method, which is characterized in that institute
It states and the subsequent basic piece of the basic piece is identified, comprising:
The state value and branch's Boolean of the subsequent basic piece of the basic piece are identified respectively;Branch's Boolean is used
Branch where the subsequent this film for identifying the basic piece.
7. the control stream according to claim 6 based on redundant code obscures method, which is characterized in that the control is inserted
The redundant code segment entered executes at random in open and flat control stream, comprising:
Branch's Boolean of attribute value and subsequent basic piece based on previous basic piece determines the subsequent basic of previous basic piece
Piece, as incoming current basic piece;
Based on the attribute value of current basic piece, judge current basic piece as basic block or the redundant code segment;
When determining current basic piece is basic block, the state value of corresponding basic block is returned;
It is random to generate the first numerical value and second value when determining current basic piece is redundant code segment;
When the numerical value generated at random is the first numerical value, the state value of the redundant code segment is returned;
When the numerical value generated at random is second value, based on the current basic attribute value of piece and its branch's cloth of subsequent basic piece
Value of determines the subsequent basic piece of current basic block, stops as incoming next basic piece, when until returning to a state value.
8. a kind of control stream obfuscator based on redundant code characterized by comprising
Open and flat unit, suitable for being inserted into preset redundant code segment in source code, to the corresponding original of the source code
Begin to control levelling exhibition;
Control unit, the redundant code segment suitable for controlling be inserted into execute at random in the control stream after open and flat.
9. the control stream obfuscator according to claim 8 based on redundant code, which is characterized in that the open and flat list
Member, the information of the basic block suitable for obtaining the source code;Acquired basic block is analyzed, determines the redundancy generation
Insertion position of the chip segment in acquired basic block;The redundant code segment is inserted into identified insertion position;It will
The basic block of the redundant code segment is not inserted into as a basic piece, and the basic block that the redundant code segment will be inserted into
Corresponding two basic pieces are divided by boundary of identified insertion position;Respectively to the state value of obtained basic piece and
Attribute value is identified;Sequence is executed in the corresponding original control flow chart of the source code according to basic block, to institute
The subsequent basic piece for stating basic piece is identified, obtain it is open and flat after control stream.
10. the control stream obfuscator according to claim 9 based on redundant code, which is characterized in that the open and flat list
Member, the basic block whether called with existence function in the basic block suitable for judging the source code;Exist when determining to have
When the basic block of function call, the insertion is used as before the first statement for the basic block that identified existence function is called
Position.
11. the control stream obfuscator according to claim 10 based on redundant code, which is characterized in that the open and flat list
Member is further adapted for repairing at least one basic block in the basic block when the determining basic block called without existence function
It is changed to the basic block of existence function calling, and the insertion position will be used as before the first statement of the basic block obtained after modification
It sets.
12. the control stream obfuscator according to claim 11 based on redundant code, which is characterized in that the open and flat list
Member is suitable for constructing the redundant code segment;The redundant code segment is for creating the first variable, and use is in the insertion
The second active structure's variable expression formula obtains first variable progress assignment on position;It is called in the existence function
A nuisance parameter is added in basic block, and modifies the ginseng in the basic block that the existence function calls when calling corresponding function
Ordered series of numbers table is passed to using first variable as parameter.
13. according to the described in any item control stream obfuscators based on redundant code of claim 9 to 12, which is characterized in that
The open and flat unit, suitable for respectively to the subsequent basic piece of the basic piece state value and branch's Boolean be identified;Institute
Branch's Boolean is stated for identifying the branch where the subsequent this film of the basic piece.
14. the control stream obfuscator according to claim 13 based on redundant code, which is characterized in that the control is single
Member determines the subsequent base of previous basic piece suitable for branch's Boolean of attribute value and subsequent basic piece based on previous basic piece
This film, as incoming current basic piece;Based on the attribute value of current basic piece, judge current basic piece as basic block or institute
State redundant code segment;When determining current basic piece is basic block, the state value of corresponding basic block is returned;It is current when determining
It is random to generate the first numerical value and second value when basic piece is redundant code segment;When the numerical value generated at random is the first numerical value
When, return to the state value of the redundant code segment;When the numerical value generated at random is second value, based on current basic piece
Branch's Boolean of attribute value and its subsequent basic piece determines the subsequent basic piece of current basic block, as incoming next base
This film stops when until returning to a state value.
15. a kind of computer readable storage medium, is stored thereon with computer instruction, which is characterized in that the computer instruction
The step of perform claim requires 1 to 7 described in any item control streams based on redundant code to obscure method when operation.
16. a kind of terminal, which is characterized in that including memory and processor, storing on the memory can be at the place
The computer instruction run on reason device, perform claim requires any one of 1 to 7 institute when the processor runs the computer instruction
The step of control stream based on redundant code stated obscures method.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201811091895.9A CN109409036A (en) | 2018-09-19 | 2018-09-19 | Control stream based on redundant code obscures method and device, storage medium and terminal |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201811091895.9A CN109409036A (en) | 2018-09-19 | 2018-09-19 | Control stream based on redundant code obscures method and device, storage medium and terminal |
Publications (1)
Publication Number | Publication Date |
---|---|
CN109409036A true CN109409036A (en) | 2019-03-01 |
Family
ID=65465053
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201811091895.9A Pending CN109409036A (en) | 2018-09-19 | 2018-09-19 | Control stream based on redundant code obscures method and device, storage medium and terminal |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN109409036A (en) |
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN112199667A (en) * | 2020-09-30 | 2021-01-08 | 常熟理工学院 | Software protection method, device, equipment and storage medium |
CN112199643A (en) * | 2020-09-30 | 2021-01-08 | 常熟理工学院 | Obfuscation method, device, equipment and storage medium for program flattening |
CN117436040A (en) * | 2023-12-18 | 2024-01-23 | 常熟理工学院 | Opaque predicate-based code confusion method, system and storage medium |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106650339A (en) * | 2016-10-13 | 2017-05-10 | 国网江苏省电力公司电力科学研究院 | Control flow complication-based Java code obfuscation method |
US20170242671A1 (en) * | 2016-02-18 | 2017-08-24 | Qualcomm Innovation Center, Inc. | Semantically sensitive code region hash calculation for programming languages |
CN107229848A (en) * | 2017-06-12 | 2017-10-03 | 北京洋浦伟业科技发展有限公司 | A kind of code reinforcement means and device |
CN107632832A (en) * | 2017-09-27 | 2018-01-26 | 电子科技大学 | One kind obscures method towards dalvik bytecode controlling streams |
-
2018
- 2018-09-19 CN CN201811091895.9A patent/CN109409036A/en active Pending
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20170242671A1 (en) * | 2016-02-18 | 2017-08-24 | Qualcomm Innovation Center, Inc. | Semantically sensitive code region hash calculation for programming languages |
CN106650339A (en) * | 2016-10-13 | 2017-05-10 | 国网江苏省电力公司电力科学研究院 | Control flow complication-based Java code obfuscation method |
CN107229848A (en) * | 2017-06-12 | 2017-10-03 | 北京洋浦伟业科技发展有限公司 | A kind of code reinforcement means and device |
CN107632832A (en) * | 2017-09-27 | 2018-01-26 | 电子科技大学 | One kind obscures method towards dalvik bytecode controlling streams |
Cited By (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN112199667A (en) * | 2020-09-30 | 2021-01-08 | 常熟理工学院 | Software protection method, device, equipment and storage medium |
CN112199643A (en) * | 2020-09-30 | 2021-01-08 | 常熟理工学院 | Obfuscation method, device, equipment and storage medium for program flattening |
CN117436040A (en) * | 2023-12-18 | 2024-01-23 | 常熟理工学院 | Opaque predicate-based code confusion method, system and storage medium |
CN117436040B (en) * | 2023-12-18 | 2024-04-12 | 常熟理工学院 | Opaque predicate-based code confusion method, system and storage medium |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
Khatibsyarbini et al. | Test case prioritization using firefly algorithm for software testing | |
McMinn et al. | Reducing qualitative human oracle costs associated with automatically generated test data | |
CN109409036A (en) | Control stream based on redundant code obscures method and device, storage medium and terminal | |
US20170091317A1 (en) | Location correlation between query script and data flow | |
US10599820B2 (en) | Control flow flattening for code obfuscation where the next block calculation needs run-time information | |
CN107341374B (en) | Insertion method and device of opaque predicates | |
Steiner et al. | Computing all efficient solutions of the biobjective minimum spanning tree problem | |
CN105487864A (en) | Method and device for automatically generating code | |
CN106446019B (en) | A kind of software function treating method and apparatus | |
CN105825137B (en) | A kind of method and device of determining sensitive data dispersal behavior | |
CN107193577A (en) | One kind application startup method, device and intelligent terminal | |
CN107632832A (en) | One kind obscures method towards dalvik bytecode controlling streams | |
CN109522013A (en) | A kind of code generating method and device of business function | |
CN105718765A (en) | Method for achieving code obfuscation through finite automaton | |
CN111221518A (en) | Script generation method, device, equipment and computer storage medium | |
CN109299444A (en) | A kind of generation method and device of editor | |
JP2005242569A (en) | Data processor design method and apparatus, and program | |
WO2018001041A1 (en) | Interface implementation method and device, set-top box, and storage medium | |
CN101710305A (en) | Method and system for realizing white box testing of computer software | |
CN107180168A (en) | File loading, generation method and device, and intelligent terminal | |
CN109976632A (en) | Text animation control methods and device, storage medium and processor | |
CN108446538A (en) | Source code reinforcement means and device based on state, semiology analysis and single-point logic | |
CN107122184A (en) | A kind of virtual reality software open type developing system and method | |
Lahaye et al. | Supervisory control of (max,+) automata: extensions towards applications | |
CN104951314A (en) | Dialog box display method and system |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
RJ01 | Rejection of invention patent application after publication | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20190301 |