Digestive
Help
This page offers a convenient way for you to interact with the "Digestive" challenge functions. You can also use GET requests to send and receive data directly from the listed routes/endpoints if you wish. For more information see the FAQ.
Your aim is to recover the FLAG
value. Once you have have it, submit it on the ECC challenge page.

Source
import hashlib
import json
import string
from ecdsa import SigningKey
SK = SigningKey.generate() # uses NIST192p
VK = SK.verifying_key
class HashFunc:
def __init__(self, data):
self.data = data
def digest(self):
# return hashlib.sha256(data).digest()
return self.data
@chal.route('/digestive/sign/<username>/')
def sign(username):
sanitized_username = "".join(a for a in username if a in string.ascii_lowercase)
msg = json.dumps({"admin": False, "username": sanitized_username})
signature = SK.sign(
msg.encode(),
hashfunc=HashFunc,
)
# remember to remove the backslashes from the double-encoded JSON
return {"msg": msg, "signature": signature.hex()}
@chal.route('/digestive/verify/<msg>/<signature>/')
def verify(msg, signature):
try:
VK.verify(
bytes.fromhex(signature),
msg.encode(),
hashfunc=HashFunc,
)
except:
return {"error": "Signature verification failed"}
verified_input = json.loads(msg)
if "admin" in verified_input and verified_input["admin"] == True:
return {"flag": FLAG}
else:
return {"error": f"{verified_input['username']} is not an admin"}