Summary of the invention
In order to solve the problems, such as that background technique, the present invention provide software product guard method, this method is by changing
Into license file and the verification mode of license information, license proving program can be prevented to be bypassed or modified,
To achieve the purpose that protect software product.
The present invention provides a kind of guard method of software product, comprising the steps of: license file is generated, comprising steps of from
Startup program and main body program are isolated in software product, integrates the startup program and license proving program, form guidance
Program merges the bootstrap, license information, generates the license file;Before running the main body program,
The license file is verified, is verified, then runs the main body program.
In a preferred embodiment, merge when generating the license file, while merging digital certificate and secret close
Key.
In a preferred embodiment, it before generating the merging step in the license file, further includes to institute
State the step of bootstrap is encrypted: the private key by the digital certificate is bootstrap generation digital digest, and
Digital digest by the privacy key for the bootstrap and the bootstrap is encrypted, and what is obtained after encryption adds
Close bootstrap with encryption bootstrap digital digest it is described merge be incorporated into step in the license file.
In a preferred embodiment, it before generating the merging step in the license file, further includes to institute
State the step of license information is encrypted: the private key by the digital certificate is that license information generation number is plucked
It wants, and the digital digest by the privacy key for the license information and the license information is encrypted, and is added
The encryption license information obtained after close with encryption license information digital digest it is described merge in step be incorporated into
In the license file.
In a preferred embodiment, it after the encrypting step, and before the merging step, further includes to described secret
The step of key encrypts: the private key by the digital certificate is that the privacy key is encrypted, and what is obtained after encryption adds
Close privacy key is incorporated into the license file in the merging step.
In a preferred embodiment, the method for the verifying license information is comprising steps of from the license
The bootstrap and the license information are parsed in file;Execute the license verifying in the bootstrap
Program verifies the license information;It is verified, then executes the startup program in the bootstrap, into
And run the main body program.
In a preferred embodiment, the license file is stored in mobile memory.
The present invention is by the guard method of the software product provided, by by the startup program of software product and main body program
Separation, and startup program and license proving program are integrated, so that license information must be verified by license
The verifying of program could operate normally startup program, and then run main body program, that is to say, that if license information can not lead to
The verifying or license proving program for crossing license proving program are bypassed, then the startup program of software product will be unable to
Operate normally so that the main body program of software product at all can not load operating, further, preferable reality of the invention
It applies in example, by bootstrap and license information and privacy key encryption, and to license file verification
The improvement of method, improve license file cracks difficulty, so as to preferably protect to software product.
Specific embodiment
To be illustrated technical solution of the present invention and its advantage hereinafter with reference to diagram definitely and in detail.
Referring to Fig. 1, Fig. 1 is painted the guard method flow chart of software product provided by a preferred embodiment of the present invention.
As shown in Figure 1, the guard method of software product includes step: generating license file;License file is verified, if verifying is logical
It crosses, then the main body program of runs software product, it is out of service if verifying does not pass through.
Specifically, referring to Fig. 2, Fig. 2 is painted license file generated provided in a preferred embodiment of the present invention
Method flow diagram.As shown in Fig. 2, the method for generating license file comprises the following steps:
S1 isolates startup program and main body program from software product.The startup program of software product, which refers to, to be run
The Bootloader being had to carry out before the main body program of software product, for example, the main body program for software product carries fortune
Row environment loads the main body program of software product, that is to say, that if the startup program of software product can not normally be held
If row, the main body program of software product will be unable to start.Various specific business are realized in referring to for the main body program of software product
The program of function is that the chief value of software product embodies.In this step, it is logical for separating the mode of startup program and main body program
The code of startup program and main body program is separated from each other independence by the mode for crossing code dehind.In the embodiment of the present invention, software
The development language that product uses is java language.
S2 integrates startup program and license proving program, forms bootstrap.In this step, by integrating code
Mode integrates startup program and license proving program.
S3 merges bootstrap, license information, generates license file.In this step, by designing customized word
Code document convention is saved, bootstrap, license information are written to same file according to customized byte code files rule
In, to generate license file.In the embodiment of the present invention, license information is software product authorization information, packet
Contain: manufacturer, name of product, authorization message, validity period, MAC binding etc..
According in above-mentioned steps license file generated, that is, containing the license information of software product, and wrap
The startup program and license proving program for having contained software product, by by the startup program of software product and main body program
Separation, and startup program is integrated into license file, increase software product cracks difficulty, has reached protection software
The purpose of product.
In order to further promote the protection to software product, can pass through in other preferred embodiments of the invention
Bootstrap or license information are encrypted, increase license file cracks difficulty.Below will respectively by Fig. 3 extremely
Those preferred embodiments are described in detail in Fig. 5.
Referring to Fig. 3, Fig. 3 is painted license document generating method process provided in a preferred embodiment of the present invention
Figure.As shown in figure 3, the difference of the present embodiment and embodiment illustrated in fig. 2 is, step S203 is further included, after step S2,
Before step S3.Step S203 is the step of encryption to bootstrap.In the present embodiment, encryption bootstrap method is logical
It crosses the means of digital certificate and privacy key to realize, is bootstrap including the private key by digital certificate specifically
Digital digest is generated, and the digital digest by privacy key for bootstrap and bootstrap is encrypted, obtains encryption and draw
The digital digest of lead sequence and encryption bootstrap.It is understood that license document generating method provided in this embodiment
In, step S3 merge generate license file when, merging be encrypt bootstrap and encrypt bootstrap number pluck
It wants, it is different from the content that the step S3 in license document generating method shown in Fig. 2 merges, but combined method is all identical,
Therefore it is not repeating herein.Method license file generated in through this embodiment, due to having done number to bootstrap
Abstract, and to both being encrypted, if it is desired to license file is cracked, then not only it should be understood that customized word
Save code document convention, it is also necessary to which completion is decrypted correctly bootstrap and its digital digest, and passes through bootstrap number
The verifying of abstract, it can be seen that, provided license document generating method, can greatly be promoted through this embodiment
License file cracks difficulty, to provide software product more solid protection.
Referring to Fig. 4, Fig. 4 is painted license document generating method process provided in a preferred embodiment of the present invention
Figure.As shown in figure 4, the difference of the present embodiment and embodiment illustrated in fig. 3 is, step S213 is further included, is located at before step S3.
Step S213 is the step of encryption to license information.In the present embodiment, the method for encryption license information is to pass through
The means of digital certificate and privacy key are license information including the private key by digital certificate specifically come what is realized
Digital digest is generated, and the digital digest by privacy key for license information and license information is encrypted, and is obtained
It encrypts license information and encrypts the digital digest of license information.It is understood that license provided in this embodiment
In document generating method, for step S3 when merging generation license file, merging is encryption license information and encryption
The digital digest of license information, it is different from the content that the step S3 in license document generating method shown in Fig. 3 merges, but
It is that combined method is all identical, therefore is not repeating herein.It is not difficult to find out that the present embodiment is based on embodiment illustrated in fig. 3 into one
Step is improved, and for embodiment shown in Fig. 2, is not only encrypted to bootstrap, still same to license information
Sample is encrypted, it can be seen that, the license file generated of method through this embodiment not only has Fig. 2 and Fig. 3
The feature for the license file that illustrated embodiment generates, also by the encryption to license information, so that license file
Crack that step is more complicated, so that further improve license file cracks difficulty.It is understood that the present embodiment
In step S213 and step S203 be independent between each other, that is to say, that in other embodiments of the invention, generating
It only can also include the step S213 encrypted to license information according to actual demand in the method for license file, without
Comprising the step S203 encrypted to bootstrap, therefore this embodiment, it also should belong to the scope that the present invention is protected.
Referring to Fig. 5, Fig. 5 is painted license document generating method process provided in a preferred embodiment of the present invention
Figure.As shown in figure 5, the difference of the present embodiment and embodiment illustrated in fig. 4 is, further include step S223, be located at step S203 and
After S213, before step S3.Step S223 is the step of encryption to privacy key.In the present embodiment, secret encryption is close
It is that privacy key is encrypted that the method for key, which is by the private key of digital certificate, obtains secret encryption key.It is understood that
In license document generating method provided in this embodiment, for embodiment illustrated in fig. 4, merges in step S3 and generate
When license file, encryption bootstrap and its encryption digital digest, encryption license information and its encryption are not only incorporated
Digital digest, still further incorporate secret encryption key, likewise, combined method is all identical, therefore herein not superfluous
It states.
It is worth noting that, in newly-increased step S203, S213 or S223, being used in embodiment shown in Fig. 3 to 5
Cryptographic means be all private key and privacy key by digital certificate, since license file is in normal use process, need
It is decrypted and verifies, and the public key and privacy key of the digital certificate needed for decrypting and verifying in number also all comprising demonstrate,proving respectively
In written matter and privacy key file, it is to be understood that in Fig. 3 into embodiment shown in fig. 5, the text that merges in step S3
Part has further included digital certificate and privacy key (or secret encryption key).
By above-mentioned diagram and description, to the method for the generation license file in method for protecting software of the invention into
Detailed description of having gone carries out the method for the license file verification in embodiment illustrated in fig. 1 detailed below with reference to diagram
Explanation.
Fig. 6 is please referred to, Fig. 6 is painted license file verification method flow diagram provided by a preferred embodiment of the present invention.
Verification method in the present embodiment is the verification method of the license file generated for embodiment illustrated in fig. 2, such as Fig. 6 institute
Show, license file verification method includes the following steps:
A1 parses bootstrap and license information from license file.Specifically, starting in software product
When, it is written in License file since startup program is separated and merged, software product is unable to complete by normal approach
Normal starting, so must by Java Virtual Machine provide bottom ClassLoader extension mechanism, extension realize it is customized
ClassLoader lead to by customized ClassLoader adapter tube Java Virtual Machine to the loading and implementation procedure of startup program
The rewriting to findclass method is crossed, according to customized byte code files rule, license file is parsed, is restored
Bootstrap executes bootstrap.
A2 executes the license proving program in bootstrap, verifies to license information.When bootstrap quilt
Parsing then can be performed bootstrap after restoring, in the embodiment of the present invention, after bootstrap is performed, begin to by drawing
Lead sequence takes over entire start-up course.Bootstrap in the process of implementation first parses license information from license file
Reduction, then license information is verified by internal license proving program.Wherein, in the embodiment of the present invention,
License proving program can be by way of validity verification or the mode of validity period and marc address binding is to license
Information is verified, but the present invention is not limited thereto, can also be verified by other verification modes.
License information is verified by license proving program, according to verification result, selects subsequent processing
Mode executes the startup program in bootstrap, and then run main body program, to complete software product if being verified
Normal starting;If verifying does not pass through, the execution of direct escape leading program, software product will be unable to start.
License file verification method provided in the embodiment of the present invention need to first call self defined class loader, according to
Used customized byte code files rule carries out parsing reduction to license file when generating license file, then by drawing
Lead sequence executes license proving program, to complete the verifying of license information.Obtain license information authentication results it
Before, the either startup program of software product or main body program do not have any movement, so as to avoid license
The verifying of information is bypassed, and provides protection to software product.
For in the verification method of Fig. 3 license file generated into embodiment illustrated in fig. 5, further include to license
Digital certificate and privacy key (or secret encryption key) in file are parsed, and to bootstrap, license information
And the process that corresponding digital digest is decrypted and verifies, it can be seen that, the verification method of license file will be with
The difference of license document generating method and it is different, further improve the difficulty that license proving program is cracked or bypasses
Degree.
In conclusion by the improvement to license file in method for protecting software provided by the present invention, and it is stringent right
The verification process of license file is managed, and improves that license file cracks difficulty and software product modified
Difficulty.For instance, if it is desired to crack the license file generated in embodiment illustrated in fig. 5, it is necessary first to correctly understand
The customized bytecode structure of license file correctly completely parses all modules, forges public key, private key, secret
Key, License information, and License file is regenerated according to encryption logic rule and customized byte code files rule
Or decompiling restores bootstrap, extracts the startup-program code in bootstrap, translates main body program, and starting code is added
Enter into software agent, to bypass License checking procedure, it can be seen that, cracking programs are extremely complex, and difficulty is also very
It is high.
More further, in order to more preferably provide protection to software product, license file can be written to USBKey etc.
In mobile memory, and executes in the findclass method of self defined class loader ClassLoader and read from USBKey
The step of License file, to complete guidance and verification process.