ROUTER SOURCE
from Crypto.Cipher import AES
from Crypto.Util.Padding import pad, unpad
KEY = b'????????????????'
FLAG = b'????????????????'
BASE_PLAINTEXT = b"uid=guest;admin=0;comment=have_fun!"
@app.route('/encrypt')
def encrypt():
iv = os.urandom(BLOCK_SIZE)
cipher = AES.new(KEY, AES.MODE_CBC, iv)
padded = pad(BASE_PLAINTEXT, BLOCK_SIZE)
encrypted = cipher.encrypt(padded)
return (iv + encrypted).hex()
@app.route('/check/<ciphertext>')
def check(ciphertext):
try:
ctext = bytes.fromhex(ciphertext)
iv = ctext[:BLOCK_SIZE]
enc = ctext[BLOCK_SIZE:]
cipher = AES.new(KEY, AES.MODE_CBC, iv)
decrypted = cipher.decrypt(enc)
plaintext = unpad(decrypted, BLOCK_SIZE)
if b"admin=1" in plaintext:
return {"status": "success", "message": FLAG}
else:
return {"status": "error", "message": "You are not admin"}
except Exception:
return {"status": "error", "message": "Invalid ciphertext"}INTERACTIVE