Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Protect from being installed on other pc's 4

Status
Not open for further replies.

neemi

Programmer
May 14, 2002
519
GB
Has anyone come accross any code which I could place in my database to stop the database from being installed on any other computers without maybe requiring a pc secific code etc?

This is to stop reselling of applications written for companies etc.

Cheers,
Neemi
 
If you know the exact computer you want it on, ive made code before that wont allow the program to run unless the drive serial number matches one youve specified.

If you wanted to take this approach you would have to get the serial numbers for all the computers you want this installed on.

Let me know if this is what you want.

-Pete
 
I worked with the dongle keys from SafeNet. These allow you to limit the number of users in the system at any given time. They can be set up so that there is a key on the network, and each time a user logs in, it checks to see if there is an available license on the key. When the user logs out, it frees up their license.

The downside to this approach is that there is a cost for each key that you purchase, and there is a minimum number of keys that you must buy. Also, it takes some work to set up the process initially.

The upside is that it really is easy to use, and once it's set up it requires very little work to use. It's very secure and is a great license enforcement technique. Best of all, you get to use the word "dongle", which is just fun to say!
 
I've designed and implemented a system that checks the PC name against a list of authorised machines (in a table) to only allow a feature to be run on certain PC's. This functionality was an export routine that writes data into an ActiveSync synchronised files folder for PDA synchronisation, only authorised PC's had the docking stations attached.

This technique could be used to stop access to the entire application though.

John
 
snyperx3
I am interested in the approach you have taken. Could you provide me with further info. Code etc? is there a function I could use within vba to get the serial number of a machine?

KornGeek
I shall remember this technique for future apps.

jrbarnett
I understand what u say up untill... "data into an ActiveSync synchronised files folder for PDA synchronisation, only authorised PC's had the docking stations attached". Huh. I'm lost. I don't uderstand what the export routine is doing.. or writing to. I don't understand what this is doing? Sounds like it could be usefull if I understood?

Thank you al for your response.
Neemi
 
You can put this in a module:
Code:
Public Function GetDriveSerialNumber(Optional ByVal DriveLetter As String) As Long
    Dim fso As Object, Drv As Object
          
    Set fso = CreateObject("Scripting.FileSystemObject")

    If DriveLetter <> "" Then
        Set Drv = fso.GetDrive(DriveLetter)
    Else
        Set Drv = fso.GetDrive(fso.GetDriveName(App.Path))
    End If
      
    With Drv
        If .IsReady Then
            DriveSerial = Abs(.SerialNumber)
        Else    '"Drive Not Ready!"
            DriveSerial = -1
        End If
    End With

    Set Drv = Nothing
    Set fso = Nothing
          
    GetDriveSerialNumber = DriveSerial
End Function
Then when you want to get the serial of the drive:
Code:
Dim strSerial as string
strSerial = Hex(GetDriveSerial("C"))

-Pete
 
strSerial = Hex(GetDriveSerial[red]Number[/red]("C"))

forgot a portion of the function name.

-Pete
 
to get the serial number to work, I had to to create a variable for Drive Serial and change the name of the Function to "GetDriveSerial". If I used "GetDriveSerialNumber", the compiler generated an error.
 
Thats strange. Works just fine here the way i have it. =\


-Pete
 
When would the drive serial number change? Reinstallation of windows? Reformatting? etc.
 
Reformatting

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
neemi

The PDA is used by duty officers for storing information and referring to while on call. The Access database exported information to HTML files on disk in a folder.
This folder happenned to be the ActiveSync synchronised files folder for the PDA, so the files got transferred across at next synchronisation.
These files were then viewed with Pocket Internet Explorer on the PDA.

John
 
This is an age old problem with software I think..

I had a database I did exactly the same thing with as you describe... I connected a serial number which i sent by email. I coded an algorithm to generate a serial number from a drive serial number, basically after the system is installed it asks to send an email..it has to do this before they can start to use the system again otherwise it wouldn't allow forms to open etc. THe email contains details of the drive serial and that was sent to me..i would return address ( or phone ) a valid serial that would only work for that machine. If they nicked the first guys serial that works for his machine it wouldn't work for the second etc...

but the beauty is the serial key wasn't demanded until after a month after installation..

So some guy buys your system..it's good and you install it fully and hence hide the serial stuff completely ( he never sees it ) ... he gives it to his mate and cuts you out and is busy filling the database and becoming dependant on it then suddenly he comes in one day and it;s demanding to send an email to you ... by this time he doesn't have much time and you simply say sure i will give you a serial number in exchange for xxx pounds... got 2 clients that way !





Hope this helps!

