added few ctfs
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user