Phinlupix's Last Laugh

Upon apprehending the hacker Phinlupix, investigators seized his laptop and managed to dump its memory before the device shut down. Throughout the entire escort, he kept muttering a single phrase over and over: “Don’t trust strings… don’t trust strings…” Alongside the memory dump, we also recovered a technical document describing the data structures of the encryption module he used. Recover what remains in memory and find the flag.

Recon

The handout is a zip with two files. artifact_1.vmem is a 32 MB memory image from the hacker’s laptop, and artifact_2.png is a photo of a technical document describing the data structures of his encryption module. The muttering about strings is the design principle of the whole challenge. The flag is never stored as a plaintext string in RAM, it lives inside encrypted binary records, and the photo documents their layout. This is a custom parsing and decryption job, not a strings hunt.

Triage of the memory dump

$ file artifact_1.vmem artifact_2.png
artifact_1.vmem: data
artifact_2.png: PNG image data, 238 x 222, 8-bit/color RGBA, non-interlaced

strings -n 8 pulls 8282 printable runs out of the dump and almost all of them are noise. The printable-byte ratio over the whole file is 0.371, which is what uniform random bytes give (95 of the 256 byte values are printable), and a page-by-page scan for printable density above 0.5 finds no 4 KB page at all. A real Linux RAM image does not look like this. The dump is synthetic, random filler with a handful of planted artifacts, so we stopped looking for operating system structures and focused on finding the planted data.

A few of the planted strings carry meaning:

$ strings -n 8 artifact_1.vmem | grep -aoE '^(USER=svc-encrypt|X-Session-Token=[0-9a-f]+|SVC_RETRY=3|/var/log/auth.log|/etc/shadow|nginx: worker process|/usr/lib/systemd/systemd-journald)' | sort -u
/etc/shadow
/usr/lib/systemd/systemd-journald
/var/log/auth.log
nginx: worker process
SVC_RETRY=3
USER=svc-encrypt
X-Session-Token=8f61c3e0912b4b1a

Two of the plants are key material. At offset 13,000,000 sits a lone base64 string:

$ grep -aob 'TjB2NFJ1bl9NM20wcnlfMjAyNg==' artifact_1.vmem
13000000:TjB2NFJ1bl9NM20wcnlfMjAyNg==
$ echo 'TjB2NFJ1bl9NM20wcnlfMjAyNg==' | base64 -d
N0v4Run_M3m0ry_2026

At offset 9,800,000 sits a key block wrapped in sentinels:

$ xxd -s 9799984 -l 64 artifact_1.vmem
00958930: ea78 51f8 8909 4560 9006 8427 5de9 3944  .xQ...E`...'].9D
00958940: 2d2d 4b45 595f 5354 4152 542d 2d49 e669  --KEY_START--I.i
00958950: 54ae 1d53 35d1 a47b f10a 5fa8 542d 2d4b  T..S5..{.._.T--K
00958960: 4559 5f45 4e44 2d2d beb0 4966 a467 ff6a  EY_END--..If.g.j

The 16 bytes between the markers are 49e66954ae1d5335d1a47bf10a5fa854. A 16-byte key block points at a 128-bit cipher.

The document photo

The struct diagram photo shipped with the challenge (artifact_2.png). Four fields are readable and the fifth is cut off at the edge of the photo.

The photo documents the record layout of the encryption module as magic (8) | salt (16) | iterations (4, LE) | iv (16), followed by a fifth field cut off at the edge of the photo. We assumed the missing field named the cipher and the key derivation, and that assumption drove everything that followed. The photo also hands over both record magics in its metadata:

$ exiftool artifact_2.png | grep -iE 'comment|image (width|height)'
Image Width                     : 238
Image Height                    : 222
Comment                         : DEADC0DEFEEDBABE
User Comment                    : CAFEBABE1337C0FF

Because the fifth field was cropped we checked whether the PNG was hiding it. It is not. The decompressed IDAT stream is exactly the 222 rows the IHDR header declares, so there are no hidden rows under the visible image, and the alpha channel is 255 everywhere except a uniform 96 across the last pixel row, which reads as a marker rather than data. The missing field is genuinely gone.

Locating the two records

Each magic appears exactly once in the dump:

$ python3 -c "
import re
d = open('artifact_1.vmem','rb').read()
for h in ('deadc0defeedbabe','cafebabe1337c0ff'):
    print(h, [hex(m.start()) for m in re.finditer(re.escape(bytes.fromhex(h)), d)])"
deadc0defeedbabe ['0x1775dc0']
cafebabe1337c0ff ['0x1eb5540']

Those offsets are decimal 24,600,000 and 32,200,000, the same round-number planting pattern as the password and the key block. Record 1 parses exactly like the diagram:

$ xxd -s 0x1775dc0 -l 64 artifact_1.vmem
01775dc0: dead c0de feed babe c315 9c7c 4287 3521  ...........|B.5!
01775dd0: fa2e 0124 1d7c 0e78 400d 0300 a277 652c  ...$.|[email protected],
01775de0: d0d9 e081 f03b c624 16c3 1be4 4597 2f5b  .....;.$....E./[
01775df0: fa3d a704 bde6 4e22 fb25 e137 ed4f 2a77  .=....N".%.7.O*w

Magic deadc0defeedbabe, salt c3159c7c42873521fa2e01241d7c0e78, the u32 at +24 reads 400d 0300 little endian, which is 200000 iterations, IV a277652cd0d9e081f03bc62416c31be4 at +28, and high-entropy data from +44 onward. Since the diagram ends at the IV, we took that +44 region for the ciphertext. Record 2 does not fit the same reading:

$ xxd -s 0x1eb5540 -l 64 artifact_1.vmem
01eb5540: cafe babe 1337 c0ff 3000 0000 a74f cbf8  .....7..0....O..
01eb5550: 94b9 d286 20fc f366 edd0 a785 cfd1 7219  .... ..f......r.
01eb5560: 1c43 afe1 cdda c14c db0b 3780 8476 3c64  .C.....L..7..v<d
01eb5570: df07 990e e136 c537 3ed1 17b9 0773 68ea  .....6.7>....sh.

Magic cafebabe1337c0ff, then 3000 0000, which is 48 as a little-endian u32, then high-entropy bytes. Two records, and only one of them matched the diagram.

Getting the record boundary right

The scheme itself was never a guess. A 200,000-iteration field names PBKDF2, the planted password is in hand, and a 16-byte key with a 16-byte IV points at AES-128-CBC. So we ran the obvious decryption against the ciphertext region we had chosen, record 1’s tail from +44:

$ python3 -c "
import base64, hashlib
from Crypto.Cipher import AES
d = open('artifact_1.vmem','rb').read()
B = 0x1775dc0
pw  = base64.b64decode('TjB2NFJ1bl9NM20wcnlfMjAyNg==')
key = hashlib.pbkdf2_hmac('sha256', pw, d[B+8:B+24],
                          int.from_bytes(d[B+24:B+28],'little'), dklen=16)
iv  = d[B+28:B+44]
pt  = AES.new(key, AES.MODE_CBC, iv).decrypt(d[B+44:B+44+48])
print('first block:', pt[:16])
print('printable ratio: %.3f' % (sum(1 for c in pt if 32 <= c < 127 or c in (9,10))/len(pt)))"
first block: b'\xc1\xae\n\x8a\xbe\xd08\xf8"\xefJQw{.\x12'
printable ratio: 0.375

The output is noise, a printable ratio of 0.375 is the uniform-random figure the filler pages of this dump already showed, so record 1’s tail is not ciphertext under this key. A scheme that every field in the record names should not return noise, which means the parse is wrong, not the cipher.

Record 2 is where the assumed layout broke, and it broke before we could aim a decryption at it. Read with record 1’s field positions, its iteration count at +24 would be 2,242,367,725, hours of key derivation that no design specifies and no attacker waits out. The “recover what remains” framing suggested record 2’s middle bytes might have been wiped, but a scan for zero runs in the 4 KB around the record found none, so no fields were wiped. That leaves the layout itself as the suspect, and comparing the two records field by field settles what record 2 is:

$ python3 -c "
import struct
d = open('artifact_1.vmem','rb').read()
print('rec1 iterations at +24:', struct.unpack_from('<I', d, 0x1775dc0+24)[0])
print('rec2 u32 at +8        :', struct.unpack_from('<I', d, 0x1eb5540+8)[0])
print('rec2 u32 at +24       :', struct.unpack_from('<I', d, 0x1eb5540+24)[0])"
rec1 iterations at +24: 200000
rec2 u32 at +8        : 48
rec2 u32 at +24       : 2242367725

No salt starts with the clean little-endian value 48, but a length field does. That 48 is the real header. Record 2 describes itself, magic (8) | length (4, LE) | payload, so its payload starts at +12, not +44, and runs exactly 48 bytes. There is no other length cue, since encrypted bytes and random filler have the same statistics.

Pointing the same key and IV at the 48 bytes record 2 actually delimits:

$ python3 -c "
import base64, hashlib
from Crypto.Cipher import AES
d = open('artifact_1.vmem','rb').read()
B1, B2 = 0x1775dc0, 0x1eb5540
pw  = base64.b64decode('TjB2NFJ1bl9NM20wcnlfMjAyNg==')
key = hashlib.pbkdf2_hmac('sha256', pw, d[B1+8:B1+24],
                          int.from_bytes(d[B1+24:B1+28],'little'), dklen=16)
iv  = d[B1+28:B1+44]
pt  = AES.new(key, AES.MODE_CBC, iv).decrypt(d[B2+12:B2+12+48])
pad = pt[-1]
print('first block:', pt[:16])
print('PKCS7 pad valid:', 1 <= pad <= 16 and pt[-pad:] == bytes([pad]) * pad)"
first block: b'NVR{pbkdf2_1s_th'
PKCS7 pad valid: True

The plaintext opens with the flag format and ends in fifteen bytes of valid PKCS7 padding, so the corrected boundary is the right one. The records divide the work between them. Record 1 carries the parameters the diagram documents, salt, iterations and IV. Record 2 carries the encrypted flag. The key derives from the planted password with PBKDF2-HMAC-SHA256 over record 1’s salt and iteration count, and the cropped fifth field only ever hid the cipher name. AES-128-CBC fits every observation. Its key is 16 bytes like the planted key block, its input is 48 bytes, a multiple of the 16-byte block size, and the IV that CBC requires is the one record 1 already provides.

Flag capture

The full solve in one script, with the record boundary corrected:

import base64, hashlib
from Crypto.Cipher import AES

data = open('artifact_1.vmem', 'rb').read()
B1, B2 = 0x1775dc0, 0x1eb5540

# record 1 holds the parameters from the diagram
salt  = data[B1+8:B1+24]
iters = int.from_bytes(data[B1+24:B1+28], 'little')
iv    = data[B1+28:B1+44]

# record 2 is self-describing: magic(8) | length(4) | ciphertext
length = int.from_bytes(data[B2+8:B2+12], 'little')
ct     = data[B2+12:B2+12+length]

pw  = base64.b64decode('TjB2NFJ1bl9NM20wcnlfMjAyNg==')
key = hashlib.pbkdf2_hmac('sha256', pw, salt, iters, dklen=16)
pt  = AES.new(key, AES.MODE_CBC, iv).decrypt(ct)

print('key      ', key.hex())
print('plaintext', pt)
pad = pt[-1]
print('pad byte', pad, 'valid:', pt[-pad:] == bytes([pad]) * pad)
print('re-encrypt matches ciphertext:', AES.new(key, AES.MODE_CBC, iv).encrypt(pt) == ct)
$ python3 solve.py
key       c481f6f646da0f587a5522c8653f15dd
plaintext b'NVR{pbkdf2_1s_th3_r34l_b055_h3r3}\x0f\x0f\x0f\x0f\x0f\x0f\x0f\x0f\x0f\x0f\x0f\x0f\x0f\x0f\x0f'
pad byte 15 valid: True
re-encrypt matches ciphertext: True