Regards

BuilderSpec
 
The other advantage to delaying the registration is that if the company that ordered it is slow in paying, this will motivate them.
 
Hi BuilderSpec.

Would you be able to help me out with a copy of the algorithm you used!!?

Cheers,
Neemi

 

The best way is to have a dynamic key.. for example, tell your users that you must register within a single day.

Prompt them for their company name and pick two other things you know of ..for example i could use my work id which is 00775627 and my signon code at work which is gdhf034. Combine these with the current date and the serial number you could get

MyCompanyLtd-00775627-gdhf034-3188C635-1302006 - 1

where the 1 at the end is a check digit and is used to verify the rest of the code is correct.

By having the date in the string you can verify that the serial number came from a valid source. if you had an email that had a different date you could always refuse it as a valid email from the system... the date should always be current if it has come from a proper source. This should stop people sending the same string as someone else , a different day should produce a different string from the same system. ( this is how licensing could work .. you have 2 dates in the key - a start date and an end date , each time the system starts it checks the end date to see if current licence is still valid - great if people are paying by instalments.. )

I would also jumble up the order of the string so as to stop people guessing what it means...

Also for the check sum you could use two check digits not just one.. internet search on fletcher check sum should provide good algorithm. ( basically the first value is all the values OR'd together and the second all the values AND'd ).

Store the licence key in the registry under a stupid name... ever wondered when in the registry you see keys called HSDFG8979JHBVHJ-FDJVG-DBHVBHVBH .. it's deliberate to stop people seeing what is stored there and tinkering.. so save the key under a stupid name that the system knows about but your user would never guess.

Anyway enuff of me...





Hope this helps!

Regards

BuilderSpec
 
Do you wish to share your code at all? for each part of the process?

Thanks in advance.

Neemi
[Ponder]

 
Hi Neemi

I am posting a "module" .. you should be able to copy and paste this code below into a new module and it should work ( access 2000 ).

It is by no means fantastic but does produce some "complex" looking keys.. you can play around with the code as much as you want to add other variables or twists..like alternating each pair of numbers etc..

Look at the function ValidateProduct to see how to use the other functions, this is meant to be a starting blocl but there is no reason why it can't be used as it is.

Incidentally it mentions 2 words..if you want a licence that they can use on any machine then just use any 2 words..if you want to incorporate the serial number , then just make one of the words the serial number.

Tell me what you think...

Regards

Builderspec


Option Compare Database

' All the following functions created in MS Access 2000 13/02/2006
' by Graham Leighton

' Written to illustrate the principles of key licensing. You can play with the encoding
' as this one is fairly simple, it just adds one to each letter. You can adapt it to your
' own needs.

' I also advise that where it mentions the "two words" , you have a different two words for
' each client to prevent key swapping.

' This function creates a check digit and is used for both encoding and decoding the key
Function CreateCheckDigit(key As String)
Dim CheckDigit As Integer

For i = 1 To Len(key)
CheckDigit = CheckDigit + Val(Mid(key, i, 1))
Next i
CheckDigit = CheckDigit Mod 10
CreateCheckDigit = CheckDigit
End Function
' this function creates the key , pass it the company name and two known words
' the known words can be anything, any length and is used as part of the key
' the company name is used so that you can see which company is used

Function CreateKey(CompanyName As String, Word1 As String, Word2 As String)
Dim key As String
Dim i, j As Integer
Dim NewKey As Integer
Dim CheckDigit As Integer

dt = Replace(Date, "/", "")
key = Replace(CompanyName, " ", "") & Word1 & Word2 & dt
For i = 1 To Len(key)
Mid(key, i, 1) = Chr(Asc(Mid(key, i, 1)) + 1)
Next i

CreateKey = key & CreateCheckDigit(key)

End Function
'this function effectively reverses the key and checks:
' 1 that the check digit is correct for the key entered
' 2 that the chosen words appear in the "decoded" string
' 3 that today's date is in the string
'
Function ValidateKey(key As String, Word1 As String, Word2 As String)
Dim i, j As Integer
Dim NewKey As String
Dim valid As Boolean
Dim CheckDigit As String
Dim KeyCheck As String
Dim FoundWord1 As Boolean
Dim FoundWord2 As Boolean

valid = False

NewKey = key

KeyCheck = Left(NewKey, Len(NewKey) - 1)
CheckDigit = CreateCheckDigit(KeyCheck)
If CheckDigit <> Right(NewKey, 1) Then
ValidateKey = False
Exit Function
End If


