stegofreeeasy
Stomach Bug
metactf
Task: a web endpoint continuously streams printable junk mixed with indexed hex chunks that hide an image. Solution: extract the numbered hex records, rebuild the PNG, decode two QR layers, repair UTF-8-expanded bytes with latin1 re-encoding, then base64-decode the final payload.
$ ls tags/ techniques/
ordered_hex_reassemblynested_qr_decodingutf8_to_latin1_byte_recovery
Stomach Bug — metactf
Description
Source challenge:
Stomach BugURL:
https://stomachbug.umbccd.net
English summary: the endpoint returns an endless attachment named spew.txt. Inside the stream, useful data appears as numbered hex records mixed with distracting printable ASCII lines.
Analysis
Recon observations:
- The server does not return a normal HTML page; it starts downloading
spew.txtand keeps streaming. - The body alternates between sliding printable ASCII text and lines of the form
|000|...through|161|.... - The numbered lines are hex-only payload chunks. Sorting by index and concatenating them reconstructs a valid PNG.
- The recovered image is a 625x625 grayscale QR code.
- Decoding that QR yields PNG bytes that were expanded through UTF-8 text encoding, so they must be converted back with
.decode("utf-8").encode("latin1")before opening the nested image. - The second QR contains a base64 string, which decodes directly to the flag.
Solution
Extraction pipeline:
- Download only a short slice of the endless response.
- Regex-extract all numbered hex chunks.
- Sort them by numeric index and concatenate the hex payload.
- Convert the hex to bytes and save the first PNG.
- Decode the first QR.
- Repair the UTF-8-expanded PNG bytes with
.decode("utf-8").encode("latin1"). - Decode the nested QR.
- Base64-decode the nested QR text to recover the flag.
#!/usr/bin/env python3 import base64 import io import re import requests from PIL import Image from pyzbar.pyzbar import decode URL = "https://stomachbug.umbccd.net" LINE_RE = re.compile(r"^\|(\d{3})\|([0-9a-fA-F]+)$") ...
🔒
Permission denied (requires auth)
Sign in to read this free writeup
This writeup is free — just sign in with GitHub to read it.
$ssh [email protected]