检测并恢复受 CVE-2023-28303 影响的 Windows 截图工具 PNG 截图
SnipRecover CLI 是一款极简、无依赖的命令行工具,旨在:
检测 因 Windows 截图工具漏洞(CVE‑2023‑28303)而被修改的 PNG 文件。
恢复 原始图像,通过恢复附加在 IEND 块之后的压缩数据。
默认情况下,恢复后的图像使用 RGBA,分辨率为 1920×1080;如果未指定输出路径,工具将写入 restored-<original_name>.png。
根据 PNG 规范(ISO/IEC 15948),所有图像数据(IDAT 块)都必须出现在最终 IEND 块之前。Windows 截图工具错误地将额外的 IDAT 数据附加在 IEND 之后,违反了该标准,并暴露了被“裁剪”掉的完整图像内容。
标准 PNG 结构:
签名(8 字节): 89 50 4E 47 0D 0A 1A 0A
块:
IHDR:图像头(宽度、高度、颜色类型等)
IDAT:压缩的像素数据
IEND:文件结束标记
被截图工具裁剪过的 PNG 在 IEND 之后含有额外字节。SnipRecover CLI 会检测此异常,并重建压缩流以恢复原始图像。
前提条件:
步骤:
git clone https://github.com/m31r0n/SnipRecover-CLI.git
cd SnipRecover-CLI
chmod +x sniprecover
无需任何外部库——仅使用 Python 标准库中的 _struct_、_zlib__ 和_ _io_ 模块。
# Display help
python3 sniprecover --help
# 1. Detect vulnerable PNG(s)
python3 sniprecover detect /path/to/images/
# 2. Restore a cropped capture
python3 sniprecover restore capture.png --output restored-capture.png
注意: 如果省略
--width、--height或--alpha,将应用默认值 1920×1080 和 RGBA。如果省略--output,恢复后的图像将保存为restored-<original_name>.png。
SnipRecover-CLI/
├── sniprecover # Main CLI executable (make sure it's executable)
└── README.md # Documentation and theory
CVE‑2023‑28303:Windows 截图工具漏洞 – Microsoft Security Response Center
PNG 规范(ISO/IEC 15948)– W3C
MIT © 2025 – 由 m31r0n 开发
| Option | 说明 | 默认值 |
|---|
--width <int> | 原始图像宽度 | 1920 |
--height <int> | 原始图像高度 | 1080 |
--alpha | 包含 alpha 通道(RGBA) | 启用 |
--output <file> | 保存恢复后 PNG 的路径 | restored-<original_name>.png |