For i = 1 To Len(NewKey)
Mid(NewKey, i, 1) = Chr(Asc(Mid(NewKey, i, 1)) - 1)
Next i
For j = 1 To Len(NewKey) - Len(Word1)
If Mid(NewKey, j, Len(Word1)) = Word1 Then
FoundWord1 = True
End If
Next j
For j = 1 To Len(NewKey) - Len(Word2)
If Mid(NewKey, j, Len(Word2)) = Word2 Then
FoundWord2 = True
End If
Next j
If FoundWord1 And FoundWord2 Then
valid = True
Else
valid = False
End If
If Not valid Then
ValidateKey = False
Exit Function
End If




dt = Left(Right(NewKey, 9), 8)

If dt = Replace(Date, "/", "") Then
valid = True
Else
valid = False
End If

ValidateKey = valid
End Function

' this is intended to show how you might use the above functions
' it creates a key then prompts you to enter a key, then validates
' the key against the key it generated itself , they should be the
' same.
' try it the day after and the key will be different
' you could alter the msgbox to display your phone number so they have to ring
' for a key!
' assumes that the company name will be held somewhere on the database or other
Function ValidateProduct()
Dim KeyGen As String
Dim ac As Integer
Dim KeyInput As String
Dim valid As Boolean
valid = False
KeyGen = CreateKey("My Company Ltd", "hstd004", "esauf02")
KeyInput = InputBox("Please enter licence key", "Key Required", "")

If Len(KeyInput) > 0 Then
If Not ValidateKey(KeyInput, "hstd004", "esauf02") Then
MsgBox "Not a valid key for this product" & vbCrLf & "Please contact ????", vbCritical
valid = False
Else
valid = True
MsgBox "Thank you registering this product with us blah blah blah"
End If
End If
ValidateProduct = valid

End Function

 
Hi BuilderSpec,
I would love to see your code working but I'm struggling to understand it. Could you highlight the bits I would need to change and maybe a little more explanation of how it works for us new guys to coding? Sorry Neemi for butting into your post.
 
to see it working copy and paste the code and make sure it compiles ok..

then in the immediate window . type

? CreateKey ( "ABC Ltd" , "Frank" , "Drebin" )
BCDMueGsbolEsfcjo261331174

here I am choosing a key for company ABC Ltd and my two chosen words are Frank and Drebin

this should have returned a key like the one above.. copy it. ( Note since the key contains the date also , the key above was generated on the 15/02/2006. a differenet date would have produced a different key - so don't worry if it doesn't match .)

Now in the function ValidateProduct ..find every occurence of "hstd004" and replace it with "Frank". find every occurence of "esauf02" replace it with "Drebin".

Now in the immediate window type

? ValidateProduct

this will pop up a box asking you to enter the key .. paste the one you copied earlier and press Ok . you should have entered a valid key and get the the Thank You message.
Note also that in the immediate window the function returned the value True.

Now in the immediate window type

? ValidateProduct

Only this time type anything you like , or paste the key back in and change some of the characters. Now press OK and you should (!) get the licence not valid message.
Note also that in the immediate window the function returned the value False.

A better function so you don't need to change code
===================================================


Function ValidateProductWords(Word1 As String, Word2 As String)
Dim ac As Integer
Dim KeyInput As String
Dim valid As Boolean
valid = False

KeyInput = InputBox("Please enter licence key", "Key Required", "")

If Len(KeyInput) > 0 Then
If Not ValidateKey(KeyInput, Word1, Word2) Then
MsgBox "Not a valid key for this product" & vbCrLf & "Please contact ????", vbCritical
valid = False
Else
valid = True
MsgBox "Thank you registering this product with us blah blah blah"
End If
End If
ValidateProductWords = valid

End Function


this function is the same as ValidateProduct except you pass the words in rather than having to change the code .

To test this you would say ( in the immediate window )

? CreateKey("ABC Ltd","Michael","Parkinson")
BCDMueNjdibfmQbsljotpo261331174
? ValidateProductWords("Michael","Parkinson")

This way you wouldn't have to change the code at all unless you wanted to play with the algorithm.
(Remember that CreateKey will return different keys on different dates with the same 2 words )


How would you use this code in practice
=======================================

On your startup form you would "find" the existing licence key ( could be saved in a file , in the database , in the registry ), you will have marked a flag somewhere to say that it was valid.

Then you would call something like

Dim LicenceValid as Boolean
Dim CompanyName as String

'...
'some code to get company name from db
'...

LicenceValid = ValidateProductWords ( CompanyName, "Word1","Word2)
if not LicenceValid then
Application.Quit
end if


but harsh but demonstrates the principle.


Hope this helps!

Regards

BuilderSpec
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top