Crypto Present

서버는 암호화한 토큰과 함께 관리자 권한을 검증하는 API를 제공합니다. 관리자 권한을 획득하여 플래그를 얻어보세요!

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

Get Encrypted Token

GET /encrypt

Check Token

GET /check/<ciphertext>

XOR Tool

Text to Hex

Hex to Text