Sinisterly
[Source]HWID Protection - Printable Version

+- Sinisterly (https://sinister.ly)
+-- Forum: Coding (https://sinister.ly/Forum-Coding)
+--- Forum: Visual Basic & .NET Framework (https://sinister.ly/Forum-Visual-Basic-NET-Framework)
+--- Thread: [Source]HWID Protection (/Thread-Source-HWID-Protection)

Pages: 1 2


[Source]HWID Protection - 1llusion - 01-23-2011

Hi,

So, here is a little HWID code. It isn't 100% secure, so don't rely on it Smile

Code:
Imports System.Management Imports System.Net Public Class Form1 Dim cpuInfo As String = String.Empty Dim mc As New ManagementClass("win32_processor") Dim moc As ManagementObjectCollection = mc.GetInstances() Public Shared Function rc4(ByVal message As String, ByVal password As String) As String Dim i As Integer = 0, j As Integer = 0, cipher As New System.Text.StringBuilder Dim returnCipher As String = String.Empty Dim sbox As Integer() = New Integer(256) {} Dim key As Integer() = New Integer(256) {} Dim intLength As Integer = password.Length, a As Integer = 0 While a <= 255 Dim ctmp As Char = (password.Substring((a Mod intLength), 1).ToCharArray()(0)) key(a) = Microsoft.VisualBasic.Strings.Asc(ctmp) sbox(a) = a System.Math.Max(System.Threading.Interlocked.Increment(a), a - 1) End While Dim x As Integer = 0, b As Integer = 0 While b <= 255 x = (x + sbox(b) + key(b)) Mod 256 Dim tempSwap As Integer = sbox(b) sbox(b) = sbox(x) sbox(x) = tempSwap System.Math.Max(System.Threading.Interlocked.Increment(b), b - 1) End While a = 1 While a <= message.Length Dim itmp As Integer = 0 i = (i + 1) Mod 256 j = (j + sbox(i)) Mod 256 itmp = sbox(i) sbox(i) = sbox(j) sbox(j) = itmp Dim k As Integer = sbox((sbox(i) + sbox(j)) Mod 256) Dim ctmp As Char = message.Substring(a - 1, 1).ToCharArray()(0) itmp = Asc(ctmp) Dim cipherby As Integer = itmp Xor k cipher.Append(Chr(cipherby)) System.Math.Max(System.Threading.Interlocked.Increment(a), a - 1) End While returnCipher = cipher.ToString cipher.Length = 0 Return returnCipher End Function Friend Function hwid() As String Return GetProcessorId() & "-" & GetMACAddress() & "-" & GetVolumeSerial() End Function Friend Function GetProcessorId() As String Dim strProcessorId As String = String.Empty Dim query As New SelectQuery("Win32_processor") Dim search As New ManagementObjectSearcher(query) Dim info As ManagementObject For Each info In search.Get() strProcessorId = info("processorId").ToString() Next Return strProcessorId End Function Friend Function GetMACAddress() As String 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 Return MACAddress End Function Friend Function GetVolumeSerial(Optional ByVal strDriveLetter As String = "C") As String Dim disk As ManagementObject = New ManagementObject(String.Format("win32_logicaldisk.deviceid=""{0}:""", strDriveLetter)) disk.Get() Return disk("VolumeSerialNumber").ToString() End Function Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Timer1.Start() If Connection() = True Then Dim wc As New WebClient Dim strings As String Dim HWID As String strings = wc.DownloadString("Here put link to textfile where the HWIDS will be stored") HWID = GetProcessorId() & "-" & GetMACAddress() & "-" & GetVolumeSerial() wc.Dispose() If strings.Contains(HWID) Then Me.Show() MsgBox("Access Granted!", MsgBoxStyle.Information) End If If strings.Contains(HWID) = False Then MsgBox("Access Denied!", MsgBoxStyle.Critical) Me.Close() End If Else MsgBox("Connect To The Internet!", MsgBoxStyle.Information) Me.Close() End If End Sub Sub Protect() Dim TargetProcess1() As Process = Process.GetProcessesByName("Fiddler") Dim TargetProcess2() As Process = Process.GetProcessesByName("SimpleAssemblyExplorer") Dim TargetProcess3() As Process = Process.GetProcessesByName("Reflector") Dim TargetProcess4() As Process = Process.GetProcessesByName("HxD") Dim TargetProcess5() As Process = Process.GetProcessesByName("Ollydb") If Not TargetProcess1.Length = 0 Then TargetProcess1(0).Kill() MsgBox("Fiddler Detected!", MsgBoxStyle.Critical, "WTF?!") Me.Close() End If If Not TargetProcess2.Length = 0 Then TargetProcess2(0).Kill() MsgBox("SimpleAssemblyExplorer Detected!", MsgBoxStyle.Critical, "WTF?!") Me.Close() End If If Not TargetProcess3.Length = 0 Then TargetProcess3(0).Kill() MsgBox("Reflector Detected!", MsgBoxStyle.Critical, "WTF?!") Me.Close() End If If Not TargetProcess4.Length = 0 Then TargetProcess4(0).Kill() MsgBox("HxD Detected!", MsgBoxStyle.Critical, "WTF?!") Me.Close() End If If Not TargetProcess5.Length = 0 Then TargetProcess5(0).Kill() MsgBox("Ollydb Detected!", MsgBoxStyle.Critical, "WTF?!") Me.Close() End If End Sub Public Function Connection() As Boolean Dim sitetocheck As New System.Uri("http://www.google.com/") Dim checkrequest As System.Net.WebRequest checkrequest = System.Net.WebRequest.Create(sitetocheck) Dim objResp As System.Net.WebResponse Try objResp = checkrequest.GetResponse objResp.Close() checkrequest = Nothing Return True Catch x As Exception Return False End Try End Function Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick Protect() End Sub End Class

Credits to: bLaZeD

Here is how to get the HWID:
Code:
Friend Function hwid() As String Return GetProcessorId() & "-" & GetMACAddress() & "-" & GetVolumeSerial() End Function Friend Function GetProcessorId() As String Dim strProcessorId As String = String.Empty Dim query As New SelectQuery("Win32_processor") Dim search As New ManagementObjectSearcher(query) Dim info As ManagementObject For Each info In search.Get() strProcessorId = info("processorId").ToString() Next Return strProcessorId End Function Friend Function GetMACAddress() As String 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 Return MACAddress End Function Friend Function GetVolumeSerial(Optional ByVal strDriveLetter As String = "C") As String Dim disk As ManagementObject = New ManagementObject(String.Format("win32_logicaldisk.deviceid=""{0}:""", strDriveLetter)) disk.Get() Return disk("VolumeSerialNumber").ToString() End Function Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click TextBox1.Text = GetProcessorId() & "-" & GetMACAddress() & "-" & GetVolumeSerial() End Sub
Smile

PS: Don't forget to add system.management reference Biggrin


RE: [Source]HWID Protection - 1234hotmaster - 01-23-2011

awsome! i really needed this for my p0rnbrowser! tnx a bounch man Biggrin


RE: [Source]HWID Protection - Amzer - 01-23-2011

Very nice and clear code. ThanksSmile


RE: [Source]HWID Protection - Coder-san - 01-23-2011

Nice. But don't use Messagebox confirmations, makes you an easier target for cracking.


RE: [Source]HWID Protection - 1234hotmaster - 01-23-2011

Imports System.Management is not supported for .Net FRW 2 Sad

what to do?


RE: [Source]HWID Protection - 1234hotmaster - 01-23-2011

oh that i already fixed it added: C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Management.dll


RE: [Source]HWID Protection - 1llusion - 03-16-2011

Glad you liked it Smile


RE: [Source]HWID Protection - 1llusion - 03-16-2011

Glad you liked it Smile


RE: [Source]HWID Protection - The Exordium - 08-05-2011

Thank for the basics mate.


RE: [Source]HWID Protection - FrostByte_mybb_import5923 - 08-05-2011

nice share, im going to add this to my source code database site - http://www.sourcex.info