Support Forums

Full Version: [TuToRiAl] How to make Offline (No Internet) Captcha (Human Confirmation) [TuToRiAl]
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
A CAPTCHA or Captcha (pronounced /ˈkæptʃə/) is a type of challenge-response test used in computing to ensure that the response is not generated by a computer. The process usually involves one computer (a server) -- WOW, WOW, WOW. A SERVER??? |||||| asking a user to complete a simple test which the computer is able to generate and grade.

Welcome to my tutorial on how to generate Captcha without using pictures, internet connection or anything external that the application has to access; as long as you get a human response? Correct? I believe so. Today I will show you a nice feature that almost every computer can do in the world, generate a random number!... -.-'



We will be using that method in our captcha, and the best part about offline captcha in a VB form my way, is that there is NO need to refresh it for the following reasons:
  • Unreadable Letters
  • Long and Pointless Words
  • Never loaded correctly
  • Half the Captcha loaded


_____________________________________________


Lets proceed. First open a form up, and have the following created:

  • 3 Buttons
  • 3 Reasonable Icons for Refresh, Close, and Confirm/Submit User Input, if you want to be fancy.
  • 3 TextBoxes
  • Ability to follow my Tutorial Victoire

1. Now Open up VB6, VB8, VB9, VB10 or whatever... Roflmao

2. Select new project, WindowsApplication...

3. Name it whatever you want, etc...

4. Add the following above. And now for the pre-step.

5. Each Button should be named, Generate New Captcha Offline, Submit New Captcha Offline, and Exit Captcha Offline.

6. One of Each textbox should have the following values: >Enter Captcha Number Here<, 999999999, and Nothing as in Blank. Make the Blank one big and obvious so they know what to enter as Captcha.

---

Now for the Code.

PublicClass + Form1_Load:
Code:
Public Class Form1
    Dim charactersDisallowed As String = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ,<>./?; :'{}[]=+-_)(*&^%$#@!~`|\uç▲ìα▲╜KÄ╤ZlÆ╘¦«¨©÷ ¢¡¬­®¯°±²³´µ¶·¸¹£¤¥»¼½¾¿"
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        KeyPreview = True
        Try
            Dim Random As New Random
            TextBox1.Text = Random.Next(TextBox2.Text)
        Catch ex As Exception
            MsgBox("Invalid Characters/No Numerical Value Detected", 16, "Fatal Error")
        End Try
        TextBox2.Visible = False 'This is what gives a digit limit for random captcha.
TextBox1.Enabled = False 'Disables TextBox so User cannot copy and paste the captcha.
        TextBox1.ReadOnly = True 'Disables so user cannot edit the captcha.
    End Sub

Generate New Captcha Button Code:

Code:
Dim Random As New Random
        TextBox1.Text = Random.Next(TextBox2.Text)

Submit Captcha Button Code:
Code:
If TextBox3.Text = TextBox1.Text Then
            MsgBox("Captcha entered successfuly!", 64, "Human Detected!")
            'Other Code should be put here if the user enters the captcha correctly, like Form2.Show()
        Else
            MsgBox("Your Kind is Not wanted Here, Robot!", 48, "Robot Detected!")
            'here add code that tells the user they have entered it incorrectly, I called them a robot for fun.
        End If

Exit Captcha Button Code:
Code:
End

Captcha Input TextBox (Where you put the captcha):
Code:
Dim theText As String = TextBox3.Text
        Dim Letter As String

        For x As Integer = 0 To TextBox3.Text.Length - 1
            Letter = TextBox3.Text.Substring(x, 1)
            If charactersDisallowed.Contains(Letter) Then
                theText = theText.Replace(Letter, String.Empty)
            End If
        Next
        TextBox3.Text = theText
        TextBox3.Select(TextBox3.Text.Length, 0)

Captcha Input TextBox (Auto Submit Captcha on Enter Key):
Code:
Private Sub TextBox3_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox2.KeyDown
        If e.KeyCode = Keys.Enter Then
            Button3_Click(Nothing, Nothing)
        End If
    End Sub

In the end, it should look somewhat like this:

[Image: dosxv8.png]

FINALIZED RESULTS!!!


[Image: 2dhbrqt.png]

[Image: e8jvp5.jpg]

Download the Application as an Example

Enjoy and don't forget to say thanks... Your all very welcome in advanced!

For:
ѕмии™, he gave me an idea by posting his tutorial!
A very nice share, thank you. I've never even thought about this type of program, very useful.
You were right this is Nice Smile
Can I use this and add a dew changes I will give Credits Smile
Can we have a download for the Source over it did not work for me?
Well this is a really nice thread and a really nice tutorial L3g1tWa5te, great share.
I will also be trying this. - Thanks!
@ ѕмии™ What the? You need the source, why don't you just follow the tutorial, it has the code there or your just trying to get 100 posts or spamming?
(11-07-2010, 03:03 AM)ѕмии™ Wrote: [ -> ]You were right this is Nice Smile
Can I use this and add a dew changes I will give Credits Smile
Can we have a download for the Source over it did not work for me?

Umm... that was the source right there... Here is the whole code for form 1, right below:
Code:
Public Class Form1
    Dim charactersDisallowed As String = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ,<>./?; :'{}[]=+-_)(*&^%$#@!~`|\uç▲ìα▲╜KÄ╤ZlÆ╘¦«¨©÷ ¢¡¬­®¯°±²³´µ¶·¸¹£¤¥»¼½¾¿"
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        KeyPreview = True
        Try
            Dim Random As New Random
            TextBox1.Text = Random.Next(TextBox2.Text)
        Catch ex As Exception
            MsgBox("Invalid Characters/No Numerical Value Detected", 16, "Fatal Error")
        End Try
        TextBox2.Visible = False 'This is what gives a digit limit for random captcha.
        TextBox1.Enabled = False 'Disables TextBox so User cannot copy and paste the captcha.
        TextBox1.ReadOnly = True 'Disables so user cannot edit the captcha.
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim Random As New Random
        TextBox1.Text = Random.Next(TextBox2.Text)
    End Sub

    Private Sub TextBox3_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox2.KeyDown
        If e.KeyCode = Keys.Enter Then
            Button3_Click(Nothing, Nothing)
        End If
    End Sub
    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        If TextBox3.Text = TextBox1.Text Then
            MsgBox("Captcha entered successfuly!", 64, "Human?")
            'Other Code should be put here if the user enters the captcha correctly, like Form2.Show()
        Else
            MsgBox("Your Kind is Not wanted Here, Robot!", 48, "Robot Detected!")
            'here add code that tells the user they have entered it incorrectly, I called them a robot for fun.
        End If
    End Sub

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

    Private Sub TextBox3_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox3.TextChanged
        Dim theText As String = TextBox3.Text
        Dim Letter As String

        For x As Integer = 0 To TextBox3.Text.Length - 1
            Letter = TextBox3.Text.Substring(x, 1)
            If charactersDisallowed.Contains(Letter) Then
                theText = theText.Replace(Letter, String.Empty)
            End If
        Next
        TextBox3.Text = theText
        TextBox3.Select(TextBox3.Text.Length, 0)
    End Sub
End Class
Nice tutorial mate. I didn't knew this,however i'll add this to my tut collection.
Thanks in advance.
watta easy tutorial! thanks mate.
Very nice tutorial, this should be useful. Thanks for sharing.
Looks pretty good, nice share.
Thanks for tutorial
Pages: 1 2 3