HWID Class

03/27/2011 05:35 Syst3m_W1z4rd#1
Language = VB.

I don't take credits for any of the content, but I thought I would share it here, because it can be used for banning peoples. It will make them not able to login, even with ipchange. They would have to switch pc. In some cases it will work better than IPBan, but giving both will have a good effect of ban.

All credits goes to Aeonhack

Source:
Code:
Imports System.Text
Imports System.Net.NetworkInformation
Imports System.Management

Class Machine
    Const PN As UShort = 4129

    Private ID(3) As String
    Private Table(255) As UShort
    Private UTF8 As New UTF8Encoding

    Private _HardwareID As String
    ReadOnly Property HardwareID() As String
        Get
            Return _HardwareID
        End Get
    End Property

    Private _Seed As UShort
    Sub New(Optional ByVal seed As UShort = 0)
        Dim R As String = String.Format(" WHERE DeviceID='{0}:'", Environment.SystemDirectory(0))
        ID(0) = Search("Win32_BaseBoard", "SerialNumber")
        ID(1) = Search("Win32_Processor", "ProcessorID")
        ID(2) = Search("Win32_LogicalDisk" & R, "VolumeSerialNumber")
        ID(3) = Search()
        _Seed = seed
        Generate()
    End Sub

    Private Function Search(ByVal element As String, ByVal item As String) As String
        element = String.Format("SELECT {0} FROM {1}", item, element)

        Dim T As New StringBuilder
        Dim U As New ManagementObjectSearcher(element)
        For Each O As ManagementObject In U.Get
            If Not O(item) Is Nothing Then T.Append(O(item))
        Next
        U.Dispose()
        Return T.ToString
    End Function
    Private Function Search() As String
        For Each O As NetworkInterface In NetworkInterface.GetAllNetworkInterfaces
            If O.OperationalStatus = OperationalStatus.Up Then Return O.GetPhysicalAddress.ToString
        Next
        Return String.Empty
    End Function

    Private Function CRC16(ByVal data As Byte()) As UShort
        CRC16 = _Seed
        For I As Integer = 0 To data.Length - 1
            CRC16 = CRC16 << 8 Xor Table(CRC16 >> 8 Xor data(I))
        Next
        _Seed = CRC16
    End Function
    Private Sub CreateTable()
        Dim V, T As UShort
        For I As UShort = 0 To 255
            V = 0
            T = I
            For U As Byte = 0 To 7
                If ((V Xor T) And 1) <> 0 Then V = V >> 1 Xor PN Else V >>= 1
                T >>= 1
            Next
            Table(I) = V
        Next
    End Sub

    Private Sub Generate()
        CreateTable()
        Dim T As New List(Of Byte)
        For I As Byte = 0 To 3
            T.AddRange(BitConverter.GetBytes(CRC16(UTF8.GetBytes(ID(I)))))
        Next
        _HardwareID = BitConverter.ToString(T.ToArray).Replace(Convert.ToChar(45), String.Empty)
    End Sub

    Function Check(ByVal id As String) As Boolean
        If Not id.Length = 16 Then Return False
        id = id.Replace(Convert.ToChar(45), String.Empty).ToUpper

        Dim M As Integer
        For I As Byte = 0 To 15 Step 4
            If Not id.Substring(I, 4) = _HardwareID.Substring(I, 4) Then M += 1
        Next

        If M > 1 Then Return False Else Return True
    End Function
End Class
Generate:
Code:
'We can create a new Machine instance
'with a seed so that the ID is unique to
'our application.

'The current seed is 1234. The range
'you can use is below.

'0 Default - 65535 Maximum
Dim T As New Machine(1234)

'This will return the machines ID.
Dim ID As String = T.HardwareID
Check:
Code:
Dim T As New Machine(1234)

'Here we check if at least 3/4 of
'the components match.
If T.Check(ID) Then
    'We have a match, do something.
End If
03/27/2011 11:29 Basser#2
Honestly not in the mood to read any code longer than 2 lines, so could you please tell me what this does? How do you identify a machine?
03/27/2011 22:31 |NeoX#3
Dude research for Hardware ID you will find alot.
03/28/2011 00:23 Syst3m_W1z4rd#4
Quote:
Originally Posted by Basser View Post
Honestly not in the mood to read any code longer than 2 lines, so could you please tell me what this does? How do you identify a machine?
Motherboard, processor, hard drive etc. That's what this can do.
03/28/2011 05:06 nTL3fTy#5
Correct me if I'm wrong, but wouldn't this need to be run client-side?
03/28/2011 05:29 Santa#6
Quote:
Originally Posted by nTL3fTy View Post
Correct me if I'm wrong, but wouldn't this need to be run client-side?
That is exactly what i was thinking.
03/28/2011 08:15 Syst3m_W1z4rd#7
Quote:
Originally Posted by nTL3fTy View Post
Correct me if I'm wrong, but wouldn't this need to be run client-side?
Yup, then you make it interact with the server :)
03/28/2011 11:01 |NeoX#8
HWID As UID as example :)