CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: Loops

  1. #1
    Join Date
    Jan 2002
    Posts
    21

    Loops

    Hi there,
    I am quite new to VB and I am trying to write a loop in my program that allows you to have five attempts in getting the password correct, after which it will exit you.
    Can someone please show me how this can be done using:
    1) Do-While loop.
    2) For loop.
    3) Any other method
    Any help will be appreciated.
    Thank you in advance.
    I have included below the code that I have been trying to use, but it does not work.

    Private Sub CmdValid_Click()
    'This procedure checks the input password
    Dim Response As Integer
    Do
    If txtPassword.Text = txtPassword.Tag Then
    'If correct, display message box
    MsgBox "You've passed security!", vbOKOnly + vbExclamation, "Access Granted"

    Else
    'If incorrect, give option to try again
    Response = MsgBox("Incorrect password", vbRetryCancel + vbCritical, "Access Denied")
    End If
    If Response = vbRetry Then

    txtPassword.SelStart = 0
    txtPassword.SelLength = Len(txtPassword.Text)

    Response = Response + 1
    lblCounter.Caption = Response
    Print Response
    Else
    End
    End If
    txtPassword.SetFocus

    Loop While Response < 5
    End Sub









  2. #2
    Join Date
    Jun 2001
    Location
    Ireland
    Posts
    56

    Re: Loops


    'Dim numTries as long

    private Sub Form_Load()
    numTries = 1
    End Sub

    private Sub CmdValid_Click()
    If numTries = 5 then
    MsgBox "You have Exceeded to amount of attempts allocated", vbOKOnly, App.Title
    Exit Sub
    End If
    'This procedure checks the input password
    Dim Response as Integer

    If txtPassword.Text = txtPassword.Tag then
    'If correct, display message box
    MsgBox "You've passed security!", vbOKOnly + vbExclamation, "Access Granted"

    else
    'If incorrect, give option to try again
    Response = MsgBox("Incorrect password", vbRetryCancel + vbCritical, "Access Denied")
    End If
    If Response = vbRetry then
    numTries = numTries + 1
    txtPassword.SelStart = 0
    txtPassword.SelLength = len(txtPassword.Text)

    Response = Response + 1
    lblCounter.Caption = Response
    print Response
    else
    End
    End If
    txtPassword.SetFocus

    End Sub




    Andy

    Don't forget to rate!!!!

    Andrew Lennon (Berlitz)
    Automation Dev Engineer

  3. #3
    Join Date
    Jan 2002
    Location
    somewhere between a variable and a string
    Posts
    214

    Re: Loops

    To be quite honest , only 1 attempt is needed.If a user purchased a product then they will type in the correct password the first time.By allowing any type of limit....3 try's ,4,5,etc..... you are really just putting a hole into your security.I would have the application unload on the first failure .Without using any message boxes.If you use a message box then it will show it in the assembly code and pinpoint a cracker closer to the required offset that will allow them to change your preset limit of password attempt's and then they will be able to run their password generator's on your program.This is just my opinion.P.S. the program"VBde085" will tell any and all message boxes used as well as what the message box say's in an .Exe and will show the coresponding offset's , as well as other information .To fool a cracker , just place a bunch of B.S. "If" statement's.These statement's are quickly found in assembly code by looking for "0F85" (which mean's Jump if condition is met), the cracker look's for this piece of code and changes it to "0F84" (which mean's "Jump if condition is not met).This is a minor technique used to at least make the cracker would be.... spend the next year tracing through all the "If" statement's,by then your product would either be outdated , or already up-graded.

    Regard's,
    Danny
    http://www.geocities.com/wildthing40486/Xara.html
    How can anyone sell information when all the information that they sell is free at the library ?

    How come Doctors keep getting smarter yet they cannot cure the common cold ?

    If Scientist are right and man evolved from monkey then where did the monkeys' come from ?

    Man I love this little dude that waves => <= He just doesn't stop

  4. #4
    Join Date
    Jun 2001
    Location
    MO, USA
    Posts
    2,868

    Re: Loops

    That's strange because I compiled this

    option Explicit

    private Sub Main()
    Dim iVar as Integer
    iVar = CInt(Command)
    If 1 = iVar then
    MsgBox "1 = " & iVar
    End If
    If 2 = iVar then
    MsgBox "2 = " & iVar
    End If
    If 3 = iVar then
    MsgBox "3 = " & iVar
    End If
    If 4 = iVar then
    MsgBox "4 = " & iVar
    End If
    If 5 = iVar then
    MsgBox "5 = " & iVar
    End If
    If 6 = iVar then
    MsgBox "6 = " & iVar
    End If
    End Sub




    and the EXE doesn't have a single 0F85 OR 0F84 in it...???



  5. #5
    Join Date
    Jan 2002
    Location
    somewhere between a variable and a string
    Posts
    214

    Re: Loops

    did you do a search ? . the 0F85 is only one jump statement though. there are several of them actually.On the line of assembly that has this statement (JNB,JNE,,etc...) , look to the left , you see that long line of numbers? anyway's, the jump statement's are there.Conditional jump if codition is met.I use w32dsm89 , personally , along with Hackman 6.01., HexWorkshop ,and vbde085.This is just my personal opinion.I would rather a cracker search through all the conditional jump if's and make them really work for my program.When you use the "vbde085"It will give you the address,code offset of any message boxes used , this is what one would use to narrow their search to the correct Jump statement.
    Here are just a couple of Jump statements that are in assembly, theres lot's more . The 0F85 was just one of them
    JA
    JAE
    JB
    JBE
    JC

    Regard's,
    Danny
    http://www.geocities.com/wildthing40486/Xara.html
    How can anyone sell information when all the information that they sell is free at the library ?

    How come Doctors keep getting smarter yet they cannot cure the common cold ?

    If Scientist are right and man evolved from monkey then where did the monkeys' come from ?

    Man I love this little dude that waves => <= He just doesn't stop

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured