CN110059456A - Code protection method, code protection device, storage medium and electronic equipment - Google Patents
Code protection method, code protection device, storage medium and electronic equipment Download PDFInfo
- Publication number
- CN110059456A CN110059456A CN201910319634.6A CN201910319634A CN110059456A CN 110059456 A CN110059456 A CN 110059456A CN 201910319634 A CN201910319634 A CN 201910319634A CN 110059456 A CN110059456 A CN 110059456A
- Authority
- CN
- China
- Prior art keywords
- function
- code
- class function
- class
- intermediate code
- 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.)
- Granted
Links
- 238000000034 method Methods 0.000 title claims abstract description 60
- 239000000284 extract Substances 0.000 claims abstract description 11
- 230000006870 function Effects 0.000 claims description 214
- 238000013507 mapping Methods 0.000 claims description 21
- 238000004590 computer program Methods 0.000 claims description 4
- 238000005516 engineering process Methods 0.000 abstract description 3
- 238000005336 cracking Methods 0.000 abstract 1
- 238000012545 processing Methods 0.000 description 13
- 230000008569 process Effects 0.000 description 11
- 238000012986 modification Methods 0.000 description 6
- 230000004048 modification Effects 0.000 description 6
- 230000003068 static effect Effects 0.000 description 5
- 238000004891 communication Methods 0.000 description 4
- 238000010586 diagram Methods 0.000 description 3
- 230000003287 optical effect Effects 0.000 description 3
- 230000008859 change Effects 0.000 description 2
- 238000000605 extraction Methods 0.000 description 2
- 230000005291 magnetic effect Effects 0.000 description 2
- 230000001133 acceleration Effects 0.000 description 1
- 230000006978 adaptation Effects 0.000 description 1
- 230000003044 adaptive effect Effects 0.000 description 1
- 238000013459 approach Methods 0.000 description 1
- 210000004027 cell Anatomy 0.000 description 1
- 239000000470 constituent Substances 0.000 description 1
- 238000007796 conventional method Methods 0.000 description 1
- 238000013461 design Methods 0.000 description 1
- 230000005611 electricity Effects 0.000 description 1
- 238000005538 encapsulation Methods 0.000 description 1
- 238000009434 installation Methods 0.000 description 1
- 239000000463 material Substances 0.000 description 1
- 230000007246 mechanism Effects 0.000 description 1
- 239000013307 optical fiber Substances 0.000 description 1
- 230000002093 peripheral effect Effects 0.000 description 1
- 230000003014 reinforcing effect Effects 0.000 description 1
- 210000000352 storage cell Anatomy 0.000 description 1
- 238000013519 translation Methods 0.000 description 1
- 239000002699 waste material 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)
- Stored Programmes (AREA)
Abstract
Present disclose provides a kind of code protection method, code protection device, computer readable storage medium and electronic equipments, belong to field of information security technology.This method comprises: being intermediate code by compilation of source code, and extract the first class function in the intermediate code and the second class function;The custom function for calling first class function is generated according to first class function;In the intermediate code, the call instruction in second class function about first class function is replaced with into the custom function;The replaced intermediate code is recompilated, object code file is obtained.The disclosure can prevent from source code to be reversed compiling cracking, and realize the effective protection to source code, and used method does not influence the normal operation of program in machine code, applicability with higher.
Description
Technical field
This disclosure relates to field of information security technology more particularly to a kind of code protection method, code protection device, calculating
Machine readable storage medium storing program for executing and electronic equipment.
Background technique
Software development usually needs to put into a large amount of manpower and material resources, for carrying out the enterprise of software development, mechanism or a
For people, software code is valuable intangible asset.Currently, due to the appearance of some decompiling instruments, so that software code holds
It easily is reversed compiling, causes its source code to be grasped by attacker even open, damages the interests of software developer.Therefore, such as
Software code is effectively protected in what, is prior art urgent problem to be solved.
It should be noted that information is only used for reinforcing the reason to the background of the disclosure disclosed in above-mentioned background technology part
Solution, therefore may include the information not constituted to the prior art known to persons of ordinary skill in the art.
Summary of the invention
Present disclose provides a kind of code protection method, code protection device, computer readable storage medium and electronics to set
It is standby, and then overcome the problems, such as that software code is easy to be reversed compiling in the prior art at least to a certain extent.
Other characteristics and advantages of the disclosure will be apparent from by the following detailed description, or partially by the disclosure
Practice and acquistion.
According to one aspect of the disclosure, a kind of code protection method is provided, comprising: by compilation of source code be intermediate generation
Code, and extract the first class function in the intermediate code and the second class function;It is generated according to first class function for adjusting
With the custom function of first class function;In the intermediate code, by second class function about described first
The call instruction of class function replaces with the custom function;The replaced intermediate code is recompilated, target is obtained
Code file.
In a kind of exemplary embodiment of the disclosure, first class function includes statement function, the second class letter
Number includes realizing function.
In a kind of exemplary embodiment of the disclosure, described by compilation of source code is intermediate code, and is extracted in described
Between the first class function and the second class function in code, comprising: using LLVM by the compilation of source code be the intermediate code;
The source code of the LLVM is compiled, the dynamic base of the LLVM is obtained;The intermediate code is parsed using the dynamic base,
To traverse the function in the intermediate code, and each function therein is divided into the first class function or the second class function.
In a kind of exemplary embodiment of the disclosure, the call instruction in second class function includes that CallInst refers to
It enables and/or InvokeInst is instructed.
It is described to be generated according to first class function for calling described the in a kind of exemplary embodiment of the disclosure
The custom function of Certain function summary, comprising: it is corresponding to generate a custom function for each first class function, and deposit
Store up the mapping relations between first class function and custom function.
It is described to recompilate the replaced intermediate code in a kind of exemplary embodiment of the disclosure, it obtains
Object code file, comprising: the replaced intermediate code is recompilated, and is added and is linked according to the mapping relations,
Obtain the object code file.
In a kind of exemplary embodiment of the disclosure, what the function name of the custom function was randomly generated.
According to one aspect of the disclosure, a kind of code protection device is provided, comprising: the first collector is used for source
Code compilation is intermediate code, and extracts the first class function in the intermediate code and the second class function;Function generation module,
For generating the custom function for calling first class function according to first class function;Instruction replacement module is used
In in the intermediate code, by the call instruction in second class function about first class function replace with it is described from
Defined function;Second collector obtains object code file for recompilating the replaced intermediate code.
In a kind of exemplary embodiment of the disclosure, first class function includes statement function, the second class letter
Number includes realizing function.
In a kind of exemplary embodiment of the disclosure, first collector includes: compilation of source code unit, is used for
Using LLVM by the compilation of source code be the intermediate code;Dynamic base acquiring unit, for the source code to the LLVM into
Row compiling, obtains the dynamic base of the LLVM;Function extraction unit, for parsing the intermediate code using the dynamic base,
To traverse the function in the intermediate code, and each function therein is divided into the first class function or the second class function.
In a kind of exemplary embodiment of the disclosure, the call instruction in second class function includes that CallInst refers to
It enables and/or InvokeInst is instructed.
In a kind of exemplary embodiment of the disclosure, the function generation module is used for for each first kind letter
Number, it is corresponding to generate a custom function, and store the mapping relations between first class function and custom function.
In a kind of exemplary embodiment of the disclosure, second collector was used for the replaced intermediate generation
Code recompilates, and is added and linked according to the mapping relations, obtains the object code file.
In a kind of exemplary embodiment of the disclosure, what the function name of the custom function was randomly generated.
According to one aspect of the disclosure, a kind of computer readable storage medium is provided, computer program is stored thereon with,
The computer program realizes method described in above-mentioned any one when being executed by processor.
According to one aspect of the disclosure, a kind of electronic equipment is provided, comprising: processor;And memory, for storing
The executable instruction of the processor;Wherein, the processor is configured to above-mentioned to execute via the executable instruction is executed
Method described in any one.
The exemplary embodiment of the disclosure has the advantages that
Based on the intermediate code after compilation of source code, custom function is generated according to the first class function therein, and by the
Call instruction in two class functions about the first class function replaces with custom function, to modify to intermediate code, most
Modified intermediate code is recompilated as object code file afterwards.It on the one hand, will based on the above-mentioned modification to intermediate code
Command content in former second class function is hidden, and has changed the affiliated party between the first class function and the second class function
Formula, the content modified are not belonging to logic compiler, therefore can not be reversed compiling and crack, to be effectively protected source code.
On the other hand, the logical AND that the present exemplary embodiment does not influence code operation to the modification of intermediate code is realized, is finally compiled
To object code file can normally be executed by computer, and entire method flow is relatively simple to the processing of code, is not necessarily to
Excess resource is occupied, so that present exemplary embodiment applicability with higher.
It should be understood that above general description and following detailed description be only it is exemplary and explanatory, not
The disclosure can be limited.
Detailed description of the invention
The drawings herein are incorporated into the specification and forms part of this specification, and shows the implementation for meeting the disclosure
Example, and together with specification for explaining the principles of this disclosure.It should be evident that the accompanying drawings in the following description is only the disclosure
Some embodiments for those of ordinary skill in the art without creative efforts, can also basis
These attached drawings obtain other attached drawings.
Fig. 1 shows a kind of process step figure of code protection method in the present exemplary embodiment;
Fig. 2 shows the sub-process step figures of code protection method a kind of in the present exemplary embodiment;
Fig. 3 shows a kind of flow diagram of code protection method in the present exemplary embodiment;
Fig. 4 shows a kind of structural block diagram of code protection device in the present exemplary embodiment;
Fig. 5 shows a kind of computer readable storage medium for realizing the above method in the present exemplary embodiment;
Fig. 6 shows a kind of electronic equipment for realizing the above method in the present exemplary embodiment.
Specific embodiment
Example embodiment is described more fully with reference to the drawings.However, example embodiment can be with a variety of shapes
Formula is implemented, and is not understood as limited to example set forth herein;On the contrary, thesing embodiments are provided so that the disclosure will more
Fully and completely, and by the design of example embodiment comprehensively it is communicated to those skilled in the art.Described feature, knot
Structure or characteristic can be incorporated in any suitable manner in one or more embodiments.In the following description, it provides perhaps
More details fully understand embodiment of the present disclosure to provide.It will be appreciated, however, by one skilled in the art that can
It is omitted with technical solution of the disclosure one or more in the specific detail, or others side can be used
Method, constituent element, device, step etc..In other cases, be not shown in detail or describe known solution to avoid a presumptuous guest usurps the role of the host and
So that all aspects of this disclosure thicken.
In addition, attached drawing is only the schematic illustrations of the disclosure, it is not necessarily drawn to scale.Identical attached drawing mark in figure
Note indicates same or similar part, thus will omit repetition thereof.Some block diagrams shown in the drawings are function
Energy entity, not necessarily must be corresponding with physically or logically independent entity.These function can be realized using software form
Energy entity, or these functional entitys are realized in one or more hardware modules or integrated circuit, or at heterogeneous networks and/or place
These functional entitys are realized in reason device device and/or microcontroller device.
Flow chart shown in the drawings is merely illustrative, it is not necessary to including all steps.For example, the step of having
It can also decompose, and the step of having can merge or part merges, therefore the sequence actually executed is possible to according to the actual situation
Change.
The exemplary embodiment of the disclosure provides firstly a kind of code protection method, and this method can run on service
Device, server cluster or Cloud Server etc. can also run on the terminal device of developer, such as personal computer.Originally show
The application scenarios of example property embodiment include but is not limited to: software project or exploitation Android JNI of the exploitation based on iOS
In (Java Native Interface, i.e. Java local interface) project, code is carried out using the method for the present exemplary embodiment
Protection, can prevent code to be stolen.Fig. 1 shows the method flow of the present exemplary embodiment, may comprise steps of
S110~S140:
Compilation of source code is intermediate code, and extracts the first class function in intermediate code and the second class by step S110
Function.
Wherein, intermediate code is also known as intermediate language, is the process by compilation of source code for another form of object code
In, to a kind of internal representation of source code progress.It is that intermediate code can be realized by compiler instrument by compilation of source code, this
Exemplary embodiment can use corresponding compiler according to the language form of source code, can also use LLVM (Low Level
Virtual Machine, underlying virtual machine, a kind of frame system of compiler) etc. the higher compiler of compatibility, it is each to compile
The source code of kind language, the disclosure do not limit this.
In the present exemplary embodiment, the first class function can be definition or statement function, the second class function can be realization
Function, comprising executing the instruction of some the first class function in usual second class function, can be considered has association between the two.Originally show
Example property embodiment can traverse intermediate code, extract all the first class function and the second class function, can also extract one
Part or some first class function and its associated second class function, such as the first class function A can be extracted, then extract
And function A has associated second class function B, C, D.
Step S120 generates the custom function for calling the first class function according to the first class function.
In the present exemplary embodiment, extracted each first class function can be generated respectively one it is corresponding customized
Function, such as: for the first class function A, custom function A ' is generated, for calling function A.Custom function, which can be considered, exchanges
The encapsulation carried out with the first class function, function name can also be generated at random, be shown one by developer's predefined
In example property embodiment, developer can be with predefined function list of file names, then system therefrom random selection function name, as from
Defined function name.
Step S130 replaces with the call instruction in the second class function about the first class function in intermediate code
State custom function.
For example, custom function A ' is equal to the instruction for calling function A, if looked into second class function B, C, D
The instruction for calling function A is found, the code of the operation part can be replaced with into custom function A ', the function of being realized is not
Become, the not normal realization of influence function B, C, D.Processing in this way can hide the command content in former second class function.
It should be noted that the type of intermediate code is different, specific call instruction is also different in the second class function, example
Such as: under LLVM translation and compiling environment, the call instruction in the second class function may include CallInst instruction and InvokeInst
Instruction.
Replaced intermediate code is recompilated, obtains object code file by step S140.
Wherein, object code file is the file that compiling is completed, and usual object code therein is corresponding to source code
Computer binary code, such as object code file can be .o file.It is compiled as compiling intermediate code in step S140
It is translated into the process of binary code, is also possible to the process of compilation.It can be mesh by compilation of source code in the present exemplary embodiment
The process of mark code is split as two processes: source code passes through the compilation process of step S110, becomes intermediate code, intermediate code
By the compilation process of step S140, become object code.In conventional Compilation Method, two compilation processes are all based on compiler
Logic is realized, it is easy to is reversed compiling and be cracked.The present exemplary embodiment replaces with certainly the part call instruction of intermediate code
Defined function, such alternative are not belonging to logic compiler, and decompiling instrument can not understand the code logic of replacement part, because
This is unable to get source code by reversely compiling.
In one exemplary embodiment, if the content of source code is more, the e.g. source code of Large-Scale Projects can
To be split as multiple portions, step S110~S140 is executed respectively, then each part is corresponding generates an object code text
These object code files can be finally chained up to generate complete executable file by part.
Based on above description, the present exemplary embodiment is based on the intermediate code after compilation of source code, according to therein first
Class function generates custom function, and the call instruction in the second class function about the first class function is replaced with customized letter
Number, to modify to intermediate code, finally recompilates modified intermediate code for object code file.One side
Face is hidden the command content in former second class function based on the above-mentioned modification to intermediate code, and has changed first
Interrelational form between class function and the second class function, the content modified is not belonging to logic compiler, therefore can not be reversed volume
It translates and cracks, to be effectively protected source code.On the other hand, the present exemplary embodiment does not influence generation to the modification of intermediate code
The logical AND of code operation realizes that finally compiling obtained object code file can normally be executed by computer, and entire method
Process is relatively simple to the processing of code, without occupying excess resource, so that present exemplary embodiment applicability with higher.
In one exemplary embodiment, if under LLVM frame application drawing 1 method, step S110 can pass through figure
Step S210~S230 in 2 is realized:
Step S111, using LLVM by compilation of source code be intermediate code;
Step S112 is compiled the source code of LLVM, obtains the dynamic base of LLVM;
Step S113 parses intermediate code using dynamic base, to traverse the function in intermediate code, and will be therein each
Function is divided into the first class function or the second class function.
In code compilation process, it will usually generate static library and dynamic base, substantially from the point of view of, library refer to it is existing, can
With the binary code of multiplexing.In the link stage of compiling, need will generate object code file (such as can be .o text
Part) it links and is bundled in executable file together with the library referred to, therefore corresponding on-link mode (OLM) is known as static linkage, is drawn
The library used is static library.However static library has that distinct program repeatedly copies caused space waste, and static library is not
Easily updating, the full dose that the variation of very little all will lead to entire program code updates, and it is more inconvenient in deployment and publication, therefore
The library of required reference is individually disposed as dynamic base when program code is run, and corresponding on-link mode (OLM) is dynamic link.
In the present exemplary embodiment, the function of source code has mapping by dynamic link in intermediate code, is based on
After the source code of LLVM compiles out dynamic base, according to the dynamic base can function from intermediate code back mapping to source code, from
And after traversing intermediate code, all functions therein can be extracted, if the type of code of function is definition or states,
It is divided into the first class function, if the type of code of function is to realize, is divided into the second class function.
Below to the step in Fig. 2 for example: can first be compiled the source code of LLVM, generate
LibLLVM.dylib dynamic base;Then finding out (such as can to generate object code file for compiling source code in compiling project
To be .o file) compiler directive;It is added in compiler directive again and compiles parameter-emit-llvm, generation intermediate code (such as
It can be .bc file);Finally, after obtaining intermediate code, can integrate libLLVM.dylib dynamic base to intermediate code into
Row parsing, then function therein is traversed to extract the first class function and the second class function.
By foregoing teachings it is found that the purpose of the present exemplary embodiment is according to the corresponding custom function of the first class function
Corresponding call instruction in the second class function is replaced, to hide a part of raw content in intermediate code, to realize that code is protected
Shield.Theoretically, the content being replaced in intermediate code is more, and finally obtained object code file is reversed the difficulty of compiling
It is bigger.Based on this, in one exemplary embodiment, the corresponding calling in the second class function of each first class function can be referred to
Order is all replaced, then step S120 can be specifically included:
It is corresponding to generate a custom function for each first class function, and store the first class function and customized letter
Mapping relations between number.
That is the first class function and custom function are one-to-one mapping relations, occur the second class letter in all intermediate codes
Number calls the instruction of the first class function, all replaces with corresponding custom function.Between first class function and custom function
Mapping relations can store as a mapping table, is stored in the file of local or procedural item, checks in order to subsequent
It uses or subsequent when increasing new source code, the method that can also execute the present exemplary embodiment according to mapping table guarantees whole
Consistency of a procedural item in code logic.
Further, in one exemplary embodiment, step S140 can be specifically included:
Replaced intermediate code is recompilated, and is added and is linked according to mapping relations, obtains object code file.
Wherein, by the first class function and the mapping relations of custom function can be generated it is corresponding link, which can be with
Be added to intermediate code compiling after object code file in, can also in addition generate an object code file for store
The link of mapping relations is stated, and is added between different object code files in the corresponding object code file of intermediate code
Link, the disclosure do not limit this.
You need to add is that above-mentioned mapping relations can also be added in the dynamic base of compiler, then object code is literary
At runtime, by calling dynamic base, the calling to the first class function in source code may be implemented in part.
The above-mentioned mode according to mapping relations addition link can retain after being compiled to source code by object code
File obtains the approach of source code with back mapping by reversely compiling, can be according to target in the case where source code is lost
Code file restores source code, and realizes the two ways of program code execution: it is executed by the logic of source code, and
It is executed by the code logic after replacement call instruction.
Fig. 3 shows a kind of method flow of the present exemplary embodiment, comprising the following steps: step S111 utilizes LLVM
Source code is compiled, intermediate code is obtained;Step S112 is compiled the source code of LLVM, obtains LLVM's
LibLLVM.dylib dynamic base;Step S113 parses intermediate code using dynamic base, to traverse intermediate code, extracts
The first all class functions and the second class function out;Step S120 is generated according to the first class function for calling first kind letter
Several custom function;Step S130 searches the instruction for calling above-mentioned first class function from the second class function, replaces with
Custom function;Replaced intermediate code is recompilated, and adds related link by step S140, obtains object code text
Part.To carry out effective protection to code during code compilation.It in one exemplary embodiment, can be according to Fig. 3
Method flow write corresponding script, script is placed under the procedural item for needing code protection and is run, with realize to entire
The code protection of procedural item.
The exemplary embodiment of the disclosure additionally provides a kind of code protection device, as shown in figure 4, the device 400 can be with
Include: the first collector 410, for being intermediate code by compilation of source code, and extracts the first class function in intermediate code
With the second class function;Function generation module 420, for being generated according to the first class function for calling the customized of the first class function
Function;Instruction replacement module 430 is used in intermediate code, by the call instruction in the second class function about the first class function
Replace with custom function;Second collector 440 obtains object code for recompilating replaced intermediate code
File.
In one exemplary embodiment, the first class function can be statement function, and the second class function can be realization function.
In one exemplary embodiment, the first collector 410 may include: compilation of source code unit, for utilizing
Compilation of source code is intermediate code by LLVM;Dynamic base acquiring unit is compiled for the source code to LLVM, obtains LLVM's
Dynamic base;Function extraction unit, for parsing intermediate code using dynamic base, to traverse the function in intermediate code, and by its
In each function be divided into the first class function or the second class function.
In one exemplary embodiment, it is based on LLVM compiler framework, the call instruction in above-mentioned second class function can wrap
Include CallInst instruction and/or InvokeInst instruction.
In one exemplary embodiment, function generation module 420 can be used for for each first class function, corresponding to generate
One custom function, and store the mapping relations between the first class function and custom function.
In one exemplary embodiment, the second collector 440 can be used for recompilating replaced intermediate code,
And added and linked according to mapping relations, obtain object code file.
In one exemplary embodiment, the function name of custom function can be randomly generated.
The detail of each module/unit has been described in detail in the embodiment of method part in above-mentioned apparatus, therefore
It repeats no more.
The exemplary embodiment of the disclosure additionally provides a kind of computer readable storage medium, and being stored thereon with can be realized
The program product of this specification above method.In some possible embodiments, various aspects of the disclosure can also be realized
For a kind of form of program product comprising program code, when program product is run on the terminal device, program code is used for
Execute terminal device described in above-mentioned " illustrative methods " part of this specification according to the various exemplary embodiment party of the disclosure
The step of formula.
It is produced refering to what is shown in Fig. 5, describing the program according to the exemplary embodiment of the disclosure for realizing the above method
Product 500, can be using portable compact disc read only memory (CD-ROM) and including program code, and can set in terminal
It is standby, such as run on PC.However, the program product of the disclosure is without being limited thereto, in this document, readable storage medium storing program for executing can
With to be any include or the tangible medium of storage program, the program can be commanded execution system, device or device use or
Person is in connection.
Program product can be using any combination of one or more readable mediums.Readable medium can be readable signal Jie
Matter or readable storage medium storing program for executing.Readable storage medium storing program for executing for example can be but be not limited to electricity, magnetic, optical, electromagnetic, infrared ray or partly lead
System, device or the device of body, or any above combination.More specific example (the non exhaustive column of readable storage medium storing program for executing
Table) it include: the electrical connection with one or more conducting wires, portable disc, hard disk, random access memory (RAM), read-only storage
Device (ROM), erasable programmable read only memory (EPROM or flash memory), optical fiber, portable compact disc read only memory (CD-
ROM), light storage device, magnetic memory device or above-mentioned any appropriate combination.
Computer-readable signal media may include in a base band or as carrier wave a part propagate data-signal,
In carry readable program code.The data-signal of this propagation can take various forms, including but not limited to electromagnetic signal,
Optical signal or above-mentioned any appropriate combination.Readable signal medium can also be any readable Jie other than readable storage medium storing program for executing
Matter, the readable medium can send, propagate or transmit for by instruction execution system, device or device use or and its
The program of combined use.
The program code for including on readable medium can transmit with any suitable medium, including but not limited to wirelessly, have
Line, optical cable, RF etc. or above-mentioned any appropriate combination.
Can with any combination of one or more programming languages come write for execute the disclosure operation program
Code, programming language include object oriented program language-Java, C++ etc., further include conventional process
Formula programming language-such as " C " language or similar programming language.Program code can be calculated fully in user
It executes in equipment, partly execute on a user device, executing, as an independent software package partially in user calculating equipment
Upper part executes on a remote computing or executes in remote computing device or server completely.It is being related to remotely counting
In the situation for calculating equipment, remote computing device can pass through the network of any kind, including local area network (LAN) or wide area network
(WAN), it is connected to user calculating equipment, or, it may be connected to external computing device (such as utilize ISP
To be connected by internet).
The exemplary embodiment of the disclosure additionally provides a kind of electronic equipment that can be realized the above method.
Person of ordinary skill in the field it is understood that various aspects of the disclosure can be implemented as system, method or
Program product.Therefore, various aspects of the disclosure can be with specific implementation is as follows, it may be assumed that complete hardware embodiment, complete
The embodiment combined in terms of full Software Implementation (including firmware, microcode etc.) or hardware and software, can unite here
Referred to as circuit, " module " or " system ".
The electronic equipment 600 of this exemplary embodiment according to the disclosure is described referring to Fig. 6.What Fig. 6 was shown
Electronic equipment 600 is only an example, should not function to the embodiment of the present disclosure and use scope bring any restrictions.
As shown in fig. 6, electronic equipment 600 is showed in the form of universal computing device.The component of electronic equipment 600 can wrap
It includes but is not limited to: at least one above-mentioned processing unit 610, at least one above-mentioned storage unit 620, the different system components of connection
The bus 630 of (including storage unit 620 and processing unit 610), display unit 640.
Wherein, storage unit 620 is stored with program code, and program code can be executed with unit 610 processed, so that processing
Unit 610 executes described in above-mentioned " illustrative methods " part of this specification according to the various illustrative embodiments of the disclosure
Step.For example, processing unit 610 can execute Fig. 1, Fig. 2 or method and step shown in Fig. 3 etc..
Storage unit 620 may include the readable medium of volatile memory cell form, such as Random Access Storage Unit
(RAM) 621 and/or cache memory unit 622, it can further include read-only memory unit (ROM) 623.
Storage unit 620 can also include program/utility 624 with one group of (at least one) program module 625,
Such program module 625 includes but is not limited to: operating system, one or more application program, other program modules and
It may include the realization of network environment in program data, each of these examples or certain combination.
Bus 630 can be to indicate one of a few class bus structures or a variety of, including storage unit bus or storage
Cell controller, peripheral bus, graphics acceleration port, processing unit use any bus structures in a variety of bus structures
Local bus.
Electronic equipment 600 can also be with one or more external equipments 700 (such as keyboard, sensing equipment, bluetooth equipment
Deng) communication, can also be enabled a user to one or more equipment interact with the electronic equipment 600 communicate, and/or with make
Any equipment (such as the router, modulation /demodulation that the electronic equipment 600 can be communicated with one or more of the other calculating equipment
Device etc.) communication.This communication can be carried out by input/output (I/O) interface 650.Also, electronic equipment 600 can be with
By network adapter 660 and one or more network (such as local area network (LAN), wide area network (WAN) and/or public network,
Such as internet) communication.As shown, network adapter 660 is communicated by bus 630 with other modules of electronic equipment 600.
It should be understood that although not shown in the drawings, other hardware and/or software module can not used in conjunction with electronic equipment 600, including but not
Be limited to: microcode, device driver, redundant processing unit, external disk drive array, RAID system, tape drive and
Data backup storage system etc..
Through the above description of the embodiments, those skilled in the art is it can be readily appreciated that example described herein is implemented
Mode can also be realized by software realization in such a way that software is in conjunction with necessary hardware.Therefore, according to the disclosure
The technical solution of embodiment can be embodied in the form of software products, which can store non-volatile at one
Property storage medium (can be CD-ROM, USB flash disk, mobile hard disk etc.) in or network on, including some instructions are so that a calculating
Equipment (can be personal computer, server, terminal installation or network equipment etc.) is executed according to the exemplary implementation of the disclosure
The method of example.
In addition, above-mentioned attached drawing is only the schematic theory of the processing according to included by the method for disclosure exemplary embodiment
It is bright, rather than limit purpose.It can be readily appreciated that the time that above-mentioned processing shown in the drawings did not indicated or limited these processing is suitable
Sequence.In addition, be also easy to understand, these processing, which can be, for example either synchronously or asynchronously to be executed in multiple modules.
It should be noted that although being referred to several modules or list for acting the equipment executed in the above detailed description
Member, but this division is not enforceable.In fact, according to an exemplary embodiment of the present disclosure, above-described two or
More multimode or the feature and function of unit can embody in a module or unit.Conversely, above-described one
A module or the feature and function of unit can be to be embodied by multiple modules or unit with further division.
Those skilled in the art after considering the specification and implementing the invention disclosed here, will readily occur to its of the disclosure
His embodiment.This application is intended to cover any variations, uses, or adaptations of the disclosure, these modifications, purposes or
Adaptive change follow the general principles of this disclosure and including the undocumented common knowledge in the art of the disclosure or
Conventional techniques.The description and examples are only to be considered as illustrative, and the true scope and spirit of the disclosure are by claim
It points out.
It should be understood that the present disclosure is not limited to the precise structures that have been described above and shown in the drawings, and
And various modifications and changes may be made without departing from the scope thereof.The scope of the present disclosure is only limited by the attached claims.
Claims (10)
1. a kind of code protection method characterized by comprising
It is intermediate code by compilation of source code, and extracts the first class function in the intermediate code and the second class function;
The custom function for calling first class function is generated according to first class function;
In the intermediate code, the call instruction in second class function about first class function is replaced with described
Custom function;
The replaced intermediate code is recompilated, object code file is obtained.
2. the method according to claim 1, wherein first class function include statement function, described second
Class function includes realizing function.
3. by compilation of source code being intermediate code the method according to claim 1, wherein described, and institute is extracted
State the first class function and the second class function in intermediate code, comprising:
Using LLVM by the compilation of source code be the intermediate code;
The source code of the LLVM is compiled, the dynamic base of the LLVM is obtained;
The intermediate code is parsed using the dynamic base, to traverse the function in the intermediate code, and each function is drawn
It is divided into the first class function or the second class function.
4. according to the method described in claim 3, it is characterized in that, the call instruction in second class function includes
CallInst instruction and/or InvokeInst instruction.
5. the method according to claim 1, wherein described generate according to first class function for calling
State the custom function of the first class function, comprising:
It is corresponding to generate a custom function for each first class function, and store first class function and make by oneself
Mapping relations between adopted function.
6. according to the method described in claim 5, it is characterized in that, described recompilate the replaced intermediate code,
Obtain object code file, comprising:
The replaced intermediate code is recompilated, and is added and is linked according to the mapping relations, obtains the target generation
Code file.
7. the method according to claim 1, wherein what the function name of the custom function was randomly generated.
8. a kind of code protection device characterized by comprising
First collector for being intermediate code by compilation of source code, and extracts the first class function in the intermediate code
With the second class function;
Function generation module, for generating the customized letter for calling first class function according to first class function
Number;
Instruction replacement module, in the intermediate code, by second class function about first class function
Call instruction replaces with the custom function;
Second collector obtains object code file for recompilating the replaced intermediate code.
9. a kind of computer readable storage medium, is stored thereon with computer program, which is characterized in that the computer program quilt
Claim 1-7 described in any item methods are realized when processor executes.
10. a kind of electronic equipment characterized by comprising
Processor;And
Memory, for storing the executable instruction of the processor;
Wherein, the processor is configured to require 1-7 described in any item via executing the executable instruction and carry out perform claim
Method.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910319634.6A CN110059456B (en) | 2019-04-19 | 2019-04-19 | Code protection method, code protection device, storage medium and electronic equipment |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910319634.6A CN110059456B (en) | 2019-04-19 | 2019-04-19 | Code protection method, code protection device, storage medium and electronic equipment |
Publications (2)
Publication Number | Publication Date |
---|---|
CN110059456A true CN110059456A (en) | 2019-07-26 |
CN110059456B CN110059456B (en) | 2020-06-05 |
Family
ID=67319919
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201910319634.6A Active CN110059456B (en) | 2019-04-19 | 2019-04-19 | Code protection method, code protection device, storage medium and electronic equipment |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN110059456B (en) |
Cited By (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110717150A (en) * | 2019-10-08 | 2020-01-21 | 北京顶象技术有限公司 | Code protection method, device, protection equipment and readable storage medium |
CN110750266A (en) * | 2019-09-20 | 2020-02-04 | 平安普惠企业管理有限公司 | Program compiling method, program compiling device, computer equipment and storage medium |
CN110990797A (en) * | 2019-11-29 | 2020-04-10 | 珠海豹趣科技有限公司 | Data processing method and device and computer readable storage medium |
CN111400675A (en) * | 2020-03-16 | 2020-07-10 | 同盾(广州)科技有限公司 | Object obfuscation method, device, electronic equipment and computer readable medium |
CN111475152A (en) * | 2020-04-14 | 2020-07-31 | 中国人民解放军战略支援部队信息工程大学 | Code processing method and device |
CN111723002A (en) * | 2020-05-18 | 2020-09-29 | 五八有限公司 | Code debugging method and device, electronic equipment and storage medium |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101853357A (en) * | 2010-04-28 | 2010-10-06 | 北京飞天诚信科技有限公司 | Software protection method |
CN107092518A (en) * | 2017-04-17 | 2017-08-25 | 上海红神信息技术有限公司 | A kind of Compilation Method for protecting mimicry system of defense software layer safe |
CN107992307A (en) * | 2017-12-11 | 2018-05-04 | 北京奇虎科技有限公司 | A kind of function Compilation Method and device |
CN109101237A (en) * | 2018-08-01 | 2018-12-28 | 北京顶象技术有限公司 | The encryption Compilation Method and device of code |
-
2019
- 2019-04-19 CN CN201910319634.6A patent/CN110059456B/en active Active
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101853357A (en) * | 2010-04-28 | 2010-10-06 | 北京飞天诚信科技有限公司 | Software protection method |
CN107092518A (en) * | 2017-04-17 | 2017-08-25 | 上海红神信息技术有限公司 | A kind of Compilation Method for protecting mimicry system of defense software layer safe |
CN107992307A (en) * | 2017-12-11 | 2018-05-04 | 北京奇虎科技有限公司 | A kind of function Compilation Method and device |
CN109101237A (en) * | 2018-08-01 | 2018-12-28 | 北京顶象技术有限公司 | The encryption Compilation Method and device of code |
Cited By (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110750266A (en) * | 2019-09-20 | 2020-02-04 | 平安普惠企业管理有限公司 | Program compiling method, program compiling device, computer equipment and storage medium |
CN110717150A (en) * | 2019-10-08 | 2020-01-21 | 北京顶象技术有限公司 | Code protection method, device, protection equipment and readable storage medium |
CN110990797A (en) * | 2019-11-29 | 2020-04-10 | 珠海豹趣科技有限公司 | Data processing method and device and computer readable storage medium |
CN111400675A (en) * | 2020-03-16 | 2020-07-10 | 同盾(广州)科技有限公司 | Object obfuscation method, device, electronic equipment and computer readable medium |
CN111475152A (en) * | 2020-04-14 | 2020-07-31 | 中国人民解放军战略支援部队信息工程大学 | Code processing method and device |
CN111475152B (en) * | 2020-04-14 | 2023-03-14 | 中国人民解放军战略支援部队信息工程大学 | Code processing method and device |
CN111723002A (en) * | 2020-05-18 | 2020-09-29 | 五八有限公司 | Code debugging method and device, electronic equipment and storage medium |
Also Published As
Publication number | Publication date |
---|---|
CN110059456B (en) | 2020-06-05 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN110059456A (en) | Code protection method, code protection device, storage medium and electronic equipment | |
CN104412229B (en) | Adaptive portable library | |
CN111736840A (en) | Compiling method and running method of applet, storage medium and electronic equipment | |
CN103713902B (en) | A kind of BOA Compilation Methods and system based on android system | |
CN109542459A (en) | Application program packaging method and device, computer installation and computer storage medium | |
CN100492387C (en) | Method and system for software protected development based on Keil C51 | |
US10809988B2 (en) | Processor emulation using multiple translations | |
CN110058861B (en) | Source code processing method and device, storage medium and electronic equipment | |
WO2019092565A1 (en) | Using comments of a program to provide optimizations | |
CN110688096B (en) | Method and device for constructing application program containing plug-in, medium and electronic equipment | |
US9405652B2 (en) | Regular expression support in instrumentation languages using kernel-mode executable code | |
US9886251B2 (en) | Optimized compiling of a template function | |
CN114461223A (en) | Code generation method and device and terminal equipment | |
CN103077066A (en) | Method and system for embedding product key information during compiling | |
EP3872630A2 (en) | Request processing method and apparatus, electronic device, and computer storage medium | |
KR102272635B1 (en) | System and method for converting large scale application | |
CN110045952A (en) | Code call method and device | |
CN116360741A (en) | Applet development method, system, device and storage medium | |
CN104331827B (en) | Transaction configuration generating method and deals match device | |
CN111274551B (en) | Compiler-based java code protection method and device and electronic equipment | |
KR20180053872A (en) | System and method for converting application | |
Kim et al. | Static dalvik bytecode optimization for Android applications | |
JP2018005915A (en) | Method and system for providing application package, and method and system for executing application | |
CN112311931B (en) | Method and device for processing contact information at terminal and electronic equipment | |
CN115935302A (en) | Android installation package generation method and device |
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 | ||
GR01 | Patent grant | ||
GR01 | Patent grant | ||
TR01 | Transfer of patent right |
Effective date of registration: 20210913 Address after: 311121 room 607-609, building 18, No. 998, Wenyi West Road, Wuchang Street, Yuhang District, Hangzhou City, Zhejiang Province Patentee after: Tongdun Network Technology Co.,Ltd. Address before: Room 704, building 18, No. 998, Wenyi West Road, Wuchang Street, Yuhang District, Hangzhou City, Zhejiang Province Patentee before: TONGDUN HOLDINGS Co.,Ltd. |
|
TR01 | Transfer of patent right |