generating machine id

hello, i just made a small point of sale program, with an access database...
to fully test and debug the program, i will install it in a small grocery store... (for free)
i just want to add a small protection to it...

the access database is password protected

what i need is:
when i first install the software, i will run an executable that will generate a key based on the computer hardware...
and will store it in the database

then, everytime the program runs, it will regenerate the same key based on the same computer hardware... the generated key will then be compared to the one in the database...
if there's no match, then the program was copied to another machine... and it will block...

so i need a function that will generate a key based on the specific computer:
ex: network card mac address, hard drive serial number, number of devices, name to which windows is registered....

the principle is something similar to microsoft's activation machine id...

i appreciate any help

Dan
LVL 11
Dany BalianCTOAsked:
Who is Participating?
 
Shiju SasidharanAssoc Project ManagerCommented:
Hi mrdany

'Try this Function to get Serial No of the Hard Drive
'This function will return the Serial No of the First
' fixed Drive found in Hexa Decimal Format
'  ( Dont forget to add Refererence to  scrrun.dll
'                   Microsoft Scripting Runtime )
'-------------------------------------------------------------------------------
Private Function GetSerialNo() as String

Dim objFso As New FileSystemObject
Dim objDrs As Drives
Dim objDr As Drive
Dim sSlNo as String

    Set objDrs = objFso.Drives
    For Each objDr In objDrs
        If objDr.DriveType = Fixed Then
           sSlNo = Hex(objDr.SerialNumber)
           Exit For
        End If
    Next
   GetSerialNo= sSlNo
End Function
'-----------------------------------------------------------------
;-)
Shiju
0
 
Ashutosh VyasFounder, InitQubeCommented:
To retrieve Mother Board's serial number :
http://www.freevbcode.com/ShowCode.Asp?ID=2664

To retrieve Hard Disk Serial Number
http://www.freevbcode.com/ShowCode.Asp?ID=430
0
 
EDDYKTCommented:
>>the access database is password protected

it is really easy to break. Don't save any import info into.



Why don't you just create your own program based on the network card mac address to create your serial number.

You can get mac address from ipconfig.

During installation, you can check to see whether the mac address same as the computer that installed
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
jimbobmcgeeCommented:
You can use the Crypt... Windows APIs to construct/hash a serial from the information you provide.  You might like to check out the API-Guide (www.allapi.net) for more details...

J.
0
 
Dany BalianCTOAuthor Commented:
just one more question...
cant this hard drive serial number be spoofed?

because i once had adsl connection restrictions from my isp on my mac address, but i wanted to use the same connection on another machine, so i spoofed the mac address on the other machine... i bet that there are spoofers for hard drives...

and do you know how to md5(the serial number) in visual basic?
0
 
Shiju SasidharanAssoc Project ManagerCommented:
Hi
Thanks for the points

Follow this link, here u will get lots of implemented alogorithms in VB
( Watch out the sample of author David Midkiff its a nice and good one)

http://www.a1vbcode.com/code.asp?type=security&intPage=6

;-)
Shiju

0
 
