How Data Is Hidden in Files: Four Steganography Techniques in Pictures
Before launching any tools, it's important to understand what exactly we're looking for. All methods for embedding hidden data in files fall into four families—from trivial ones to those requiring specialized steganalysis.
Metadata. Every JPEG, PNG, or MP3 file carries structured metadata: EXIF tags, XMP blocks, and ID3 frames. The Comment, Artist, and Copyright fields accept arbitrary text without validation. A Base64 string in an EXIF comment is the laziest way to hide information, but it's common because it works and doesn't require anything more complex than a text editor.
Appended data and polyglot files. Image formats clearly announce their end. JPEG ends with a marker. FF D9, PNG — by piece IENDViewers ignore everything after these markers, but the file system stores it correctly. Combine PNG and ZIP files using cat photo.png secret.zip > output.png— you get a polyglot that opens both as an image and as an archive. According to SigmaHQ, there's a separate rule for detecting such operations. lnx_auditd_hidden_zip_files_steganography.yml— the polyglot technique is used far beyond the scope of educational CTFs.
LSB encoding. Classic LSB steganography: in a 24-bit image, each pixel stores three 8-bit channels. Changing the last bit of a channel shifts the color by 1/256, which is invisible to the eye. On a 1920x1080 image, this yields approximately 760 KB of usable space for hidden data. The same arithmetic works for WAV audio samples. A critical nuance: LSB data does not survive recoding. Upload an image to a social network—the payload is destroyed.
Text and whitespace. Zero-width space (U+200B), zero-width non-joiner (U+200C) are legitimate Unicode characters of zero width. These two characters directly encode binary data. This is less common in CTFs, but if the task outputs a text file, check for invisible characters using xxd.
Steganography Tools: Compatibility Chart
The biggest mistake beginners make is grabbing the first tool they come across. steghide doesn't support PNG. zsteg doesn't work with JPEG. Here's a table to keep handy when analyzing files for hidden data:
Tool Format What is he looking for? Restrictions
file Any Real type by magic bytes Does not analyze content
exiftool Any EXIF/XMP/ID3 metadata Doesn't see LSB and appended data
binwalk Any Attached files by signature Doesn't work with LSB data
strings Any Printable ASCII strings High noise, many false alarms
steghide 0.5.1 JPEG, BMP, WAV, AU LSB with encryption (Rijndael-128 CBC) No PNG or GIF support
stegseek JPEG, BMP, WAV, AU Brute-force steghide passwords Requires dictionary (rockyou.txt)
zsteg PNG, BMP LSB of all bit planes No JPEG support
foremost Any Carving files by headers Slower than binwalk on large files
Sonic Visualiser WAV, MP3, FLAC Audio spectrogram Requires human visual analysis
The choice is determined by the file format. PNG — zsteg. JPEG — steghide and stegseek. WAV — Audacity plus steghide. Any file, without exception — let's start with file, exiftool, binwalkIf you're short on time at a CTF tournament, stegoveritas runs exiftool, binwalk, zsteg, foremost, and color plane extraction with a single command. It's a handy tool, though it can be time-consuming on large files.
Step-by-step file analysis for hidden data
The first step is critical. File with extension .jpgmay be a PNG, ZIP, or ELF binary. fileReads magic bytes and displays the actual format. A mismatch between the extension and the actual type is a clue in itself.
The fourth step is often underestimated. The steghide password is often hidden right in the file—in ASCII strings. At one tournament, the flag was encoded in base64 and simply appended after the end marker of the JPEG. stringsshowed it without any specialized steganography tools.
exiftool: Analyze image metadata
exiftool is the first thing that runs after fileThe utility reads dozens of metadata formats: EXIF, IPTC, XMP, ICC profiles, and GPS coordinates. In CTFs, we're interested in text fields where the problem author could enter a hint or flag.
exiftool challenge.jpgDisplays all available fields. Look at Comment, UserComment, Artist, Copyright, and ImageDescription. A Base64 string or hex sequence in any of them is a reason to decode. GPS coordinates sometimes contain the numeric portion of the flag.
The thumbnail should be checked separately. A JPEG may contain a thumbnail that differs from the main image. It is extracted via exiftool -b -ThumbnailImage challenge.jpg > thumb.jpgIn several CTFs, I encountered a situation where the thumbnail contained another image with hidden text—the main image was a trap.
Fact for the blue team: exiftool appears in GTFOBins as a utility for reading arbitrary files. If a CTF machine has exiftool with the SUID bit enabled, that's a privilege vector, not a steganography one.
binwalk: file extraction and polyglot detection
binwalk scans binary files for hundreds of known signatures: ZIP, RAR, gzip, JPEG, PNG, and ELF headers. If an archive is hidden within an image, binwalk will show the offset.
binwalk challenge.pngDisplays a table of found signatures with offsets. If you see a ZIP at offset 0x1234, extract it using binwalk -e challenge.png. A directory will be created. _challenge.png.extractedwith all contents. For pinpoint extraction: dd if=challenge.png bs=1 skip=$((0x1234)) of=extracted.zip.
Polyglot files are a common find on binwalk. JPEG+ZIP, PNG+RAR, and PDF+ZIP are common in both CTFs and real-world incidents. Always try unzip challenge.jpg or 7z x challenge.jpg— even if binwalk didn't show anything. Sometimes signatures are masked, and binwalk misses them.
steghide and stegseek: LSB steganography with password
Steghide is a classic steganography tool for JPEG and WAV. Version 0.5.1 was released in 2003 and hasn't been updated since, but the target formats are also stable, so this isn't a problem. It only supports JPEG, BMP, WAV, and AU. PNG is not supported—if your task returns PNG and steghide suggests it, look for a different file.
steghide encrypts the payload before embedding - in the standard 0.5.1 build, the default is Rijndael-128 in CBC mode (checked with the command steghide --encinfo). Without the correct password, the data cannot be extracted: the command will return an error, not garbage. To analyze files for hidden data, start with the following check: steghide info challenge.jpgwill show if there is an attachment.
A blank password solves a surprising number of CTF problems. Seriously, try it before brute-forcing. If that doesn't work, try stegseek with rockyou.txt. According to 0xrick.github.io, stegseek brute-forces dictionary passwords orders of magnitude faster than stegcracker and, in practice, cracks trivial passwords in seconds. SigmaHQ contains detection rules for both steghide embed ( lnx_auditd_steghide_embed_steganography.yml), and steghide extract ( lnx_auditd_steghide_extract_steganography.yml) via auditd.
zsteg: LSB analysis of PNG and BMP
zsteg fills a niche that steghide does not: LSB steganography in PNG and BMP. zsteg -a challenge.pngIterates through all combinations of bit planes, byte orders, and channels. The output is voluminous—look for lines with readable text or patterns. flag{, CTF{.
For pinpoint extraction: zsteg -E "b1,rgb,lsb,xy" challenge.png— will extract data from the first bit of the RGB channels in LSB order.
A special trick for PNG is the CRC and dimensions trick. If the task author manually changed the height (or width) field in IHDR to hide part of the image, the chunk's CRC32 no longer matches the content. pngcheck -v challenge.pngThis will be detected. Next, it tries valid width/height values and recalculates the chunk's CRC32, after which the hidden area becomes visible. A neat trick, common in medium- and complex CTFs.
Before launching any tools, it's important to understand what exactly we're looking for. All methods for embedding hidden data in files fall into four families—from trivial ones to those requiring specialized steganalysis.
Metadata. Every JPEG, PNG, or MP3 file carries structured metadata: EXIF tags, XMP blocks, and ID3 frames. The Comment, Artist, and Copyright fields accept arbitrary text without validation. A Base64 string in an EXIF comment is the laziest way to hide information, but it's common because it works and doesn't require anything more complex than a text editor.
Appended data and polyglot files. Image formats clearly announce their end. JPEG ends with a marker. FF D9, PNG — by piece IENDViewers ignore everything after these markers, but the file system stores it correctly. Combine PNG and ZIP files using cat photo.png secret.zip > output.png— you get a polyglot that opens both as an image and as an archive. According to SigmaHQ, there's a separate rule for detecting such operations. lnx_auditd_hidden_zip_files_steganography.yml— the polyglot technique is used far beyond the scope of educational CTFs.
LSB encoding. Classic LSB steganography: in a 24-bit image, each pixel stores three 8-bit channels. Changing the last bit of a channel shifts the color by 1/256, which is invisible to the eye. On a 1920x1080 image, this yields approximately 760 KB of usable space for hidden data. The same arithmetic works for WAV audio samples. A critical nuance: LSB data does not survive recoding. Upload an image to a social network—the payload is destroyed.
Text and whitespace. Zero-width space (U+200B), zero-width non-joiner (U+200C) are legitimate Unicode characters of zero width. These two characters directly encode binary data. This is less common in CTFs, but if the task outputs a text file, check for invisible characters using xxd.
Steganography Tools: Compatibility Chart
The biggest mistake beginners make is grabbing the first tool they come across. steghide doesn't support PNG. zsteg doesn't work with JPEG. Here's a table to keep handy when analyzing files for hidden data:
Tool Format What is he looking for? Restrictions
file Any Real type by magic bytes Does not analyze content
exiftool Any EXIF/XMP/ID3 metadata Doesn't see LSB and appended data
binwalk Any Attached files by signature Doesn't work with LSB data
strings Any Printable ASCII strings High noise, many false alarms
steghide 0.5.1 JPEG, BMP, WAV, AU LSB with encryption (Rijndael-128 CBC) No PNG or GIF support
stegseek JPEG, BMP, WAV, AU Brute-force steghide passwords Requires dictionary (rockyou.txt)
zsteg PNG, BMP LSB of all bit planes No JPEG support
foremost Any Carving files by headers Slower than binwalk on large files
Sonic Visualiser WAV, MP3, FLAC Audio spectrogram Requires human visual analysis
The choice is determined by the file format. PNG — zsteg. JPEG — steghide and stegseek. WAV — Audacity plus steghide. Any file, without exception — let's start with file, exiftool, binwalkIf you're short on time at a CTF tournament, stegoveritas runs exiftool, binwalk, zsteg, foremost, and color plane extraction with a single command. It's a handy tool, though it can be time-consuming on large files.
Step-by-step file analysis for hidden data
The first step is critical. File with extension .jpgmay be a PNG, ZIP, or ELF binary. fileReads magic bytes and displays the actual format. A mismatch between the extension and the actual type is a clue in itself.
The fourth step is often underestimated. The steghide password is often hidden right in the file—in ASCII strings. At one tournament, the flag was encoded in base64 and simply appended after the end marker of the JPEG. stringsshowed it without any specialized steganography tools.
exiftool: Analyze image metadata
exiftool is the first thing that runs after fileThe utility reads dozens of metadata formats: EXIF, IPTC, XMP, ICC profiles, and GPS coordinates. In CTFs, we're interested in text fields where the problem author could enter a hint or flag.
exiftool challenge.jpgDisplays all available fields. Look at Comment, UserComment, Artist, Copyright, and ImageDescription. A Base64 string or hex sequence in any of them is a reason to decode. GPS coordinates sometimes contain the numeric portion of the flag.
The thumbnail should be checked separately. A JPEG may contain a thumbnail that differs from the main image. It is extracted via exiftool -b -ThumbnailImage challenge.jpg > thumb.jpgIn several CTFs, I encountered a situation where the thumbnail contained another image with hidden text—the main image was a trap.
Fact for the blue team: exiftool appears in GTFOBins as a utility for reading arbitrary files. If a CTF machine has exiftool with the SUID bit enabled, that's a privilege vector, not a steganography one.
binwalk: file extraction and polyglot detection
binwalk scans binary files for hundreds of known signatures: ZIP, RAR, gzip, JPEG, PNG, and ELF headers. If an archive is hidden within an image, binwalk will show the offset.
binwalk challenge.pngDisplays a table of found signatures with offsets. If you see a ZIP at offset 0x1234, extract it using binwalk -e challenge.png. A directory will be created. _challenge.png.extractedwith all contents. For pinpoint extraction: dd if=challenge.png bs=1 skip=$((0x1234)) of=extracted.zip.
Polyglot files are a common find on binwalk. JPEG+ZIP, PNG+RAR, and PDF+ZIP are common in both CTFs and real-world incidents. Always try unzip challenge.jpg or 7z x challenge.jpg— even if binwalk didn't show anything. Sometimes signatures are masked, and binwalk misses them.
steghide and stegseek: LSB steganography with password
Steghide is a classic steganography tool for JPEG and WAV. Version 0.5.1 was released in 2003 and hasn't been updated since, but the target formats are also stable, so this isn't a problem. It only supports JPEG, BMP, WAV, and AU. PNG is not supported—if your task returns PNG and steghide suggests it, look for a different file.
steghide encrypts the payload before embedding - in the standard 0.5.1 build, the default is Rijndael-128 in CBC mode (checked with the command steghide --encinfo). Without the correct password, the data cannot be extracted: the command will return an error, not garbage. To analyze files for hidden data, start with the following check: steghide info challenge.jpgwill show if there is an attachment.
A blank password solves a surprising number of CTF problems. Seriously, try it before brute-forcing. If that doesn't work, try stegseek with rockyou.txt. According to 0xrick.github.io, stegseek brute-forces dictionary passwords orders of magnitude faster than stegcracker and, in practice, cracks trivial passwords in seconds. SigmaHQ contains detection rules for both steghide embed ( lnx_auditd_steghide_embed_steganography.yml), and steghide extract ( lnx_auditd_steghide_extract_steganography.yml) via auditd.
zsteg: LSB analysis of PNG and BMP
zsteg fills a niche that steghide does not: LSB steganography in PNG and BMP. zsteg -a challenge.pngIterates through all combinations of bit planes, byte orders, and channels. The output is voluminous—look for lines with readable text or patterns. flag{, CTF{.
For pinpoint extraction: zsteg -E "b1,rgb,lsb,xy" challenge.png— will extract data from the first bit of the RGB channels in LSB order.
A special trick for PNG is the CRC and dimensions trick. If the task author manually changed the height (or width) field in IHDR to hide part of the image, the chunk's CRC32 no longer matches the content. pngcheck -v challenge.pngThis will be detected. Next, it tries valid width/height values and recalculates the chunk's CRC32, after which the hidden area becomes visible. A neat trick, common in medium- and complex CTFs.