Skip to content

Instantly share code, notes, and snippets.

Created April 3, 2022 18:22
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Solution for challenge Cape Kennedy at the Space Heroes 2022 CTF
import random
from string import ascii_letters
pwds = []
def solve():
while True:
s = ["A"]*8
s[0] = random.choice(ascii_letters)
s[1] = random.choice(ascii_letters)
s[2] = random.choice(ascii_letters)
s[5] = s[2]
s[3] = random.choice(ascii_letters)
s[4] = s[3]
s[6] = random.choice(ascii_letters)
s[7] = s[6]
builder = 0
password = "".join(s)
for c in password:
builder += ord(c)
if (builder == 713 and len(password) == 8 and (ord(password[2]) == ord(password[5]))):
if (ord(password[3]) == ord(password[4])) and ((ord(password[6])) == ord(password[7])):
if password not in pwds:
with open("moon2.txt", "a") as f:
f.write(password + "\n")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment