Challenge Description
I found this weird file on my computer. I tried opening it, but there were some problems.
We get a single file named inception.
Initial Analysis
file calls it a PNG, but strings and a hexdump show several file formats stacked into one. A file within a file within a file, hence Inception. Locating the signatures:
import redata = open("inception", "rb").read()# IEND (PNG end) @ 815# PK\x03\x04 (ZIP) @ 823 -> contains data.bin# %PDF @ 964# %%EOF @ 1617So there are three payloads in one blob: a PNG, a ZIP appended after it, and a PDF after that. Each holds one part of the flag.
Extraction
Part 1 - the PNG itself. Rendering the image shows text:
flag part 1================================byuctf{wh4t_Part 2 - the appended ZIP. Carve from the PK offset and read data.bin:
import zipfile, iopk = data.find(b"PK\x03\x04")z = zipfile.ZipFile(io.BytesIO(data[pk:]))print(z.read("data.bin").decode())# flag part 2# ================================# th3Part 3 - the trailing PDF. Decode its FlateDecode content stream:
import zlib, rem = re.search(rb"stream\r?\n(.*?)\r?\nendstream", data, re.S)print(zlib.decompress(m.group(1)).decode())# ... (flag part 3) ... (_fr3ak}) ...Assemble
part1: byuctf{wh4t_part2: th3part3: _fr3ak}Flag
byuctf{wh4t_th3_fr3ak}