Anantya ByteMe CTF Writeup Series: Ghosts Of The Realm

 


Welcome Back to the Official Write-Up Series of ByteMe CTF!

The OWASP PCCOE Student Chapter is diving into the shadows of digital storage. For our 7th write-up, we explore GHOSTS OF THE REALM, a challenge that focuses on the persistence of "deleted" data and the forensic value of database artifacts.

Category: Digital Forensics / Database Analysis

Difficulty: Medium

Author: Sharayu Kotkar

Theme: Game of Thrones / The Citadel Archives


Problem Statement

A raven once carried a message across the realm, but the Citadel’s records now show no trace of it. The archive appears intact and the messages ordinary yet in Westeros, things thought lost often leave shadows behind. Your task is to investigate these remnants and recover the message that refused to disappear.

Provided Files

The challenge provides three specific files:

  • chat.db

  • chat.db-wal

  • chat.db-shm


Investigation & Analysis

Step 1: Identifying the Artifacts

The .db extension identifies the main file as a SQLite database. However, the presence of the -wal and -shm files is the real clue. These indicate that the database is operating in Write-Ahead Logging (WAL) mode.

Why this matters:

  • WAL files contain recent writes and uncommitted transactions.

  • More importantly for us, they often contain remnants of deleted data that has not yet been "checkpointed" or overwritten in the main database file.

Step 2: Inspecting the "Official" Records

We open the database to see what the Citadel wants us to see:

Bash
sqlite3 chat.db
sqlite> .tables
sqlite> SELECT * FROM messages;

The output displays several mundane chat messages. No secrets, no flags. This confirms that the message we are looking for is no longer part of the "active" database state.

Step 3: Hunting the Shadows

Since the data isn't in the primary table, we shift our focus to the WAL file. Because these logs are binary, a standard text editor won't help, but the strings utility is perfect for extracting human-readable sequences from binary blobs.

Running the command:

Bash
strings chat.db-wal

Hidden among the binary noise, a suspicious string appears: Qnl0ZU1le2xvc3RfbWVzc2FnZXNfbmV2ZXJfZGllfQ==

Step 4: Decoding the Message

The trailing == is a classic indicator of Base64 encoding. We can decode this via the terminal:

Bash
echo Qnl0ZU1le2xvc3RfbWVzc2FnZXNfbmV2ZXJfZGllfQ== | base64 --decode

Decoded Output: ByteMe{lost_messages_never_die}


Final Answer (Flag)

Flag: ByteMe{lost_messages_never_die}


Key Takeaways

  • Data Persistence: Deleting a row in a database doesn't immediately scrub the bits from the disk.

  • Auxiliary Files: In forensics, the "sidecar" files (like -wal and -journal) are often more valuable than the primary file.

  • Simplicity Wins: Never underestimate basic tools like strings. They can often bypass complex structures to find the raw data hidden within.

In the Citadel, as in security, the archives never truly forget.

Comments

Popular posts from this blog

CyberKavach QuestCon Series: Upside-Down Vault

From Open Networks to Safe Systems: How Firewalls Block the Hacker’s Doorway

CyberKavach QuestCon Series: VecNet