Undertow ext4 full-journaling recovers a deleted script

forensics
flag L3m0n{the_journal_remembers_what_you_deleted_e6ad3b7f}

nas-srv01.img.xz unpacks to a 128 MB ext4 volume, label NASOPS, no partition table. The description all but narrates the solve: a key-rotation script went missing from the ops directory, a suspicious .bak sits in its place, and a vault.bin still needs unsealing.

Hint

fls -rd finding nothing deleted doesn't mean nothing is recoverable - it means nothing is recoverable that way. Check the mount options.

The live tree is a dead end

debugfs lists /srv/ops: asset_tag.txt, README.ops, vault.bin, rotate_keys.sh.bak. The real rotate_keys.sh is missing, and it's not sitting as a recoverable deleted directory entry either - fls -rd comes back empty. The .bak turns out to be the wrong script entirely (ops.log later spells this out: "unexpected .bak present").

Insight

/etc/fstab has the actual lever:

output
LABEL=NASOPS   /srv   ext4   defaults,data=journal,errors=remount-ro   0 2

data=journal - this volume was mounted with full data journalling, meaning file contents, not just metadata, get written into the ext4 journal before they're committed to their real location. A file that was deleted normally can still be sitting, complete, inside the journal itself. ext4's journal lives at a fixed inode (8), so it can be dumped directly:

bash
1debugfs -R "dump <8> journal.bin" nas-srv01.img

Carving the dumped journal turns up three complete revisions of the missing script, each stamped with its own salt:

output
revision 1   SALT="f4f93a271a5bb206cb5cee4f"
revision 2   SALT="b5f9160cc6b5edd84347f1a4"
revision 3   SALT="cb41263a47bf9f9ae3843005"

Pitfall

The .bak left on disk carries a fourth salt (1f12fe28d4d6d7b947258c7e) that matches none of the three recovered revisions - a deliberate decoy. ops.log confirms which revision is actually live:

output
2026-02-03 11:18:07 ops: rotate_keys.sh updated, salt rotated (revision 3, current)
2026-02-03 11:19:40 ops: vault.bin resealed against revision 3

Deriving the key and decrypting

The recovered script spells out the whole derivation, no mystery cipher:

output
KEY = sha256("HOST:SERIAL:SALT")     # hex, 32 bytes
IV  = md5("SERIAL")                  # hex, 16 bytes
AES-256-CBC over vault.bin

HOST comes from /etc/hostname (nas-srv01.instr.englab), SERIAL from the Chassis-Serial field in asset_tag.txt (INSTR-EE2F-2BCFD0). Trying all three recovered salts, only revision 3 produces a cleanly-padded plaintext:

output
nas-srv01 credential vault
--------------------------
smtp relay ......... relay.instr.englab:587
backup account ..... svc-backup
recovery token ..... L3M0N{the_journal_remembers_what_you_deleted_e6ad3b7f}

Note

The vault stores the wrapper uppercase, L3M0N{...} - the event's actual flag format is lowercase L3m0n{...}. Worth a double take before submitting a flag that looks right but doesn't match the stated format character-for-character.

output
L3m0n{the_journal_remembers_what_you_deleted_e6ad3b7f}

A dozen run-00X.bin blobs and a 1 MB .stage file elsewhere on the volume are noise - they overwrote free blocks on disk, never touched the journal, and never factor into the solve.