simple VB password box
Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: simple VB password box

  1. #1
    Banned
    Join Date
    Jul 2002
    Posts
    877

    simple VB password box

    I seen alotta guys post things about VB programs lately but instead im posting how to 'LIGHTLY' protect these programs from kids who like playing on your PC and opening applications then playing with them and other snoopy peaple. PS feel free to post ways to improve this or let me know about any errors so that I may improve my lack of attention.

    Ok I bought VB5 for dummy. Hey it was a compulsive buy! Anyways in the book they teach you how to make simple text password boxes but what they don't teach is how to actually attach this to a program. You have to go checkout the free source inside the that is packaged in the back of the book but I think my way is shorter than their's.

    Ok to make it your going to need a Textbox called PSWbox and a button called OK then go to the properties of PSWbox and click PasswordChar and hit a button like ? or * so that when you type the password in no1 can read it unless they have some type of keylogger. Oh and your going to need another form for the Password promt to load up.

    Source code is:

    Private Sub PSWbox_change()
    End sub

    Private sub OK_click()
    If PSWbox.text = "your password goes here" then
    load.form2
    Else MsgBox "tell user that the password is wrong"
    End Sub

    P.S. my printer is messed up so I had to do this by memory so let me know about any errors here.

  2. #2
    It's a gas!
    Join Date
    Jul 2002
    Posts
    699
    You forgot the End If statement:

    Private sub OK_click()
    If PSWbox.text = "your password goes here" then
    load.form2
    Else MsgBox "tell user that the password is wrong"
    End If
    End Sub

    Also theres no need for:

    Private Sub PSWbox_change()
    End sub


    r3b00+

  3. #3
    Banned
    Join Date
    Nov 2001
    Posts
    43
    Ive never used load.form so im not sure it works. you can use "load form2" (load is a function not an object) to load it into memory and form2.show to actually show the form.

  4. #4
    Banned
    Join Date
    Jul 2001
    Posts
    264
    There are several problems with this post. I will breifly explain here.

    Private sub OK_click()
    If PSWbox.text = "your password goes here" then
    load.form2
    Else MsgBox "tell user that the password is wrong"
    End If
    End Sub



    Problem # 1 - Storing a plain text password.

    msgbox.text="static password here" <---If you place a password here, it is plain text. Anyone with a VB decompiler has just h@X0r3d your application.

    Problem # 2 - Static Password assignment.

    msgbox.test="static password here" <----Using this example each time you need or want to change your password you would need to located the source code (which contains a world readable copy of the existing password) then edit the password and recompile.

    Problem # 3 - Plain text password input.

    If your going to use a text box to enter a password, you need to shadow that password with a specified character. What I mean is when you enter a password in the above example it will show exactly what you enter as you enter it. If you've ever entered a password before you know that commonly passwords are hidden using the * character. To do this in a VB text box you must set the 'passwordchar' property of the textbox.

    you can do this 2 ways.

    Example 1 - code: textbox.passwordchar="*"

    Example 2 - design time: Set the design time property 'passwordchar' to the character * or any other character which you would like to use to mask the password being entered.

    -Quad

  5. #5
    Banned
    Join Date
    Jul 2001
    Posts
    264
    Who ever the little puke who negged me here.....care to explain how I am wrong? ****ing twit.

  6. #6
    Ninja Code Monkey
    Join Date
    Nov 2001
    Location
    Washington State
    Posts
    1,027
    Quad is indeed correct. At the very least you may want to look into the windows crypto api's as they can be called from vb. You could use these to at least add some encryption to the passwords.

    Simply leaving them as string constants in the app is a bad idea. Requiring a recompile to change the password sucks.

    Finally it is better coding practice to compare what is in the text box against the constant in a constant first manner....

    If PASSWORDCONSTANT = textbox.text Then

    This way if you screw up your code an error will always be thrown (instead of the code thinking you are making that an assignment statement).

    Use the password char as Quad said....that way when people are looking over your shoulder they have to see what keys you type and not just read the pass off the screen.
    "When I get a little money I buy books; and if any is left I buy food and clothes." - Erasmus
    "There is no programming language, no matter how structured, that will prevent programmers from writing bad programs." - L. Flon
    "Mischief my ass, you are an unethical moron." - chsh
    Blog of X

  7. #7
    Senior Member
    Join Date
    Sep 2001
    Posts
    1,027
    You probably don't even need a decompiler to see the password... Just open the exe in a text editor like notepad (or hexeditor of your choice, or even easier, with a program such as strings in unix), and you'll probably be able to see the password...

    Also, keep in mind that when using a textbox with a passwordchar value set, it might keep the value hidden from your eyes, but using such a prog as Snadboy's revelation (if I remember the name right), will show you what's hiding behind the "*" by hooking up trough the win32 api...

    So unless necessary, don't leave already set/entered passwords in textboxes for nothing...

    Ammo
    Credit travels up, blame travels down -- The Boss

  8. #8
    Banned
    Join Date
    Jul 2002
    Posts
    877
    Well like I said when I first posted this "I didn't put much thought into it" anyways... I like playing with VB at night when im half asleep & really bored but the thing about VB is there isn't much thinking involved and as you can see I didn't do much thinking, lol.

  9. #9
    Junior Member
    Join Date
    Aug 2002
    Posts
    14
    Ok who does not know how to make a password window in Vb.
    But does any one know how to make to thay are forced to put a password in.
    You wont be able to close it no matter what you try.

    I am trying to figure out how to make so when windows boots it is the first thing you see before windows starts. Can any one tell me that.

    you can have vb make the login box for you and all you have to do is edit it.

  10. #10
    Originally posted here by kingpinzs
    Ok who does not know how to make a password window in Vb.
    But does any one know how to make to thay are forced to put a password in.
    You wont be able to close it no matter what you try.

    I am trying to figure out how to make so when windows boots it is the first thing you see before windows starts. Can any one tell me that.

    you can have vb make the login box for you and all you have to do is edit it.
    Easy, make the box System Modal

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •