top of page
Visual Basic 2013 Adobe-88.jpg

Example 11.32 : Password Cracker

This is a password cracking program where it can generate possible passwords and compare each of them with the actual password; and if the generated password found to be equal to the actual password, login will be successful. In this program, a timer is inserted into the form and it is used to do a repetitive job of generating the passwords.

We create passwords generating procedure generate () and it is called by the  Timer1_Tick() event so that the procedure is repeated after every interval. The interval of the timer can be set in its properties window where a value of 1 is 1 millisecond, so a value of 1000 is 1 second; the smaller the value, the shorter the interval. However, do not set the timer to zero because if you do that, the timer will not start.

 

We shall set the Timer's interval at 100 which is equivalent to 0.1 seconds. The Timer1.Enabled property is set to false so that the program will only start generating the passwords after you click on the Generate button. Rnd is a VB function that generates a random number between 0 and 1. Multiplying Rnd by 100 will obtain a number between 0 and 100. Int is a Visual Basic 2013 function that returns an integer by ignoring the decimal part of that number.

In addition, Rnd is a VB function that generates a random number between 0 and 1. Multiplying Rnd by 100 will obtain a number between 0 and 100. Int is a Visual Basic 2013 function that returns an integer by ignoring the decimal part of that number.

Therefore, Int(Rnd*100) will produce a number between 0 and 99, and the value of Int(Rnd*100)+100 will produce a number between 100 and 199.Finally, the program uses If…Then…Else to check whether the generated password is equal the actual password or not; and if they are equal, the passwords generating process will be terminated by setting the Timer1.Enabled property to false.

The Code :

Visual Basic - An Event Driven Programming Language

Building the GUI-Based Programming Language

by Inserting Controls from the Tool Box.

1. Right Click on Graphics Image : Then Press Save Image as to Folder

      - The Graphics Chart above corresponds to the Tool Box Controls

      - Making Graphic User Interface [GUI] Easier to Build.

2. Copy Coding onto Forms VB for Program Execution.

3. In VB Design Mode : Drag Picture Box from Tool Box.

4. Drag Timer from Tool Box -  In Properties set Timer to (100) = 0.1 Second

5. Set Picture Box Size Mode to Stretch Image.

6. Download Graphic Image below from allocated Folder.

In Private Sub Button_3 if only 1 Form is being used.

Terminate Form57.Show()

               Me.Hide()

Then add  Me.Close()   ' To Close Program.

Follow and Insert the LabelBox and Button Controls from ToolBox

and allocate them on the Graphics Chart.

The Program Tests the Random Values (crackpass) against (password Value)

Initiated the the Sub Procedure Generate().

The Program Counts the number of Cycling unil (crackpass = password)

      

Public Class Form59

    Dim password As Integer
    Dim
crackpass As Integer
    Dim
Count As Integer

    Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
       

        Form57.Show()
        Me.Hide()


    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

        Timer1.Enabled = True

    End Sub

    Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick

        'Generate() - Initiates Goto Sub Gernerate() Command
        generate()

        'Count Number of Cycles until Pasword Achieved.
        Count = (Count + 1)

        Label3.Text = Count  'Label3 = Count

        'Test Value of crackpass against password
        If crackpass = password Then

            Timer1.Enabled = False  'Timer = False - Turn Off
            Label1.Text = crackpass 'Assign Crackpass to Label1
            Label2.Text = "Password Cracked!Login Successful!"

            'Else continue Cycling 
        Else : Label1.Text =
crackpass
            Label2.Text = "Please wait..."

        End If

    End Sub

    'Sub Procedure generate

    Sub generate()

        'Random Values assigned to crackpass
        crackpass = Int(Rnd() * 100) + 100

    End Sub

    Private Sub Form59_Load(sender As Object, e As EventArgs) Handles MyBase.Load

        'Assign password Numerical Value
        password = 123

    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click

        'Clear Labels & Reset Count = 0
        Label1.Text = ""
        Label2.Text = ""
        Label3.Text = ""
        Count = 0

    End Sub


End Class

bottom of page