Challenge 3 - Uncovering Multiple layers of Hidden Data
CybersecMastery Research Team
•
November 11, 2026 •
75 min read
•
110 views
•
0 discussions
Table of Contents
Educational & Defensive Research Notice: The commands, tools, and technical procedures detailed in this guide are provided strictly for lawful security education, authorized penetration testing, and defense hardening. Never perform testing against any network or asset without prior written authorization. Consult our Ethical Hacking Disclaimer.
In the previous challenge, we recovered a hidden document from a JPEG image using Steghide and StegSeek. Challenge 3 takes a different approach. Instead of relying on a single hidden file, we need to investigate a JPEG containing several embedded data structures, carve those structures manually, and follow multiple layers of encryption and steganography to recover the flag.
This walkthrough covers the investigation from the initial file checks to the final archive extraction. We will use tools such as file, ExifTool, Binwalk, xxd, dd, OpenSSL, and a Python extraction script supplied with the challenge.
Lab note: The filenames, offsets, and password pattern in this article belong to this challenge. Your results may differ when analysing another file. Run these steps only against files and systems you own or are authorised to investigate.
Understanding the Challenge
Prepare the Challenge Files
Move into the directory for Challenge 3 in the downloaded challenge repository. The exact path depends on where you saved the repository. In this example, we are working from the challenge directory and using Honey.jpeg as the target image.
Well now… this here's a simple one, leastways it looks that way. Just one lonely JPEG, sittin' there waitin' to be picked over. Your job's plain enough — find the flag. But I'll tell you, partner, there ain't much in this world that's as simple as it looks. Plenty of folks've gone diggin' through fossils like this and never come back with so much as a whisper.
Now, if you get yourself stuck, and you ain't got nothin' better to do, lean back a spell, and I'll spin you a yarn about a feller they called John, back in the Desert Storm days.
They say John could stare down a locked file the way a cowboy sizes up a spooked horse — patient, calm, and just a little amused. He wasn't ridin' solo, neither. Had a few sharp pals who shared his taste for codes and riddles — Aho, Weinberger, and Kernighan. Together, they were somethin' of a posse — the kind who could turn scrambled lines into sense faster than a dust devil changes course.
When John needed a way to tie loose ends together, those three showed him a clever trick: how to stitch two strings — a word and a tail — into one clean rope. He liked that trick so much he'd jot their initials — A W K — in the margins of his notebook, a quiet grin on his face, like he was leavin' himself a joke only he'd get.
John, he always found ways to make work into play. He'd tell the young codebreakers, "Don't just pick a name — build one. Give it a backbone, then tack on somethin' small that makes it yours." To prove his point, he'd show 'em how to make a password that wasn't just strong, but had a rhythm to it: start with a codename, add a #, then toss on two numbers and a three-letter tag that danced between lower and upper case. Made sense to him — a little structure, a little flair, and a lesson tucked inside the challenge.
There was even a friend of his — a real peculiar fella — who wrote in fancy, alien-lookin' symbols, said you could describe any pattern with nothin' but question marks and letters. Folks these days call it mask shorthand or somethin' close to it. And if you peeked at John's old notebook, you'd see one of his patterns scribbled out like this:
?d?d?l?u?l
Well, I hope ya enjoyed an old man's tale about puzzles, little suffixes, and how sometimes the smallest patterns can open the biggest doors. So go on now. The JPEG's waitin'.
For the initial examination, we will focus on Honey.jpeg. We can return to the description when we need to interpret the challenge-specific clues.
Inspect the Image Format
A file extension does not prove a file's actual format. A text document or encrypted file can be renamed with a `.jpg` extension without becoming a JPEG image. We should inspect the file contents before trusting the extension.
The challenge file is identified as JPEG image data using the EXIF standard, with dimensions of 1024 × 1024 pixels. This confirms that the file contains a JPEG image structure.
However, a valid JPEG can still contain additional data. The next step is to inspect its metadata.
Inspect the JPEG Metadata
Image metadata can include information such as the camera model, image dimensions, orientation, date and time, colour space, and—in some cases—location details. Metadata can also contain clues deliberately added to a CTF challenge.
The output displays the image's technical properties, including its dimensions, EXIF version, orientation, colour space, and JPEG encoding information.
In this challenge, the metadata does not reveal an obvious hidden message. In particular, there is no useful encrypted message in the EXIF Comment field.
That does not mean the image is clean. Metadata is only one place where information can be stored. Additional content may be appended to the file or embedded between its normal structures. To investigate the complete binary file, we need a signature-scanning tool.
Scan the Image with Binwalk
Binwalk searches files for recognisable signatures that may indicate embedded files or data structures. For example, a JPEG may contain a ZIP archive, another image, or an encrypted data section.
Decimal: The byte offset where Binwalk identifies a structure, shown in decimal notation.
Hexadecimal: The same offset represented in hexadecimal notation.
Description: The type of structure or file signature detected.
The important findings in this challenge are:
The entries at offsets 235,921, 272,710, and 272,950 are especially interesting. They indicate three sections that appear to use OpenSSL's salted encryption format. Binwalk also identifies a ZIP archive and a second JPEG image.
These offsets mark the detected starting positions. They do not, by themselves, tell us the exact length of every structure. We must examine the boundaries before extracting each section.
Try Binwalk's Automatic Extraction
Binwalk can attempt to extract recognised embedded files. The -e option enables extraction, while -M enables recursive scanning, sometimes called Matryoshka extraction. With recursive extraction, Binwalk scans extracted files again for additional embedded structures.
Binwalk creates an extraction directory, usually named: _Honey.jpeg.extracted/
The output also reports that one or more items could not be extracted. This does not mean the signature scan was wrong. Identifying a structure and extracting or decrypting it are separate operations.
Binwalk may recognise an OpenSSL header but cannot determine the password needed to decrypt the data. It may also lack the extraction utility or rule required for a particular structure.
Its contents may look like a clue, but we should not assume that it is relevant. The directory also contains a ZIP archive, so inspect the archive before spending time on the text file.
Inspect the extracted ZIP archive
List the archive contents without extracting them:
The archive contains another file named do_not_open.txt. It is the same decoy file already found in the extraction directory. This branch does not lead to the main solution, so we can set it aside and return to the structures reported by the original Binwalk scan.
Binwalk identified multiple structures, but automatic extraction did not recover everything. We will therefore extract the required byte ranges ourselves. This process is known as file carving.
File carving is a digital forensics technique used to recover data from a larger file by identifying a structure's starting position and ending boundary. We can then copy only that range into a separate output file.
For this task, we will use two Linux utilities:
`xxd` displays file contents in hexadecimal form. It is useful for checking file signatures and inspecting bytes at specific offsets.
`dd` copies selected data from an input file to an output file. By setting the starting offset and byte count, we can carve an individual structure from the original image.
`bs=1` sets the block size to one byte, allowing precise byte-based offsets.
`skip` tells `dd` how many bytes to skip from the beginning of the input file.
`count` specifies how many bytes to copy after the skipped bytes.
`status=progress` displays the copy progress.
To calculate the number of bytes to carve, subtract the starting offset from the ending boundary:
Length = Ending boundary - Starting offset
For example, a section beginning at offset 100 and ending at boundary 200 has a length of 100 bytes. The ending boundary is exclusive: the byte at that boundary belongs to the next section and is not included in the current extraction.
Do not assume that the next Binwalk result always marks the exact end of the current structure.
There may be padding, unrelated bytes, comments, or other data between structures. Inspect the actual signatures and boundaries before choosing a byte count.
Carve the First OpenSSL-Encrypted Section
Binwalk reports the first encrypted section at decimal offset 235,921. Before extracting it, inspect its first 16 bytes:
This marker is commonly found in OpenSSL's password-based encryption file format. It is followed by salt information used by the key-derivation process.
Calculate the section length
The next ZIP archive begins at offset 246,742. However, the boundary established during this investigation for the encrypted section is 246,721, leaving a 21-byte gap before the ZIP archive begins.
Use the verified ending boundary rather than assuming the encrypted data continues directly to the ZIP signature:
Ending boundary: 246721
Starting offset: 235921
Length: 246721 - 235921 = 10800 bytes
The length is 10,800 bytes. It is divisible by 16, which is consistent with the block alignment expected for an AES-CBC encrypted payload, including the 16-byte OpenSSL salted header. This is a useful consistency check, although block alignment alone does not prove the encryption algorithm.
The extracted file should retain the OpenSSL `Salted__` header.
Carve the ZIP Archive
The ZIP archive begins at decimal offset 246,742. To determine its ending boundary, Binwalk's output identifies a ZIP end-of-central-directory record at offset 246,957.
The record begins with the ZIP end-of-central-directory signature. In this challenge, the record is 22 bytes long and has no additional ZIP comment. Therefore:
246957 + 22 = 246979
The calculated ending boundary, 246,979, matches the starting offset of the next JPEG image reported by Binwalk.
This confirms the boundary for this archive. In other ZIP files, the end-of-central-directory record may include a comment, so its comment-length field must also be checked rather than assuming the record is always exactly 22 bytes.
carved/decoy.zip: Zip archive data, made by v3.0 UNIX, extract using at least v2.0, last modified Sep 28 2025 19:37:50, uncompressed size 58, method=deflate
The extracted file should be identified as a ZIP archive, and the integrity test should complete successfully. Extract it into a separate directory if you want to inspect its contents:
The archive contains `do_not_open.txt`, the same decoy file discovered during Binwalk's automatic extraction. We have now confirmed that this ZIP archive is not the main route to the flag.
Carve the Second JPEG Image
The next embedded structure begins at offset 246,979 and is another JPEG image.
The extracted file is a JPEG image. Its metadata does not reveal an obvious clue, so we will retain it for later analysis. It becomes important when we investigate the JPEG quantization tables.
Carve the Fourth Structure: Another Encrypted Section
Binwalk identifies another OpenSSL-encrypted structure at offset 272,710.
Once again, the data begins with the `Salted__` marker.
The next encrypted section begins at offset 272,950. For this extraction, the established boundary of the current section is the start of that next structure.
Calculate the length:
Ending boundary: 272950
Starting offset: 272710
Length: 272950 - 272710 = 240 bytes
The 240-byte length is divisible by 16. This is consistent with the block alignment expected for an OpenSSL salted AES-CBC payload, but it is not, by itself, conclusive proof of the cipher.
Unlike the previous sections, there is no later embedded structure that marks the ending boundary. This section continues to the end of the original file. We therefore use the file size obtained earlier: 277,078 bytes.
The output should be 4,128 bytes long and should begin with the OpenSSL salted marker. The earlier JPEG metadata inspection did not reveal a useful clue, so we can leave that image aside for now.
We have now recovered all five structures identified during the initial scan.
The table lists the byte ranges used in this walkthrough. The ending boundary is exclusive, meaning the byte at the ending offset is not included in the extracted file.
At this stage, we have three encrypted files, one ZIP archive, and one additional JPEG image. The ZIP archive is a decoy. The next step is to decrypt the first OpenSSL file and examine the material inside it.
Decrypt the secret.enc
From our earlier investigation, we already know that this
file contains OpenSSL-encrypted data with a salted header. This means we cannot simply open it and read its original
contents.
We need the correct decryption settings and, most
importantly, the password.
So, where do we find the password?
This is where the challenge description becomes useful. Remember, the challenge brief contains some clues about the
password format.
Let's examine those clues carefully.
The challenge description contains a password pattern. It specifies a codename followed by a hash symbol and five characters with particular character types:
For this challenge:
`?d` represents a digit.
`?l` represents a lowercase letter.
`?u` represents an uppercase letter.
The codename is Desert Storm. The pattern requires two digits, then a lowercase letter, an uppercase letter, and another lowercase letter. Applying the challenge's intended formatting gives this password:
DesertStorm#82pLm
The password omits the space in the displayed codename.
Now, we've got a possible password that matches the pattern
provided in the challenge. Let's use it to decrypt the first encrypted file.
Decrypt the OpenSSL File
The first carved encrypted file is `carved/secret.enc`. Its `Salted__` header indicates that we should use OpenSSL's password-based decryption workflow.
secret_bundle.bin: Zip archive data, made by v3.0 UNIX, extract using at least v2.0, last modified Sep 28 2025 19:11:54, uncompressed size 8726, method=deflate
The output identifies it as a ZIP archive. We have successfully decrypted the first encrypted section, but we still need to inspect the archive contents.
`iv.bin` appears to contain an initialization vector.
`passwords.enc` contains encrypted password data.
`qtbl.py` is a Python script that extracts hidden information from JPEG quantization tables.
`STEGO_KEY_368.txt` contains data that appears to be used to construct the script's extraction key.
These filenames suggest that the files are related, but we
shouldn't assume their purpose just from their names. We will examine these files rather than assuming their purpose from their names alone.
Inspect the Encrypted Password File
Start by identifying the format of `passwords.enc`:
The `file` utility does not recognise a familiar format. That does not necessarily indicate corruption. The file may contain raw encrypted bytes without a standard file header.
The output looks like ciphertext, not readable text. Unlike `secret.enc`, it does not begin with the OpenSSL `Salted__` marker.
This suggests that `passwords.enc` may use raw encryption data with the key and initialization vector supplied separately.
What does this mean? It means that when we have the correct AES key and initialization vector, or IV, we can use OpenSSL to decrypt the encrypted file, provided we also specify the correct encryption algorithm and mode.
Finding and Verifying the AES Key and IV Before Decryption
AES encryption requires a key. In CBC mode, it also uses an initialization vector, commonly abbreviated as IV.
The key is the secret value used to encrypt and decrypt the data. The IV is an additional input used by CBC mode. For AES-CBC, the IV must be 16 bytes long, regardless of whether the AES key is 128, 192, or 256 bits.
Here, in this directory, we have an IV file. Inspect the IV file:
The displayed hexadecimal data contains 32 hexadecimal characters. Each pair of hexadecimal characters represents one byte, so the file contains 16 bytes.
This matches the required IV size for AES-CBC. However, the IV is not the AES key. We still need to recover the key before we can decrypt `passwords.enc`.
Understand the Python script
Before examining the key file, inspect the supplied Python script:
You can also display it directly with `cat`, although `less` is usually easier for longer scripts. Press `q` to exit `less`.
The script reads a JPEG image and searches for its DQT, or Define Quantization Table, data. Quantization tables are part of JPEG compression. The script examines selected values in those tables and extracts their two least significant bits to reconstruct hidden bytes.
This is a form of steganography: information is concealed in values that are part of the JPEG structure, rather than being stored as a normal visible message.
The script also accepts an optional key. According to its implementation, the supplied value is used in an XOR operation on the extracted bytes to reverse an additional layer of obfuscation. The recovered bytes are then written to an output file.
In other words, `qtbl.py` is not simply reading ordinary image metadata. It is designed to recover data hidden inside the JPEG quantization tables.
But what about the key? While looking to get hint or clue to get the key, I remembered a interesting file, here, we need
to investigate the file which is inside our extracted directory.
It's named STEGO_KEY_368.txt.
Construct the Extraction Key from `STEGO_KEY_368.txt`
The file `STEGO_KEY_368.txt` is the next clue. Its name contains the numbers 3, 6, and 8, which may indicate which records we need to select.
The result is zero. This does not mean the file is empty. It means the file contains no newline characters separating its contents into multiple lines.
The output makes the record positions easier to inspect. So, this means all the characters are stored on a single
line. We need to split this long string into smaller records first.
The challenge filename, `STEGO_KEY_368.txt`, indicates that we need to select records three, six, and
eight, in that exact order, and combine them into a single extraction key.
So, how do we do that? Remember the clue from the challenge brief? It mentions AWK.
But what exactly is AWK?
Select records 3, 6, and 8
AWK is a text-processing language commonly used on Linux. It can select specific records and process their contents. We will use it to extract records 3, 6, and 8, then join them without adding spaces or line breaks.
This 72-character string is the extraction key for `qtbl.py`. It isn't the final AES key. The Python script uses it to recover the AES key hidden inside the JPEG image.
Extract the AES Key from the JPEG Image
We now have the two required inputs:
The recovered JPEG image: `carved/nothingtoseehere.jpg`
The script processes the JPEG quantization tables and writes the recovered bytes to `aeskey.bin`. At this point, we have the AES key file and the IV file. Before attempting decryption, verify their lengths:
The key and IV are binary data. OpenSSL's `-K` and `-iv` options expect hexadecimal strings, so we must convert the contents before using them.
Convert the AES Key and IV to Hexadecimal
Use `xxd -p` to print each binary file as a plain hexadecimal string. The `tr` command removes newline characters, and command substitution stores the result in a shell variable.
The result should be 64 hexadecimal characters. Each hexadecimal character represents four bits, so 64 characters represent 256 bits, or 32 bytes. That is the expected size of an AES-256 key.
The result should be 32 hexadecimal characters, representing 128 bits, or 16 bytes. That is the expected size of an AES-CBC initialization vector.
These length checks help catch common errors, such as extracting an incomplete key or accidentally including extra characters.
Decrypt `passwords.enc`
We now have the AES key and IV required to decrypt `secret_bundle/passwords.enc`.
Because we are supplying the raw key and IV directly, we do not need password-based key derivation with `-pbkdf2`. Use OpenSSL's `-K` option for the hexadecimal key and `-iv` for the hexadecimal initialization vector:
The first entries show a filename and its corresponding password. The first pair refers to `secret.enc`, which we have already decrypted.
secret.enc
DesertStorm#82pLm
The remaining entries provide passwords for other encrypted files from the challenge.
One of the entries is associated with `decoy_random.enc`. Decrypting that file produces data that does not immediately identify itself as a familiar file format. We can inspect it, but it does not reveal a useful route to the flag.
For example, after decrypting the decoy with its corresponding password, inspect the result with:
In this challenge, the output is reported only as generic data. The initial bytes do not show a familiar file signature, and Binwalk does not identify another embedded structure. We can set this result aside and continue with the password entry associated with `payload.enc`.
Extract the Password for `payload.enc`
The sixth line of `passwords.txt` contains the password associated with `payload.enc`. Instead of typing a long password manually, save that line to a separate file.
The `$` displayed at the end of the line represents the newline character. It is not part of the password. When OpenSSL reads the password from a file, it handles the line ending as expected.
Using a password file also avoids several shell interpretation problems that can occur when a password contains characters such as `$`, `&`, semicolons, or backticks.
Decrypt `payload.enc`
We now have the encrypted file and its corresponding password. Use OpenSSL with AES-256-CBC and PBKDF2, and tell it to read the password from `pw.txt`:
This time, the file utility identifies the output as a ZIP archive. This is a promising result: the decrypted payload contains another archive that may hold the flag.
Test and extract the final archive
Before extracting it, test the ZIP archive's integrity:
The flag confirms that we have successfully completed Challenge 3.
What We Learned from Challenge 3
This challenge required more than finding a hidden file inside an image. We had to combine several forensic and steganographic techniques:
File identification: We used `file` to confirm the target's actual format instead of relying on its extension.
Metadata inspection: We used ExifTool to examine the JPEG's metadata.
Signature analysis: We used Binwalk to identify embedded encrypted sections, a ZIP archive, and another JPEG image.
Manual file carving: We used `xxd` to verify boundaries and `dd` to extract exact byte ranges from the original image.
Password-based decryption: We used a password pattern from the challenge description to decrypt the first OpenSSL-encrypted section.
JPEG steganography: We examined the supplied Python script and used it to recover an AES key from the image's quantization tables.
Text processing: We used `fold` and AWK to construct the extraction key from selected records in `STEGO_KEY_368.txt`.
Raw-key decryption: We converted the recovered binary AES key and IV into hexadecimal strings and used them to decrypt `passwords.enc`.
Archive analysis: We decrypted `payload.enc`, tested the resulting ZIP archive, and extracted the flag.
The central lesson is to work from evidence. A signature can tell us where a structure begins, but we must verify its boundaries before carving it. A file that the system reports as generic data is not necessarily useless; it may be raw ciphertext or a format without a recognisable header. Finally, encrypted data may require several separate clues—a password pattern, an embedded key, and an initialization vector—before it can be recovered.
That completes the walkthrough for Steganography CTF Challenge 3. Share your questions or observations in the comments, especially if your offsets or extraction results differ from those shown here.
Share this article:
CM
Verified
CybersecMastery Research & Editorial Group
Verified Security Analysts
Authored and peer-reviewed by certified information security practitioners (CEH, OSCP & CompTIA Security+ aligned). All lab commands, scripts, and exploit walkthroughs are tested in isolated environments before publication.