You are viewing our Forum Archives. To view or take place in current topics click here.

Was The Tutorial Helpful

Yes
0.00% (0 votes)
No
100.00% (1 vote)

Total Votes: 1

[VB.NET]HWID license file Authorization system[TUT]
Posted:

[VB.NET]HWID license file Authorization system[TUT]Posted:

architecture
  • Challenger
Status: Offline
Joined: Dec 25, 201112Year Member
Posts: 182
Reputation Power: 6
Status: Offline
Joined: Dec 25, 201112Year Member
Posts: 182
Reputation Power: 6
This tutorial will teach you how to use a combination of HWID to protect your application from leaker

First, you create new class , and add these HWID functions to it in order to call it later,then you add a reference to System.Management


Imports System.Management

Public Class ComputerInfo

    Public Shared 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

    Public Shared 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

    Public Shared 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

End Class

The class will look like this.
[ Register or Signin to view external links. ]

PUT THE FOLLOWING IN Form1_Load

Then we declare 3 variables to store the HWID by

Dim MyMacAddress As String = ComputerInfo.GetMACAddress()
Dim MyProcessAddress As String = ComputerInfo.GetProcessorId()
Dim MyVolumeAddress As String = ComputerInfo.GetVolumeSerial()


So MacAddress,ProcessorID,HDVolume will be stored.

Then we declare another variable to store the formatted HWID.
Dim ARCH_MID As String = "ARCH-" & MyMacAddress.Substring(MyMacAddress.Length() - 4, 4) _
    & "-" & MyProcessAddress.Substring(MyProcessAddress.Length() - 4, 4) & "-" & MyVolumeAddress.Substring(MyVolumeAddress.Length() - 4, 4)


The above code will declare ARCH_MID to be a string with ARCH as salt followed by last 4 string of MACAddress , ProcessID , Volume.

The format will look like this
ARCH-XXXX-XXXX-XXXX

*Note that you can change how to order those three above or change salt ARCH into another name.

After that, we add RC4 encryption algorithm below the sub Form1_Load
add these on top as imports
Imports System.IO
Imports System.Text


Public Shared Function rc4(ByVal message As String, ByVal password As String) As String
  Dim i As Integer = 0
  Dim j As Integer = 0
  Dim cipher As New 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
  Dim 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
  Dim 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

Then we add
If (File.Exists(Application.StartupPath & "\ARCH.lic")) Then

To check that the file "ARCH.lic" exists or not, and add this to make a stream reader to read for our license key
Dim stream_reader As New StreamReader(Application.StartupPath & "\ARCH.LIC")

then we decrypted the license file to compare with our HWID with ARCH as password
Dim myMIDReader = rc4(stream_reader.ReadToEnd, "ARCH")
stream_reader.close()

After that we put
If (myMIDReader = ARCH_MID) Then

    Else
    MsgBox("The license key is incorrect, please contact email @ email.com for more information", MsgBoxStyle.Critical)
    End
    End If

  Else
    MsgBox("Your machine ID is : " & ARCH_MID & vbCrLf & "Your machine ID is copied to clipboard, press ctrl+v to paste it!", MsgBoxStyle.Critical)
    Clipboard.SetText(ARCH_MID)
    End
  End If

to check that the decrypted lic file is same as ARCH_MID or not. If yes, the program run normal.
And if it's not the same , it show the msgbox that the license key is incorrect and end the application.
The next else show the machine ID and copy it to clipboard in case the license key is not found.

This is the final code in Form1_Load()
[ Register or Signin to view external links. ]

Now for the keygen to generate your license file

[ Register or Signin to view external links. ]
Create a new project and add 1 textbox and 1 button as above.

then add
Imports System.IO
Imports System.Text

on the top as imports

and add this RC4 encryption to the application

Public Shared Function rc4(ByVal message As String, ByVal password As String) As String
  Dim i As Integer = 0
  Dim j As Integer = 0
  Dim cipher As New 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
  Dim 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
  Dim 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


then double click at the button and add this code

Dim write_file As New StreamWriter(Application.StartupPath & "\ARCH.lic", False)
        write_file.Write(rc4(TextBox1.Text, "ARCH"))
        write_file.Close()


*Note that the password "ARCH" must the same as your application and keep it private or else anyone can gen your license file . You can freely change the order or salt . Don't forget to obfuscate your application to prevent viewing through reflector and keep your keygen private.
Credit:
Heartz Of Men from HackForms
I take no credit but for the pictures


Last edited by architecture ; edited 1 time in total
#2. Posted:
SyntaxError_81
  • Ladder Climber
Status: Offline
Joined: Oct 20, 201112Year Member
Posts: 322
Reputation Power: 13
Status: Offline
Joined: Oct 20, 201112Year Member
Posts: 322
Reputation Power: 13
Pretty impressive for a first post, C & P?
#3. Posted:
architecture
  • Challenger
Status: Offline
Joined: Dec 25, 201112Year Member
Posts: 182
Reputation Power: 6
Status: Offline
Joined: Dec 25, 201112Year Member
Posts: 182
Reputation Power: 6
SyntaxError_81 wrote Pretty impressive for a firts post, C & P?


adding credit to who made it


Last edited by architecture ; edited 1 time in total
#4. Posted:
Z61
  • TTG Fanatic
Status: Offline
Joined: Apr 16, 201014Year Member
Posts: 4,309
Reputation Power: 179
Status: Offline
Joined: Apr 16, 201014Year Member
Posts: 4,309
Reputation Power: 179
architecture wrote
SyntaxError_81 wrote Pretty impressive for a firts post, C & P?


No i have just not really been on ttg i learned things through other sites and books

you took this from hackforums.
#5. Posted:
Extazc
  • TTG Senior
Status: Offline
Joined: Aug 17, 201112Year Member
Posts: 1,444
Reputation Power: 75
Status: Offline
Joined: Aug 17, 201112Year Member
Posts: 1,444
Reputation Power: 75
In one of your screenshots it says architecture from TTG i suggest you add credits in the images
Jump to:
You are viewing our Forum Archives. To view or take place in current topics click here.