Overview
The challenge provides a small collection of files from a record/catalogue system:
| File | Role |
|---|---|
desk.log |
Timeline: test pressing queued (16:41), catalogue revised (16:42), counter closed (16:43) |
library.db |
Current SQLite database (revised/truncated receipt) |
library.db-wal |
SQLite Write-Ahead Log (may hold previous page versions) |
library.db-shm |
SQLite shared-memory / WAL index |
The objective is to recover information removed or truncated during the catalogue revision. The key technique is SQLite WAL forensics: WAL mode can retain previous versions of database pages after an update, so a value truncated in the current database may still exist in the WAL.
Prerequisites / Setup
unzip,file,strings,sqlite3(optional),python3(base64,zlib)- Work on copies of the database files, never the originals, to avoid checkpointing the WAL.
Recon
Step 1 — Extract the challenge archive
Goal: Unpack listening-room.zip and inventory the files.
unzip listening-room.zip
ls
desk.log
library.db
library.db-shm
library.db-wal
listening-room.zip
Step 2 — Read the desk log
Goal: Establish the timeline and what changed.
cat desk.log
16:41 test pressing queued
16:42 catalogue revised
16:43 counter closed
Interpretation: Something in the database was modified after the original record was created (16:42), making the WAL files particularly interesting.
Step 3 — Identify the file types
Goal: Confirm the SQLite database and its WAL files.
file library.db
file library.db-wal
file library.db-shm
library.db: SQLite 3.x databaselibrary.db-wal: SQLite Write-Ahead Log, version 3007000library.db-shm: SQLite WAL shared-memory
Interpretation: The database is in WAL mode. The interesting forensic artifact is library.db-wal; library.db-shm only coordinates readers/writers and holds no application records.
Exploitation
Step 4 — Confirm the current database is insufficient
Goal: Verify that querying library.db directly does not yield the complete receipt.
sqlite3 library.db '.tables'
sqlite3 library.db '.schema'
The live database contains the current (revised) version of the catalogue, but not the complete original receipt. Because the catalogue was revised at 16:42, the historical version must be recovered from the WAL.
Step 5 — Search the WAL for the receipt
Goal: Find printable application data in library.db-wal, especially the receipt.
strings -a library.db-wal
A targeted search for the receipt’s characteristic prefix:
strings -a library.db-wal | grep eJ
The eJ prefix is characteristic of a Base64-encoded zlib stream. The value recovered:
eJwrTkxLLkmrNjRKSko2NUzRNTcxNdA1MUk2001MM07TNTQ3MjY1NEmySExMqQUALKEM0A==
This appeared in the first WAL frame (around offset 0xfe0) and was longer than the corresponding receipt visible in the revised database.
Step 6 — Decode the receipt
Goal: Base64-decode, then zlib-decompress, to recover the original receipt.
python3 -c "import base64,zlib;print(zlib.decompress(base64.b64decode('eJwrTkxLLkmrNjRKSko2NUzRNTcxNdA1MUk2001MM07TNTQ3MjY1NEmySExMqQUALKEM0A==')))"
safctf{REDACTED}
Interpretation: The eJ prefix confirmed Base64-encoded zlib data (78 9c zlib header after Base64 decode). The decoding chain is:
Base64 decode
↓
zlib decompress
↓
plaintext (the flag)
WAL Timeline
| Time | Event | Database state |
|---|---|---|
| 16:41 | Test pressing queued | Original record with complete receipt written to WAL |
| 16:42 | Catalogue revised | Receipt truncated; revised page written to WAL |
| 16:43 | Counter closed | Activity finished; WAL still retains the earlier page |
The original row contained the complete Base64/zlib receipt; the revised record contained only a truncated value (safctf{12bbc51d-7450-44c6-af3f…). The current database no longer exposes the full flag, but SQLite previously wrote the original page into the WAL, where it remained recoverable.
Flag
safctf{REDACTED}
Recovered from library.db-wal via Base64 decode + zlib decompress.
Lessons / Takeaways
- Don’t inspect only
database.db— treatdatabase.db,database.db-wal, anddatabase.db-shmas a single evidence set. - WAL files can contain historical data: updates may leave previous page contents recoverable.
- Search binary database artifacts with
strings; even a binary WAL yields useful application data. - Recognize encoding signatures:
eJstrongly suggests Base64-encoded zlib. - Preserve evidence: copy the
.db/.db-wal/.db-shmset before running anything that could checkpoint the WAL (e.g.PRAGMA wal_checkpoint(TRUNCATE)).
Techniques
References
- SQLite, “Write-Ahead Logging”: https://www.sqlite.org/wal.html

