Challenge
This is an encoded message, the only tip you get is ‘2 null bytes’ 这是一条编码过的消息,唯一的提示是
2 null bytes。NOTE: There is no encoding error
题目提供一个 BMP 图片文件,密码隐藏在像素数据中。
Solution
$ curl -sL -b "HackThisSite=<mission-cookie>" \ "https://www.hackthissite.org/missions/stego/lvl/1.bmp" -o 1.bmp$ file 1.bmp1.bmp: PC bitmap, Windows 3.x format, 283 x 170 x 8, image size 48280, resolution 2835 x 2835 px/m, 256 important colors, cbSize 49358, bits offset 1078这是一个 8bpp indexed BMP:
- 文件头:0–53
- 调色板:54–1077
- 像素数据:1078–49357
bfOffBits(1078)与 biSizeImage(48280)之和为 ,像素数据正好延伸到文件末尾。因此,隐藏信息位于像素数组内部,调色板和文件尾部都不是载荷位置。
像素数据中只有偏移 59 和 116 处出现连续的 00 00,两处都在 BMP 存储的第 0 行,也就是图像最底行。00 00 之间的 55 个像素字节是载荷:
16 16 17 17 17 16 16 16 16 17 17 16 16 17 17 16 16 17 17 16 17 17 17 1617 17 16 17 16 16 16 16 17 17 16 16 16 16 17 16 17 17 17 16 16 17 17 1616 17 17 16 17 17 16这 55 个字节只包含相邻的两个像素索引:0x16 和 0x17。它们分别编码 bit 0 和 1:
0x16 -> 00x17 -> 1
0011100001100110011011101101000011000010111001100110110得到的 bit 流有 55 位。前 7 位 0011100 属于第一个字节,末位补 0 后按 8 位分组:
0011100 + 0 -> 00111000 -> 800110011 -> 300110111 -> 701101000 -> h01100001 -> a01110011 -> s00110110 -> 6因此,信息具体隐藏在 BMP 像素数组的底行中,形式是两个 00 标记之间的 0x16/0x17 像素索引序列。调色板只负责把这些索引显示成灰度,解码时读取的是像素索引本身。
837has6