added few ctfs

This commit is contained in:
2025-05-27 03:40:34 +02:00
parent 9fe7119118
commit e36053882b
62 changed files with 3981391 additions and 18 deletions

View File

@@ -1,3 +1,5 @@
#!/usr/bin/env python3
from hashlib import sha1
from base64 import b64encode, b64decode
from secrets import token_hex
@@ -7,8 +9,6 @@ from secret import FLAG
KEY = token_hex(16)
print(KEY)
def get_mac(data: bytes) -> str:
return sha1(KEY.encode("latin1") + data).hexdigest()
@@ -21,8 +21,7 @@ def parse_token(token: str) -> dict:
# Check the MAC
token, mac = token.split(b"|mac=")
print(token, mac)
print(f"Calculated mac = {get_mac(token)}")
print(mac)
if get_mac(token) != mac.decode("latin1"):
return None