首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在表单加载前进行HWID验证

如何在表单加载前进行HWID验证
EN

Stack Overflow用户
提问于 2017-02-16 06:43:05
回答 1查看 1.2K关注 0票数 0

首先,我想说清楚,我不是visual basic的“专家”,也不是c#的专业人士。但是这个问题在我的脑海里有好几天了。

“是否可以在加载表单之前验证HWID ?它是如何工作的?”

因为我正在为当地的健身房创建一个软件,所以我想实现一些安全性,而不仅仅是一个基本的“登录表单”。所以,这就引出了我的问题...我如何创建一种简单的方法来从CPU获取HWID,并从纯文本(可能用md5散列加密)验证该列表中是否存在相同的值?我正在寻找一些关于如何做到这一点以及如何在VB.NET和C#上实现它的解释。

代码语言:javascript
复制
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

有什么建议吗?

提前谢谢。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-02-16 21:20:06

我已经找到了解决问题的方法。下面是我写的代码:

代码语言:javascript
复制
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
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/42261495

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档