LSB Steganography
Understand and extract data hidden via Least Significant Bit (LSB) manipulation in image files.
LSB Steganography
LSB (Least Significant Bit) steganography hides data in the lowest bit of each color channel in an image. Since changing a pixel value from 254 to 255 produces no visible color difference, the hidden data is invisible to the human eye. This is the most common image steganography technique in CTFs.
How LSB Works
Each pixel in an RGB image has three channels: Red, Green, Blue — each an 8-bit value (0–255). The least significant bit (bit 0) contributes the least to the visible color.
Original Red value: 11001010 (202)
After hiding '1': 11001011 (203) ← changes by just 1
After hiding '0': 11001010 (202) ← unchangedTo hide a message, each character's binary representation is spread across the LSBs of sequential pixels. The image looks identical, but the LSBs encode your data.
Bit-Plane Overview
Most commonly used for hiding. Changing bit 0 alters the pixel value by ±1 — completely invisible. zsteg scans this by default. Stegsolve "Red plane 0" shows this layer visually.
Step-by-Step Analysis
Identify and check metadata
file suspicious.png
exiftool suspicious.pngSearch for readable strings
strings suspicious.png | grep -iE "(flag|ctf|key|pass|secret)"Check for embedded files
binwalk suspicious.png
binwalk -e suspicious.pngRun automated LSB scan
zsteg suspicious.png # fastest for PNG
zsteg -a suspicious.png # try ALL combinationsVisual inspection
Open in Stegsolve or upload to StegOnline — browse each bit plane visually.
Manual Python extraction
Use the scripts below if tools return nothing but the file is still suspicious.
Always try zsteg -a suspicious.png before writing custom Python — it covers all standard channel/bit/order combinations in seconds.
Tool: zsteg (PNG and BMP)
zsteg is the go-to tool for automated LSB scanning of PNG files:
gem install zsteg
zsteg suspicious.png # basic scan
zsteg -a suspicious.png # try ALL combinations
zsteg -E "b1,rgb,lsb,xy" suspicious.png > extracted.bin # specific config
zsteg -E "b1,r,lsb,xy" suspicious.png # red channel only
zsteg -E "b2,rgb,lsb,xy" suspicious.png # 2 LSBs
zsteg -E "b1,bgr,lsb,xy" suspicious.png # reversed channel orderReading zsteg output:
b1,rgb,lsb,xy .. text: "flag{lsb_1s_fun}"
↑ ↑ ↑ hidden content
bit channel scan patternTool: steghide (JPEG and WAV)
steghide uses a different algorithm (not simple LSB) for JPEG files:
steghide extract -sf suspicious.jpg -p "" # blank password first
steghide extract -sf suspicious.jpg -p "password" # known password
steghide info suspicious.jpg # check if data embedded
# Crack password
stegseek suspicious.jpg /usr/share/wordlists/rockyou.txtsteghide does not work on PNG files — only JPEG and WAV. Use zsteg for PNG/BMP.
Tool: Stegsolve (GUI)
Stegsolve lets you visually flip through each individual bit plane:
wget http://www.caesum.com/handbook/Stegsolve.jar
java -jar Stegsolve.jar- File → Open → select image
- Click left/right arrows to cycle through bit planes
- Analyse → Data Extract → configure custom LSB extraction (channels, bit positions, scan order)
Manual Python Extraction
When tools fail or you need custom extraction:
from PIL import Image
img = Image.open("suspicious.png")
pixels = list(img.getdata())
bits = ""
for px in pixels:
bits += str(px[0] & 1) # LSB of red channel
message = ""
for i in range(0, len(bits), 8):
byte = bits[i:i+8]
if len(byte) == 8:
char_val = int(byte, 2)
if char_val == 0:
break
if 32 <= char_val <= 126:
message += chr(char_val)
print(f"Message: {message}")Online Tools
| Tool | URL | Notes |
|---|---|---|
| Aperisolve | aperisolve.com | Best all-in-one: runs zsteg, strings, binwalk, exiftool |
| StegOnline | stegonline.georgeom.net | Browser-based bit plane viewer + LSB extraction |
| FotoForensics | fotoforensics.com | Error Level Analysis (ELA) for JPEG |
Checklist
-
file+exiftool+strings→ basic identification -
binwalk -e→ embedded files? -
zsteg suspicious.png→ automated LSB scan -
zsteg -a suspicious.png→ try ALL combinations -
steghide extract -sf suspicious.jpg -p ""→ blank password -
stegseek suspicious.jpg rockyou.txt→ crack steghide password - Open in Stegsolve → browse bit planes visually
- Upload to Aperisolve → automated multi-tool analysis
- Python extraction → try all channel/bit combinations manually
- Check alpha channel (RGBA) separately
- Try column-order scanning (not just row-order)
- Look for 2-bit or 3-bit LSB hiding
Last updated on