CSAW CTF Qualification Round 2013 Misc 200 deadbeef

0x00 题目

IMG_0707.png

0x01 解题

下载图片能在Windows上能成功浏览图片:

IMG_0707.gif

但是当在Linux打开却发现CRC error:

CSAW CTF Qualification Round 2013 Misc 200 deadbeef crc error.gif

使用PNGDebugger检查图片CRC

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
C:\png-debugger-master\Debug>PNGDebugger.exe IMG_0707.png
----
file-path=IMG_0707.png
file-size=6214620 bytes
0x00000000 png-signature=0x89504E470D0A1A0A
0x00000008 chunk-length=0x0000000D (13)
0x0000000C chunk-type='IHDR'
0x00000010 width=0x00000CC0 (3264)
0x00000014 height=0x00000691 (1681)
0x00000018 bit-depth=8
0x00000019 color-type=6 (truecolour with alpha)
0x0000001A compression-method=0 (deflate/inflate)
0x0000001B filter-method=0 (adaptive)
0x0000001C interlace-method=0 (standard)
0x0000001D crc-code=0xC1D0B3E4
>> (CRC CHECK) crc-computed=0xFCC410A8 => CRC FAILED
...

参考资料:PNG文件结构分析
发现图片的IHDR(文件头数据块)的CRC(循环冗余检测)不对,而其他的数据块的CRC都是正确的,根据题目意思推测:原本的CRC应该是0xC1D0B3E4,但是可能修改IHDR里的某个域的值导致计算出CRC为0xFCC410A8,从而导致校对失败。

CSAW CTF Qualification Round 2013 Misc 200 deadbeef IHDR.gif

综合下来,推测最有可能修改的域应该就是宽度和高度,之后通过exiftool又了解了一些exif信息

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
E:\exiftool-10.25>"exiftool(-k).exe" IMG_0707.png
ExifTool Version Number : 10.25
File Name : IMG_0707.png
Directory : .
File Size : 5.9 MB
File Modification Date/Time : 2016:08:17 12:46:20+08:00
File Access Date/Time : 2016:08:17 19:04:02+08:00
File Creation Date/Time : 2016:08:17 19:04:02+08:00
File Permissions : rw-rw-rw-
File Type : PNG
File Type Extension : png
MIME Type : image/png
Image Width : 3264
Image Height : 1681
Bit Depth : 8
Color Type : RGB with Alpha
Compression : Deflate/Inflate
Filter : Adaptive
Interlace : Noninterlaced
SRGB Rendering : Perceptual
Gamma : 2.2
Pixels Per Unit X : 2835
Pixels Per Unit Y : 2835
Pixel Units : meters
Source : iPhone 5
Software : 6.1.4
Modify Date : 2013:09:10 22:03:32
Creation Time : 2013:09:10 22:03:32
Image Size : 3264x1681
Megapixels : 5.5

得知可能是由iPhone 5手机拍摄,然后通过搜索发现iPhone 5拍摄默认分辨率为3264×2448,也就是可能修改了图片的高度,所以试着修改图片高度:

CSAW CTF Qualification Round 2013 Misc 200 deadbeef original.gif

题图给出的高度是1681(0x00000691),修改为2448(0x00000990)
CSAW CTF Qualification Round 2013 Misc 200 deadbeef modified.gif

之后再用PNGDebugger检测图片CRC:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
C:\png-debugger\Debug>PNGDebugger.exe --verbose solved.png
----
file-path=solved.png
file-size=6214620 bytes
0x00000000 png-signature=0x89504E470D0A1A0A
0x00000008 chunk-length=0x0000000D (13)
0x0000000C chunk-type='IHDR'
0x00000010 width=0x00000CC0 (3264)
0x00000014 height=0x00000990 (2448)
0x00000018 bit-depth=8
0x00000019 color-type=6 (truecolour with alpha)
0x0000001A compression-method=0 (deflate/inflate)
0x0000001B filter-method=0 (adaptive)
0x0000001C interlace-method=0 (standard)
0x0000001D crc-code=0xC1D0B3E4
>> (CRC CHECK) crc-computed=0xC1D0B3E4 => CRC OK!
...

现在CRC校对成功,说明图片的原始高度是2448,打开图片得到flag:

CSAW CTF Qualification Round 2013 Misc 200 deadbeef original solved.gif