Hard
Reversing
250 pts
A "secure" vault program verifies the flag using a repeating XOR key plus a position shift. Reverse the maths to recover the flag.
import sys
DATA = [0, 1, 37, 42, 120, 57, 63, 124, 62, 59, 37, 43, 113, 67, 21, 77, 135, 50, 56, 46, 50, 22, 41, 60]
KEY = b"UDX"
def verify(flag):
if len(flag) != len(DATA):
return False
for i, ch in enumerate(flag):
x = ord(ch) ^ KEY[i % len(KEY)]
if (x + i) % 256 != DATA[i]:
return False
return True
print("Access granted" if verify(sys.argv[1]) else "Access denied")
Need a hint?
Undo the steps in reverse order: first subtract i (mod 256), then XOR with KEY[i % 3].