Method and system based on the software protection of Keil C51 exploitation
Technical field
The present invention relates to information security field, particularly a kind of method and system of developing based on the software protection of Keil C51.
Background technology
Keil C51 is the 51 serial compatible single-chip microcomputer C lingware development systems that U.S. Keil Software company produces.KeiluVision2 is the window application of a standard, integrated C51 compiler, A51 assembler, L51 connector, real time operating system, project manager and debugger etc., can finish whole development processs such as editor, compiling, link, debugging and emulation, the developer can use IDE (Integrated Development Environment, Integrated Development Environment) or other editing machine editor C or compilation source file, generate file destination (.OBJ file) by the compiling of C51 and A51 compiler respectively then.File destination can be created by LIB51 and generate library file, also can connect the location through L51 with library file and generate absolute object file (.ABS file).The absolute object file is converted to the Hex file of standard by OH51, the Hex file can be used by emulator, directly Target Board is debugged, also can be directly with Hex file write-in program memory, in EPROM (ErasableProgrammable Read-Only Memory, EPROM (Erasable Programmable Read Only Memory)).
Keil has defined an AGDI (Advanced Generic Debugger Interface, senior general debugger interface) interface, the user writes the IDE that DLL connects replicating machine and Keil by this interface, be Keil C51 Integrated Development Environment uVision2, the uVision2 debugger utilizes senior AGDI interface, and the uVision2 debugger is tied to goal systems.Keil also provides one group of DLL (dynamic link library) AGSI (Advanced Generic Simulator Interface, senior universal simulator interface), use this interface can develop the DLL consistent with hardware capability, embed this DLL to Keil C environment, direct exploitation C51 program under pure software environment just, the user can be on PC simulated target program, instruction set and sheet inner peripheral function fully.
The software simulation emulator is a kind of microcomputer development method, is equally applicable to the exploitation of software protection.This method is on PC, realizes emulation with software, and disposes a series of relevant service routines, as long as move this software package on PC, just can debug object code program during use.
So-called virtual machine, can be imagined as a machine of simulating to it with software, various hardware such as processor, internal memory, register are arranged in this machine, the various instructions of Simulation execution, the software that moves on this machine does not have specific (special) requirements to running environment, so virtual machine is transparent to the program of moving on it.For example, what the X86 virtual machine was simulated is the running environment of X86 instruction repertorie, and what the C51 virtual machine was simulated is the running environment of C51 instruction repertorie.
At present, the information safety devices manufacturer can realize certain virtual machine function in the hardware device of higher-end, therefore can in information safety devices, directly move code with the corresponding form of realizing of virtual machine, for example, the hardware manufacturer has realized the C51 virtual machine in information safety devices, present application mode is exactly that c program is compiled into the binary file that contains the C51 instruction by Keil C51 compiler, and the file of this form is exactly the executable file that can carry out on information safety devices.
File system is method and the data structure that operating system is used for the file on clear and definite disk or the subregion, i.e. the method for constituent act on disk also refers to be used for the disk or the subregion of storage file or file system kind.
Virtual File System is meant the behavior that comes the structure of constituent act and/or simulate a file system by software, and it realizes all or part of function of file system.
The software pirate version is the numerous developers' of puzzlement a great difficult problem always for many years; so having to just drop into energy in the performance history of software product, many developers go making software defencive function module; especially those prices are higher relatively, towards the professional software product of specific industry.But drop into energy and go to realize that the software protection function is not to receive special effect in a Products Development process, finally the protection effect that can reach not is always to be directly proportional with the energy that drops into.Relevant with software protection and encryption after all function development need according to the concrete characteristics of software product, be formulated the software protection scheme based on certain practical experience, and just sets about the amount body design of protection scheme at the initial stage of software development.The complicacy that realizes just because of the software protection function so the developer still can select the ready-made software protection series products of a cover mostly, and is gone in the later stage of software development is attached to oneself product.
In the product aspect numerous software protections, the lock of software cryptography for many years product remains the protected software product of being familiar with and being commonly used for everybody.Encryption lock also claims softdog, it is a kind of a kind of small hardware device that has separate CPU, RAM and nonvolatile memory, it can be connected with computing machine by the data communication interface of computing machine, can store, management data, and can preset the cryptographic algorithm function, but also the later stage customizes the part algorithm function voluntarily simultaneously.When a software product combines after encryption lock protects, software just can't leave encryption lock and normal operation, and this software product just intangibly has been bundled in encryption lock hardware, software just look like pinned by this device like, so the title encryption lock.
The file system of encryption lock and the file system of Windows are similar, are directory/file structure, and file comprises: executable file, data file and key file.Executable file is the file at the encryption lock internal operation.When application software is moved, call by the api interface of outside, import the input data into to this document, executable file returns to outside application program with the result behind the encryption lock internal operation.Data file is the file of store data information.Key file is the file of storage RSA key to (PKI and private key).
It is as follows to carry out a kind of encryption method principle of software protection based on encryption lock in the prior art: the software developer is written to the part of program in the encryption lock and needn't keeps this a part of copy on main frame, also can not occur in the internal memory of computing machine during program run; In software, be written into the position of that part of program of encryption lock, add calling encryption lock; During running software, these transplanted programs will be in encryption lock internal operation, and the result returned to software.Because a part of program of software is transplanted in the encryption lock, clearly, the software of installing has on computers left the just impossible operate as normal of encryption lock, thereby realizes the protection to software.
Above-mentioned software protection development process generally comprises following step:
1. exploitation: the software developer selects key code to pass through the compiler of encryption lock compatibility, these code compiles is become local code, i.e. executable file;
2. debugging: debug for transplanted code, it can be downloaded in the encryption lock and debug, also can come it is debugged by the real encryption lock equipment of software simulator emulation in PC;
3. download: after debug successfully, associated documents such as the executable file that executable file and executable file need be visited when moving, data file, key file download to encryption lock inside;
4. test: the software developer tests a whole set of software, comprises that the software to the executable file that downloads to encryption lock inside and PC end calls test;
5. produce: the software developer repeatedly step of repeated downloads carries out batch and fires.
There is following shortcoming in above-mentioned prior art:
1. if downloading to encryption lock debugs, then efficient is low, cost is high; If utilize software simulator emulation to debug, then can not simulate the function of real hardware fully, can not carry out hardware-related function such as software simulator;
2. in the process of firing and producing, related resource environment such as the executable file that the user is visited in the time of must getting the operation of executable program in the manual configuration debug process, data file, key file, and these files may be rewritten in debug process, be that pre-configured file and the file content in the debug process may be inequality, can cause firing environment and virtual environment is inconsistent, thereby can not guarantee accuracy; If the user reconfigures resource repeatedly, then make complicated operationization.
Summary of the invention
In order to address the above problem, the invention provides a kind of method and system of developing based on the software protection of Keil C51.
The method of developing based on the software protection of Keil C51 provided by the invention comprises:
The kernel program of software is converted to the source code of C51 language; The file of in Virtual File System, being visited during the described source code of configuration debugging and the hardware device information of software protecting equipment;
Compile described source code and generate the C51 local code, the Keil debugger is simulated the running status of described software protecting equipment, debugs described source code; After debugging successfully, the C51 local code after the debugging is downloaded in the described Virtual File System, and generate the Virtual File System mirror image; Described Virtual File System mirror image is write in the described software protecting equipment.
File or internal memory by computing machine are simulated described Virtual File System.
Described Virtual File System is independent software, storehouse or module.
Described Virtual File System can be realized virtual catalogue and/or file structure.
Before debugging described source code, described Keil debugger also comprises:
Write described Keil debugger by AGDI or AGSI interface.
Described method also comprises:
Described Keil debugger is revised the content of described Virtual File System in debug process.
Described method also comprises:
Described Keil debugger reads the file and the information of obtaining in the described Virtual File System in the described Virtual File System in debug process.
Described running status comprises input data and/or output data.
Described Virtual File System mirror image comprises the bibliographic structure information of described Virtual File System.
Described Virtual File System mirror image comprises the document structure information of described Virtual File System.
Described Virtual File System mirror image comprises the document content information in the described Virtual File System.
Described Virtual File System mirror image comprises the hardware device information of the described software protecting equipment in the described Virtual File System.
The hardware device information of described software protecting equipment comprises password information and/or ATR.
The system that develops based on the software protection of Keil C51 provided by the invention comprises:
Interface module is used to connect the integration environment of described system and Keil;
The Virtual File System configuration module is used for the file of being visited and the hardware device information of software protecting equipment when the source code of Virtual File System configuration debugging C51 language;
The system call module is used to call the function of realizing described software protecting equipment function;
C51 virtual machine module is used for explaining and execution C51 instruction, and debugs described source code by calling described system call module and described Virtual File System; The integration environment of Keil loads and/or calls described C51 virtual machine module by described interface module;
Download module is used for after debugging successfully, the C51 local code after the debugging is downloaded in the described Virtual File System, and generate the Virtual File System mirror image; Described Virtual File System mirror image is write in the described software protecting equipment; The integration environment of Keil loads and/or calls described download module by described interface module;
The hardware access module is used at described download module described Virtual File System mirror image being write the process of described software protecting equipment, communicates with described software protecting equipment.
Described interface module realizes AGDI interface or AGSI interface.
Described system call module also is used for being called to revise in described debug process the content of described Virtual File System.
Described system call module also is used for being called to read the file in the described Virtual File System and obtaining information in the described Virtual File System in described debug process.
The present invention can guarantee that the software developer simplifies the software protection performance history of oneself, can guarantee the accuracy of performance history again.Debugger can call Virtual File System in debug process; the centralized management executable file is at operation time institute's accessed resources environment; each link in the software protection exploitation need not to reconfigure these resource environments again; thereby reduced the probability of makeing mistakes; guaranteed accuracy, also simplified the software developer and carried out the software protection performance history.The Keil debugger of virtual combination file system is equivalent to the simulated environment of a true card, can finish the function of whole encryption lock built-in system functions, has overcome software simulator and can not simulate the problem of true hardware equipment function fully.
Description of drawings
Fig. 1 is the method flow diagram of the embodiment of the invention based on the software protection exploitation of Keil C51;
Fig. 2 is the system construction drawing of the embodiment of the invention based on the software protection exploitation of Keil C51.
Embodiment
The invention will be further described below in conjunction with the drawings and specific embodiments, but the present invention is not limited to the following examples.
Referring to Fig. 1, the embodiment of the invention provides a kind of method of developing based on the software protection of Keil C51, specifically may further comprise the steps:
Step 101: the software developer uses higher level lanquage to develop software;
Step 102: select kernel program, convert thereof into the source code of C51 language;
Step 103: the hardware device information of file of being visited when in Virtual File System, disposing the debug source code and the software protecting equipment of being visited;
Virtual File System can be by the file or the internal memory simulation of computing machine, and it can be independent software, storehouse or module, can realize virtual catalogue and/or file structure;
Step 104: the source code of compiling C51 language generates the C51 local code;
The running status of step 105:Keil debugger simulation softward protective device, the source code of debugging C51 language;
The Keil debugger is for to write by AGDI interface or AGSI interface, it can revise the content of Virtual File System in debug process, can also read file and the information of obtaining in the Virtual File System in the Virtual File System, wherein revise to be included in and create directory in the Virtual File System and/or file, deltree and/or file, write document content information; Running status comprises input data and/or output data;
Step 106: after debugging successfully, download the C51 local code in Virtual File System, and generate the Virtual File System mirror image;
The Virtual File System mirror image can comprise: one or more in bibliographic structure information, document structure information, document content information and the Virtual File System of Virtual File System in the hardware device information of software protecting equipment, wherein the hardware device information of software protecting equipment comprises password information and/or ATR (Answer To Reset, response automatically resets);
Step 107: the Virtual File System mirror image is write in the software protecting equipment.
Referring to Fig. 2, the embodiment of the invention also provides a kind of system that develops based on the software protection of Keil C51, specifically comprises:
(1) interface module 201, are used for the integration environment of connected system and Keil;
(2) the Virtual File System configuration module 202, are used for the file of being visited when the source code of Virtual File System configuration debugging C51 language and the hardware device information of software protecting equipment;
(3) system call module 203 is used to call the function of realizing the software protecting equipment function;
(4) C51 virtual machine module 204 is used for explaining and execution C51 instruction, and comes the debug source code by invoke system call module and Virtual File System; The integration environment of Keil loads and/or calls C51 virtual machine module by interface module;
(5) download module 205, are used for after debugging successfully, the C51 local code after the debugging is downloaded in the Virtual File System, and generate the Virtual File System mirror image; The Virtual File System mirror image is write in the software protecting equipment; The integration environment of Keil loads and/or calls download module by interface module;
(6) the hardware access module 206, are used at download module the Virtual File System mirror image being write the process of software protecting equipment, communicate with software protecting equipment.
Interface module 201 can realize AGDI interface or AGSI interface.
System call module 203 also is used for being called to revise in debug process the content of Virtual File System, wherein revises to be included in createing directory in the Virtual File System and/or file, deltrees and/or file, writes document content information.
System call module 203 also is used for being called to read the file in the Virtual File System and obtaining information in the Virtual File System in debug process.
Above-described embodiment is a more preferably embodiment of the present invention, and common variation that those skilled in the art carries out in the technical solution of the present invention scope and replacement all should be included in protection scope of the present invention.