There's no sure way to add protection to software and the more you try, just increases the risk of annoying your softwares users
You can easily generate a unique license file for a user on a server and add results for multiple tests, locking it to a specific user or machine
though it'd be still be fairly trivial to patch the test points in the exe to circumvent them.
Something like this maybe?
Code: Select all
;on server
Procedure hidekey(MasterKey.s,publicKey.s,privateKey.s)
Protected result.q,MasterPublic.s
fn = OpenFile(#PB_Any,"randomfile.dat")
If fn
For a = 0 To 2048
WriteByte(fn,Random(42)+48)
Next
For a = 1 To Len(MasterKey)
MasterPublic + Chr(PeekC(@MasterKey+a) ! PeekC(@publicKey+a))
Next
For a = 1 To Len(MasterKey)
result = CRC32Fingerprint(@MasterPublic,Len(MasterKey),result) & $FFFFFF
result % 2048
FileSeek(fn,result)
byte = Asc(Mid(privatekey,a,1))
WriteByte(fn,byte)
Next
;add aes encypted data block using the users private key containing results of fingerprints ...
CloseFile(fn)
EndIf
EndProcedure
;in client
Procedure.s GetKey(MasterKey.s,publicKey.s)
Protected key.s,result.q,MasterPublic.s
fn = OpenFile(#PB_Any,"randomfile.dat")
For a = 1 To Len(MasterKey)
MasterPublic + Chr(PeekC(@MasterKey+a) ! PeekC(@publicKey+a))
Next
If fn
For a = 1 To Len(MasterKey)
result = CRC32Fingerprint(@MasterPublic,Len(MasterKey),result) & $FFFFFF
result % 2048
FileSeek(fn,result)
key + Chr(ReadByte(fn))
Next
CloseFile(fn)
EndIf
ProcedureReturn key
EndProcedure
Define SharedKey.s,DecryptionKey.s,PublicKey.s
Global dump.s=Space(2048)
;On first run of program, it regsiters the user sending to the server the users data and fingerprints
;Server generates a random license file for the user to use the application
;appends the encrpyted data block to the license file with specific test results, could be hardware fingerprints
;to tie the license file to a specific machine or user
SharedKey = MD5Fingerprint(@"TheSharedKey",12) ;A shared key in the exe and used on server
DecryptionKey = MD5Fingerprint(@"DecryptionKey",13) ;A user specific decryption key to an encypted data block
PublicKey = MD5Fingerprint(@"bob@billbob.com",15) ;The resistered users key sent back to the user
hidekey(SharedKey,PublicKey,DecryptionKey) ;Generate the license file hides the decryption key
;Server returns the PublicKey, RandomFile with appended encrpyted data block, saves them in the application data dir
fn = OpenFile(#PB_Any,"randomfile.dat")
ReadData(fn,@dump,2048)
Debug dump
CloseFile(fn)
Debug "---------------------------------------------------"
;client gets the decyption key from the publickey
Debug getkey(SharedKey,PublicKey)
Debug DecryptionKey
;decrypts the data block used for multiple validation tests while running the exe