AdvancedHMI Software

General Category => Open Discussion => Topic started by: alfig_controls on September 23, 2022, 02:07:41 PM

Title: Locking Application to Specific Computer
Post by: alfig_controls on September 23, 2022, 02:07:41 PM
Hi All,

I'm trying to implement a sort of security to where the application only works on a specific computer. I'm thinking I can have a hash of the Mac Address that the user has to type in prior to loading the main form. Just curious if anyone has done something similar before? How did you go about it. The application would still be fully open source, but I don't want it to run anywhere else besides the machine server that sits next to the machine.

Title: Re: Locking Application to Specific Computer
Post by: dmroeder on September 23, 2022, 03:38:54 PM
Hi All,

I'm trying to implement a sort of security to where the application only works on a specific computer. I'm thinking I can have a hash of the Mac Address that the user has to type in prior to loading the main form. Just curious if anyone has done something similar before? How did you go about it. The application would still be fully open source, but I don't want it to run anywhere else besides the machine server that sits next to the machine.

I suppose one way would be to hard code the computers hostname in the application.  So in the form load event  If Environment.MachineName isn't equal to your servers hostname, exit.
Title: Re: Locking Application to Specific Computer
Post by: bachphi on September 29, 2022, 09:17:33 PM
The code below will get the macAddress for the connected Enet adapter, thus avoid mac spoofing.

Code: [Select]
For Each nic As NetworkInterface In NetworkInterface.GetAllNetworkInterfaces()

            If nic.OperationalStatus = OperationalStatus.Up Then
                macAddresses += nic.GetPhysicalAddress().ToString()
                Exit For
            End If
        Next

        If macAddresses.Contains("WS_MacAddress") Then
            'Run software
        Else
            'exit
        End If