[VB] HWID System

05/28/2012 17:51 Whoknowsit#1
Moin,

ich habe vor einigen Tagen mit VB.Net angefangen und direkt eine Frage dazu :p Es geht um das E*PVP HWID-System.

Dieses würde ich gerne in einem meiner Projekte einsetzen und tu dies auch schon recht erfolgreich. Warum ich schreibe ist, dass ich glaube, dass man das Ganze noch optimieren könnte :) Falls nicht, umso besser. Falls doch, freue ich mich über jeden Vorschlag.

Code:
Imports System.Runtime.InteropServices
Imports System.Text
Imports System.Security.Cryptography

Public Class HWID
    <Flags()> _
    Private Enum DockInfo
        DOCKINFO_DOCKED = &H2
        DOCKINFO_UNDOCKED = &H1
        DOCKINFO_USER_SUPPLIED = &H4
        DOCKINFO_USER_DOCKED = &H5
        DOCKINFO_USER_UNDOCKED = &H6
    End Enum

    <StructLayout(LayoutKind.Sequential)> _
    Public Class HW_PROFILE_INFO
        <MarshalAs(UnmanagedType.U4)> _
        Public dwDockInfo As Int32

        <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=39)> _
        Public szHwProfileGuid As String

        <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=80)> _
        Public szHwProfileName As String
    End Class

    <DllImport("advapi32.dll", SetLastError:=True)> _
    Private Shared Function GetCurrentHwProfile(lpHwProfileInfo As IntPtr) As Boolean
    End Function

    Declare Function GetVolumeInformationA Lib "kernel32" ( _
        PathName As String, _
        VolumeNameBuffer As StringBuilder, _
        VolumeNameSize As UInt32, _
        ByRef VolumeSerialNumber As UInt32, _
        ByRef MaximumComponentLength As UInt32, _
        ByRef FileSystemFlags As UInt32, _
        FileSystemNameBuffer As StringBuilder, _
        FileSystemNameSize As UInt32) As Long

    Private Shared Function ProfileInfo() As HW_PROFILE_INFO
        Dim profile As HW_PROFILE_INFO
        Dim profilePtr As IntPtr = IntPtr.Zero
        Try
            profile = New HW_PROFILE_INFO()
            profilePtr = Marshal.AllocHGlobal(Marshal.SizeOf(profile))
            Marshal.StructureToPtr(profile, profilePtr, False)

            If Not GetCurrentHwProfile(profilePtr) Then
                Throw New Exception("Error cant get current hw profile!")
            Else
                Marshal.PtrToStructure(profilePtr, profile)
                Return profile
            End If
        Catch e As Exception
            Throw New Exception(e.ToString())
        Finally
            If profilePtr <> IntPtr.Zero Then
                Marshal.FreeHGlobal(profilePtr)
            End If
        End Try
    End Function

    Private Shared Function GetVolumeSerial(strDriveLetter As String) As String
        Dim serNum As UInteger = 0
        Dim maxCompLen As UInteger = 0
        Dim VolLabel As New StringBuilder(256)
        Dim VolFlags As New UInt32()
        Dim FSName As New StringBuilder(256)
        strDriveLetter += ":\"
        Dim Ret As Long = GetVolumeInformationA(strDriveLetter, VolLabel, CType(VolLabel.Capacity, UInt32), serNum, maxCompLen, VolFlags, _
         FSName, CType(FSName.Capacity, UInt32))
        Return Convert.ToString(serNum)
    End Function

    Shared Function getHWID() As String
        Dim info As HW_PROFILE_INFO = ProfileInfo()
        Dim GUID As String = info.szHwProfileGuid.ToString()
        Dim volumeserial As String = GetVolumeSerial(Environment.SystemDirectory.Substring(0, 1))

        Dim md5Hasher As MD5 = MD5.Create()
        Dim data As Byte() = md5Hasher.ComputeHash(Encoding.Default.GetBytes(GUID & volumeserial))
        Dim sBuilder As New StringBuilder()

        For i = 0 To data.Length - 1
            sBuilder.Append(data(i).ToString("x2"))
        Next i

        getHWID = sBuilder.ToString()
    End Function
End Class
05/30/2012 10:47 qickly#2
Besonders wenn du anfängst solltest du wissen, da jeder Nuub das umgehen kann. Indem er dein Programm patched...
05/30/2012 14:31 Whoknowsit#3
Und das sagt mir jetzt was? Ob und wie man da irgendetwas umgehen kann, war nicht gefragt ;) Danke trotzdem.
05/31/2012 14:06 Skriptum#4
Quote:
Originally Posted by Whoknowsit View Post
Und das sagt mir jetzt was? Ob und wie man da irgendetwas umgehen kann, war nicht gefragt ;) Danke trotzdem.
Ehm..., dafür ist die HWID in diesem Fall doch aber da, dass Programm sollen nur ausgewählte Personen benutzen können.

Wenn dieser Schutz leicht zu umgehen ist, bringt einem der ganze Mist doch nichts oder, was meinst du dazu?
05/31/2012 18:52 Huibuh2010#5
Er wollte sicherlich nur damit sagen wenn es nicht gerade sicher programmiert ist, kann es schnell so gecrackt werden das z.b. die ID egal ist.
05/31/2012 20:39 Whoknowsit#6
Es geht einzig darum: [Only registered and activated users can see links. Click Here To Register...]

Da ich VB.net gerde erst begonnen habe, habe ich diesen Thread hier erstellt um heraus zu finden, ob man am obigen Code etwas verändern/optimieren muss/kann. Sinn und Unsinn war hier nicht gefragt. Denn dass das kein ultimativer Schutz ist, ist mir bewusst ;)
09/20/2012 18:19 1badbobby#7
for some reason when people use this with my updater are telling me that they get a different HWID then you zyorsddl, care to help try and get them to match
09/24/2012 14:30 Whoknowsit#8
Just use the DLL instead of a custom function
09/30/2012 06:52 1badbobby#9
Quote:
Originally Posted by Whoknowsit View Post
Just use the DLL instead of a custom function
I Would but Vb2012 is saying the .dll "could not be added. Please make sure that the file is accessible,and that it is a valid assembly or COM component."

Got any help with this?
09/30/2012 09:28 Whoknowsit#10
I'll send you a pm.