ArkCommented:
Hi
Just to make this PAQ more usefull -
>>this Function to get Serial No of the Hard Drive<<
Above function have NOTHING with HDD serial (as well as #430 FreeVBCode sample) - it returns VOLUME serial. This is NOT a hardware info, this number can be change manually and change automatically every time you format/revormat the drive, chnage partitons etc. Also, solution, based only on 1 unique number is dangerous - if user change, say, his HDD your up won't work though user have all rights. Better solution should be based on a number of unique numbers and if, say, 75% of them match - it's OK. If you're planing your app for w2K/XP - you can use WMI object:

'=======collect system hardware info using WMI object sample====
Private Sub Command1_Click()
   Dim WMI As Object
   Dim wmiCollection As Object
   Dim wmiMember As Object
   Dim oTemp As Object
   Dim sOut As String, sTemp As String
   Dim i As Integer
   Set WMI = GetObject("winmgmts:\\")
   
   Set wmiCollection = WMI.InstancesOf("Win32_BIOS")
   For Each wmiMember In wmiCollection
       sOut = "Serial number: " & CheckValue(wmiMember.SerialNumber)
       sOut = sOut & vbCrLf & "Manufacturer: " & CheckValue(wmiMember.Manufacturer)
       sOut = sOut & vbCrLf & "Manufacturer's identifier: " & CheckValue(wmiMember.IdentificationCode)
       sOut = sOut & vbCrLf & "BIOS version: " & wmiMember.version
       sTemp = Trim(wmiMember.ReleaseDate)
       sOut = sOut & vbCrLf & "Release date: " & DateSerial(Left(sTemp, 4), Mid(sTemp, 5, 2), Mid(sTemp, 7, 2))
       If Mid(sTemp, 9, 1) <> "*" Then
          sOut = sOut & "  " & TimeSerial(Mid(sTemp, 9, 2), Mid(sTemp, 11, 2), Mid(sTemp, 13, 2))
       End If
       MsgBox sOut, vbInformation, wmiMember.Caption & " info"
   Next
   
   Set wmiCollection = WMI.InstancesOf("Win32_BaseBoard")
   For Each wmiMember In wmiCollection
       sOut = "Description: " & CheckValue(wmiMember.Description)
       sOut = sOut & vbCrLf & "Manufacturer: " & CheckValue(wmiMember.Manufacturer)
       sOut = sOut & vbCrLf & "Model: " & CheckValue(wmiMember.Model)
       sOut = sOut & vbCrLf & "Manufacturer's identifier: " & CheckValue(wmiMember.SKU)
       sOut = sOut & vbCrLf & "System name: " & CheckValue(wmiMember.Tag)
       sOut = sOut & vbCrLf & "Version: " & CheckValue(wmiMember.version)
       sOut = sOut & vbCrLf & "Width x Height x Weight: " & CheckValue(wmiMember.Width) & " x " & CheckValue(wmiMember.Height) & " x " & CheckValue(wmiMember.Weight)
       sOut = sOut & vbCrLf & "Serial number: " & CheckValue(wmiMember.SerialNumber)
       sOut = sOut & vbCrLf & "Product number: " & wmiMember.Product
       MsgBox sOut, vbInformation, wmiMember.Caption & " info"
   Next
   
   Set wmiCollection = WMI.InstancesOf("Win32_MotherboardDevice")
   For Each wmiMember In wmiCollection
       sOut = "Description: " & CheckValue(wmiMember.Description)
       sOut = sOut & vbCrLf & "DeviceID: " & CheckValue(wmiMember.DeviceID)
       sOut = sOut & vbCrLf & "Name: " & CheckValue(wmiMember.Name)
       sOut = sOut & vbCrLf & "Install date: " & CheckValue(wmiMember.InstallDate)
       sOut = sOut & vbCrLf & "Revision number: " & CheckValue(wmiMember.RevisionNumber)
       sOut = sOut & vbCrLf & "System name: " & CheckValue(wmiMember.systemname)
       MsgBox sOut, vbInformation, wmiMember.Caption & " info"
   Next
   
   Set wmiCollection = WMI.InstancesOf("Win32_Processor")
   For Each wmiMember In wmiCollection
       sOut = "Description: " & CheckValue(wmiMember.Description)
       sOut = sOut & vbCrLf & "DeviceID: " & CheckValue(wmiMember.DeviceID)
       sOut = sOut & vbCrLf & "Manufacturer: " & CheckValue(wmiMember.Manufacturer)
       sOut = sOut & vbCrLf & "Name: " & CheckValue(wmiMember.Name)
       sOut = sOut & vbCrLf & "ProcessorID: " & CheckValue(wmiMember.ProcessorID)
       sOut = sOut & vbCrLf & "System name: " & CheckValue(wmiMember.systemname)
       sOut = sOut & vbCrLf & "UniqueID: " & CheckValue(wmiMember.UniqueID)
       sOut = sOut & vbCrLf & "Install date: " & CheckValue(wmiMember.InstallDate)
       sOut = sOut & vbCrLf & "Revision number: " & CheckValue(wmiMember.Revision)
       MsgBox sOut, vbInformation, wmiMember.Caption & " info"
   Next
   
   Set wmiCollection = WMI.InstancesOf("Win32_PhysicalMemory")
   For Each wmiMember In wmiCollection
       sOut = "Description: " & CheckValue(wmiMember.Description)
       sOut = sOut & vbCrLf & "Bank label: " & CheckValue(wmiMember.BankLabel)
       sOut = sOut & vbCrLf & "Capacity: " & CheckValue(wmiMember.Capacity)
       sOut = sOut & vbCrLf & "Manufacturer: " & CheckValue(wmiMember.Manufacturer)
       sOut = sOut & vbCrLf & "Model: " & CheckValue(wmiMember.Model)
       sOut = sOut & vbCrLf & "Manufacturer's identifier: " & CheckValue(wmiMember.SKU)
       sOut = sOut & vbCrLf & "System name: " & CheckValue(wmiMember.Tag)
       sOut = sOut & vbCrLf & "Version: " & CheckValue(wmiMember.version)
       sOut = sOut & vbCrLf & "Install date: " & CheckValue(wmiMember.InstallDate)
       sOut = sOut & vbCrLf & "Serial number: " & CheckValue(wmiMember.SerialNumber)
       MsgBox sOut, vbInformation, wmiMember.Caption & " info"
   Next
   
   Set wmiCollection = WMI.InstancesOf("Win32_DiskDrive")
   For Each wmiMember In wmiCollection
       sOut = "Description: " & CheckValue(wmiMember.Description)
       sOut = sOut & vbCrLf & "DeviceID: " & CheckValue(wmiMember.DeviceID)
       sOut = sOut & vbCrLf & "Install date: " & CheckValue(wmiMember.InstallDate)
       sOut = sOut & vbCrLf & "Model: " & CheckValue(wmiMember.Model)
       sOut = sOut & vbCrLf & "Signature: 0x" & Hex(wmiMember.Signature)
       Set oTemp = WMI.Get("Win32_PhysicalMedia.Tag='\\.\PHYSICALDRIVE0'")
       sOut = sOut & vbCrLf & "Serial number: " & CheckValue(oTemp.SerialNumber)
       MsgBox sOut, vbInformation, wmiMember.Caption & " info"
   Next
   
   Set wmiCollection = WMI.InstancesOf("Win32_NetworkAdapter")
   sOut = ""
   For Each wmiMember In wmiCollection
       sOut = sOut & "Name: " & wmiMember.Caption & " - MAC Address: " & CheckValue(wmiMember.MACAddress) & vbCrLf
   Next
   MsgBox sOut, vbInformation, "Network adapters info"
   
   Set wmiMember = Nothing
   Set wmiCollection = Nothing
   Set WMI = Nothing
End Sub

Private Function CheckValue(ByVal s As Variant) As String
   If VarType(s) = vbNull Then s = ""
   s = Trim(s)
   If s = "" Then CheckValue = "Not available" Else CheckValue = s
End Function

Private Sub Form_Load()
   Command1.Caption = "Show system info"
End Sub
'========end WMI sample=========
Some other samples not using WMI:
***Get REAL HDD Serial (aka VendorID)***
http://freevbcode.com/ShowCode.Asp?ID=3380
'Note - works with IDE drives only. I have a code for SCSI drives, but it works on NT platform (NT/2K/XP) only.

*** Get BIOS Info ***
http://freevbcode.com/ShowCode.Asp?ID=3292
'Note - NT platform doesn't support direct memory access to system memory area, so bios unique number is not available on NT, though all other info is available

*** MAC Address ***
http://vbnet.mvps.org/code/network/macaddress.htm
'Note - code doesn't work on laptop winXP systems. To get MAC address on XP you shoud use GetIFEntry fro iphlpapi.dll
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.