-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathHWID.vb
152 lines (142 loc) · 8.11 KB
/
HWID.vb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
Imports System.Management
Imports System.Security.Cryptography
Imports System.Text
Public Class HWID
Private Sub HWID_Load(sender As Object, e As EventArgs) Handles Me.Load
CheckBox1.Checked = True
CheckBox2.Checked = True
CheckBox3.Checked = True
CheckBox4.Checked = True
End Sub
Dim condition As Integer
Private Sub ButtonGenerate_Click(sender As Object, e As EventArgs) Handles ButtonGenerate.Click
If CheckBox1.Checked = True And CheckBox2.Checked = False And CheckBox3.Checked = False And CheckBox4.Checked = False Then
condition = 1000
ElseIf CheckBox1.Checked = False And CheckBox2.Checked = True And CheckBox3.Checked = False And CheckBox4.Checked = False Then
condition = 100
ElseIf CheckBox1.Checked = False And CheckBox2.Checked = False And CheckBox3.Checked = True And CheckBox4.Checked = False Then
condition = 10
ElseIf CheckBox1.Checked = False And CheckBox2.Checked = False And CheckBox3.Checked = False And CheckBox4.Checked = True Then
condition = 1
ElseIf CheckBox1.Checked = True And CheckBox2.Checked = True And CheckBox3.Checked = False And CheckBox4.Checked = False Then
condition = 1100
ElseIf CheckBox1.Checked = True And CheckBox2.Checked = True And CheckBox3.Checked = True And CheckBox4.Checked = False Then
condition = 1110
ElseIf CheckBox1.Checked = True And CheckBox2.Checked = True And CheckBox3.Checked = True And CheckBox4.Checked = True Then
condition = 1111
ElseIf CheckBox1.Checked = False And CheckBox2.Checked = True And CheckBox3.Checked = True And CheckBox4.Checked = False Then
condition = 110
ElseIf CheckBox1.Checked = False And CheckBox2.Checked = True And CheckBox3.Checked = True And CheckBox4.Checked = True Then
condition = 111
ElseIf CheckBox1.Checked = False And CheckBox2.Checked = False And CheckBox3.Checked = True And CheckBox4.Checked = True Then
condition = 11
ElseIf CheckBox1.Checked = False And CheckBox2.Checked = True And CheckBox3.Checked = False And CheckBox4.Checked = True Then
condition = 101
ElseIf CheckBox1.Checked = True And CheckBox2.Checked = False And CheckBox3.Checked = True And CheckBox4.Checked = False Then
condition = 1010
ElseIf CheckBox1.Checked = True And CheckBox2.Checked = False And CheckBox3.Checked = False And CheckBox4.Checked = True Then
condition = 1001
ElseIf CheckBox1.Checked = True And CheckBox2.Checked = True And CheckBox3.Checked = False And CheckBox4.Checked = True Then
condition = 1101
ElseIf CheckBox1.Checked = True And CheckBox2.Checked = False And CheckBox3.Checked = True And CheckBox4.Checked = True Then
condition = 1011
End If
TextBox1.Text = Get_HWID()
'MsgBox("Your HWID is = " & Get_HWID())
End Sub
Public Function Get_HWID() As String
Dim strMotherBoardID As String = Nothing
Dim query As New SelectQuery("Win32_BaseBoard")
Dim search As New ManagementObjectSearcher(query)
Dim info As ManagementObject
For Each info In search.Get()
strMotherBoardID = info("SerialNumber").ToString()
Next
Dim disk As ManagementObject = New ManagementObject(String.Format("win32_logicaldisk.deviceid=""{0}:""", "C"))
disk.Get()
Dim mc As ManagementClass = New ManagementClass("Win32_NetworkAdapterConfiguration")
Dim moc As ManagementObjectCollection = mc.GetInstances()
Dim MACAddress As String = String.Empty
For Each mo As ManagementObject In moc
If (MACAddress.Equals(String.Empty)) Then
If CBool(mo("IPEnabled")) Then MACAddress = mo("MacAddress").ToString()
mo.Dispose()
End If
MACAddress = MACAddress.Replace(":", String.Empty)
Next
Dim strProcessorId As String = String.Empty
Dim GHHKJGK As New SelectQuery("Win32_processor")
Dim YUGYUKJH As New ManagementObjectSearcher(GHHKJGK)
Dim fghfgh As ManagementObject
For Each fghfgh In YUGYUKJH.Get()
strProcessorId = fghfgh("processorId").ToString()
Next
Dim sha512 As Security.Cryptography.SHA512 = Security.Cryptography.SHA512Managed.Create()
Dim bytes As Byte()
If condition = 1111 Then
bytes = System.Text.Encoding.UTF8.GetBytes(strProcessorId & disk("VolumeSerialNumber").ToString() & strMotherBoardID & MACAddress)
ElseIf condition = 1 Then
bytes = System.Text.Encoding.UTF8.GetBytes(MACAddress)
ElseIf condition = 11 Then
bytes = System.Text.Encoding.UTF8.GetBytes(strMotherBoardID & MACAddress)
ElseIf condition = 111 Then
bytes = System.Text.Encoding.UTF8.GetBytes(disk("VolumeSerialNumber").ToString() & strMotherBoardID & MACAddress)
ElseIf condition = 1000 Then
bytes = System.Text.Encoding.UTF8.GetBytes(strProcessorId)
ElseIf condition = 100 Then
bytes = System.Text.Encoding.UTF8.GetBytes(disk("VolumeSerialNumber").ToString())
ElseIf condition = 10 Then
bytes = System.Text.Encoding.UTF8.GetBytes(strMotherBoardID)
ElseIf condition = 1001 Then
bytes = System.Text.Encoding.UTF8.GetBytes(strProcessorId & MACAddress)
ElseIf condition = 110 Then
bytes = System.Text.Encoding.UTF8.GetBytes(disk("VolumeSerialNumber").ToString() & strMotherBoardID)
ElseIf condition = 1010 Then
bytes = System.Text.Encoding.UTF8.GetBytes(strProcessorId & strMotherBoardID)
ElseIf condition = 101 Then
bytes = System.Text.Encoding.UTF8.GetBytes(disk("VolumeSerialNumber").ToString() & MACAddress)
ElseIf condition = 1110 Then
bytes = System.Text.Encoding.UTF8.GetBytes(strProcessorId & disk("VolumeSerialNumber").ToString() & strMotherBoardID)
ElseIf condition = 1100 Then
bytes = System.Text.Encoding.UTF8.GetBytes(strProcessorId & disk("VolumeSerialNumber").ToString())
ElseIf condition = 1011 Then
bytes = System.Text.Encoding.UTF8.GetBytes(strProcessorId & strMotherBoardID & MACAddress)
ElseIf condition = 1101 Then
bytes = System.Text.Encoding.UTF8.GetBytes(strProcessorId & disk("VolumeSerialNumber").ToString() & MACAddress)
End If
Dim hash As Byte() = sha512.ComputeHash(bytes)
Dim stringBuilder As New System.Text.StringBuilder()
For i As Integer = 0 To hash.Length - 1
stringBuilder.Append(hash(i).ToString("X2"))
Next
Return stringBuilder.ToString()
End Function
Private Sub CheckBox1_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox1.CheckedChanged
If CheckBox1.Checked = False And CheckBox2.Checked = False And CheckBox3.Checked = False And CheckBox4.Checked = False Then
ButtonGenerate.Enabled = False
Else
ButtonGenerate.Enabled = True
End If
End Sub
Private Sub CheckBox2_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox2.CheckedChanged
If CheckBox1.Checked = False And CheckBox2.Checked = False And CheckBox3.Checked = False And CheckBox4.Checked = False Then
ButtonGenerate.Enabled = False
Else
ButtonGenerate.Enabled = True
End If
End Sub
Private Sub CheckBox3_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox3.CheckedChanged
If CheckBox1.Checked = False And CheckBox2.Checked = False And CheckBox3.Checked = False And CheckBox4.Checked = False Then
ButtonGenerate.Enabled = False
Else
ButtonGenerate.Enabled = True
End If
End Sub
Private Sub CheckBox4_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox4.CheckedChanged
If CheckBox1.Checked = False And CheckBox2.Checked = False And CheckBox3.Checked = False And CheckBox4.Checked = False Then
ButtonGenerate.Enabled = False
Else
ButtonGenerate.Enabled = True
End If
End Sub
End Class