0

First of all I want to make it clear that I'm no "PRO" at visual basic, neither c#. But I had this question for a few days in my head.

"Is it possible to verify HWID before a form load? And how it works?"

Since I'm creating a software for a local gym, I would like to implement some security, not just a basic "login form". So, it brings me to this question... How can i create a simple way to get the HWID from the CPU and verify from a plain text(maybe encripted with md5 hash) if the same value is on that list? I was looking for some explanation on how to do it and how to implement it on both VB.NET and C#.

Private Sub frmprincipal_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    Dim janela As New frmLogin
    janela.MdiParent = Me
    janela.Show()
    Label4.Text = "Faça login!"
    tmrRelogio.Enabled = True
    bttLogout.Enabled = False
    bttLogout.Visible = False
    Dim hwid As String = String.Empty
    Dim mc As New ManagementClass("win32_processor")
    Dim moc As ManagementObjectCollection = mc.GetInstances()
    For Each mo As ManagementObject In moc
        If hwid = "" Then
            hwid = mo.Properties("processorID").Value.ToString()
            Exit For
        End If
    Next
    Dim request As System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create("https://www.dropbox.com/s/zewro4zubg9qc1s/HWID.txt")
    Dim response As System.Net.HttpWebResponse = request.GetResponse()
    Dim sr As System.IO.StreamReader = New System.IO.StreamReader(response.GetResponseStream())
    Dim hwidcheck As String = sr.ReadToEnd
    If hwidcheck.Contains(hwid) Then
        MsgBox("This is the original copy!", "INFORTGEI", MessageBoxButtons.OK)
        If DialogResult.OK = True Then
            Close()
        End If
    Else
        MsgBox("Contact the admin to activate the copy!", MessageBoxButtons.OK, "INFORTGEI")
    End If
End Sub

Any advices?

Thanks in advance.

  • 2
    Your question is very (too) broad. a) What are you going to do with the ID? How is that "security"? How would it replace a user log on? b) an MD5 hash is not encryption, its a hash, c) MD5 is outdated. Also, please read [Ask] and take the [Tour] – Ňɏssa Pøngjǣrdenlarp Feb 15 '17 at 22:48
  • http://stackoverflow.com/questions/31746613/how-do-i-get-a-unique-identifier-for-a-device-within-windows-10-universal check the answer someone explain how to get the HWID – Kenion Feb 15 '17 at 22:51
  • I've read all those questions and didn't help me quite well. First, since this program is just to be used on a single company computer, that's my purpose to use HWID. Secondly, improves security because, very often they pass the reports throught USB drives, and if anyone gets a copy, they can easly debug it and steal and finaly it wont replace the login form because I still have the login form, it's just a sort of extra verification for my purpose. You can check some code i've tryied to explain what i really want. – Tiago Turella Feb 15 '17 at 22:59
  • 1
    Questions in comments are not supposed to help *you*,they help us understand what you are asking. if you want to do that before the form loads, start your app from Sub Main and do it there. That "security" is trivial to defeat though and means the user cant upgrade their hardware without causing it to not validate. Have you considered a dongle? – Ňɏssa Pøngjǣrdenlarp Feb 16 '17 at 01:43
  • The hardware is from the same company that provided the software, so if there is any necessity, it would be updated.Why buying a dongle when you can create a function regarding this type of situation and save some money? – Tiago Turella Feb 16 '17 at 12:31

1 Answers1

0

I've found a way to resolve my problem. Here is the code i made:

Dim hwid As String = String.Empty
    Dim mc As New ManagementClass("win32_processor")
    Dim moc As ManagementObjectCollection = mc.GetInstances()
    For Each mo As ManagementObject In moc
        If hwid = "" Then
            hwid = mo.Properties("processorID").Value.ToString()
            Exit For
        End If
    Next
    Dim hash As List(Of String) = New List(Of String)(System.IO.File.ReadAllLines("..\HWID.txt"))

    If Not hash.Contains(hwid) Then
        MsgBox("Contact administrator to activate the hardware on the database.", MessageBoxButtons.OK, "INFORTGEI")
        If DialogResult.OK = True Then
            Close()
        End If
    Else
        MsgBox("Activated sucessfully!", MessageBoxButtons.OK, "INFORTGEI")
    End If