HTB University CTF 2023 — BioBundle (medium)
Overview
A binary that dynamically loads an encrypted shared library from memory to perform flag validation — without touching disk.
Analysis
The get_handle() function:
- Calls
memfd_createto create an anonymous in-memory file descriptor - Iterates through an array
_, XORing each byte with0x37 - Writes the decrypted bytes to the in-memory fd
- Opens it as a shared library via
dlopen - Resolves a function named
"*"viadlsym— this is the actual validator
XORing the array’s first bytes with 0x37 yields \x7fELF — the ELF magic header.
Extraction Script
with open('exe.txt', 'rb') as f:
data = f.read().split()
val = [int(h, 16) for h in data]
res = bytes(v ^ 0x37 for v in val)
with open('inside_bio', 'wb') as f:
f.write(res)
Open inside_bio in IDA to find the validation logic and recover the flag.