Support Forums

Full Version: [Tutorial] Login system w/ HWID[/Tutorial]
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Per Thoth's request, I am making a tutorial on how to incorporate your HWID into a login system.
*Note, this system only checks login information, it does not register new usernames and passwords

Things you will need:
  • A way to upload a text file and read it from the internet
  • VB.net

Controls used:
  • Textbox: txtLogin
  • Textbox: txtPass
  • Button: btnLogin



Here is a screenshot of the form im using. It is pretty basic but so is this tutorial.
Screenshot (Click to View)

The first thing we need to do is add the Imports into the program. The ones you will need during this tutorial are:

Imports System.IO
Imports System.Management
Imports System.Net

also, add this under Public Class Form1:

Dim HWID As String = ""

Next, we need to program the function that returns the HWID on the computer you are on.
Code:
Private Function getHWID()
        'not going to explain this, in short it grabs
        'the HWID from the system you are on
        Dim mc As New ManagementClass("win32_processor")
        Dim moc As ManagementObjectCollection = mc.GetInstances()
        For Each mo As ManagementObject In moc
            If HWID = "" Then
                HWID = mo.Properties("processorID").Value.ToString()
                Exit For
            End If
        Next
        Return HWID
End Function
*Note: If you have errors, you may need to add the System.Management class manually. To do so, on the top menu click Project->Add Reference then under the .NET tab go down and double-click System.Management.

Now that we have a function to get the HWID, check it by adding this code to Form1_Load:
Code:
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        'sets the form text to the current HWID
        Me.Text = "HWID: " & getHWID()
End Sub

When you run the program, the Form text should now have your HWID in it.

Before we code the login button, we are going to program the Function that checks the login information. The code for that is here:

Code:
Private Function checkLogin(ByVal sUser As String, ByVal sPass As String) As Boolean
        'this array reads HWID|user|pass from the txt file
        Dim login As String()
        'I used HttpWebRequest to loop through each line indvidually
        'I figured it would be easier that using WebClient
        'HttpWebRequest.Create("") opens our text file
        'Replace your the URL with the URL path to your txt
        Dim wr As HttpWebRequest = HttpWebRequest.Create("http://www.yoursitehere/HWID.txt")
        'HttpWebResponse downloads the txt as a stream
        Dim response As HttpWebResponse = wr.GetResponse()
        'StreamReader reads the stream
        Dim sr As StreamReader = New StreamReader(response.GetResponseStream())
        'this loop goes through each line of the stream and checks
        'the HWID and login information
        While Not sr.EndOfStream
            'inside the txt, each lines reads HWID|user|pass
            'this is split up into the array like so
            'login(0) = HWID, login(1) = user, login(2) = pass
            login = sr.ReadLine.Split("|")
            'checks the login information
            If login(0) = HWID Then
                If sUser = login(1) Then
                    If sPass = login(2) Then
                        'if all three are correct the function returns true
                        Return True
                    End If
                End If
            End If
        End While
        'if none worked, it returns false
        Return False
End Function

Now all that is left is code our button;
Code:
Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogin.Click
        'checkLogin() returns a boolean/this checks if login worked or failed
        'it passes the username and password to the function
        Select Case checkLogin(txtLogin.Text, txtPass.Text)
            Case True
                MessageBox.Show("Login Successful")
            Case False
                MessageBox.Show("Login Failed")
        End Select
End Sub


Now that your program is finished, you need to upload a txt file to the internet, and link to it by replacing the URL in the program, with your file. This is obviously not a very secure login system, however with minor adjustments(ie. online database/sql, encrypted HWID) this has the potential to be a pretty decent security measure.,

The format of you text must be: HWID|username|password


Ex.
Code:
176BFBFF00200F89|user|pass
176BFBFF00200F89|check|works
176BFBFF00200F89|user2|pass2
176BFBFF00200F89|user3|pass3
176BFBFF00200F89|user4|pass4

The source code for the most part is Fully Commented
You can either:
Download Full Source

or

View Full Source (Click to View)
Decent tutorial KoBE, it's pretty basic and easily cracked, but nonetheless a good tutorial to start beginners with.
(12-05-2010, 04:21 AM)versx Wrote: [ -> ]Decent tutorial KoBE, it's pretty basic and easily cracked, but nonetheless a good tutorial to start beginners with.


I agree, very easy to crack.. but this does give people a starting point in creating one on their own.
Hey thanks, going to build off of this ^.^
Thanks for the share, I appreciate it.
Nice tutorial, great share. This could help a few members.
Very good for beginners good job Smile
Great guide Thanks Smile
This has been posted multiple time but thanks for sharing it..
thanks for the share ill give this ago
Pages: 1 2