Solved

generating machine id

Posted on 2004-10-26
262 Views
Last Modified: 2012-08-14
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
0
Question by:Dany Balian
    7 Comments
     
    LVL 8

    Assisted Solution

    by:Ashutosh Vyas
    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
     
    LVL 26

    Expert Comment

    by:EDDYKT
    >>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
     
    LVL 16

    Expert Comment

    by:jimbobmcgee
    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
     
    LVL 14

    Accepted Solution

    by:
    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
     
    LVL 11

    Author Comment

    by:Dany Balian
    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
     
    LVL 14

    Expert Comment

    by:Shiju Sasidharan
    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
     
    LVL 27

    Expert Comment

    by:Ark
    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

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone. Privacy Policy Terms of Use

    Featured Post

    Course: JavaScript Coding - Massive 12-Part Bundle

    Regardless of your programming skill level, you'll go from basics to advanced concepts in a vast array of JavaScript subjects including Sammy.js, Agility.js, Ember.js, Node.js, jQuery, AJAX, Extjs, AngularJS, Knockout.js, and JSON.

    If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
    When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
    Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
    This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

    877 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now