考点CRC 校验图片宽高篡改隐写解压缩看到一张图片遇到图片第一时间放进010里看看有没有线索——直接看到有个提示由此猜测是图片高宽被篡改导致CRC校验出错。放个脚本先import binascii import struct # 1. 读取PNG文件这里替换成你的图片路径 file_path rF:\网络攻防\CTF\脚本\\flag.png try: with open(file_path, rb) as f: png_data f.read() except Exception as e: print(f文件读取失败{e}) exit() # 2. 提取IHDR块的核心数据严格遵循PNG规范 # PNG文件头8字节 4字节长度 12字节12-16是IHDR类型IHDR ihdr_type png_data[12:16] # 16-29是IHDR的13字节核心数据4字节宽 4字节高 5字节固定字段 fixed_data png_data[24:29] # 5字节固定字段位深、颜色类型等不可修改 # 29-33是IHDR块末尾存储的目标CRC值出题人留下的正确CRC target_crc struct.unpack(I, png_data[29:33])[0] # 3. 打印校验信息确认读取正确 current_ihdr ihdr_type png_data[16:29] current_crc binascii.crc32(current_ihdr) 0xffffffff print(f当前IHDR的CRC值{hex(current_crc)}) print(f文件里存储的目标CRC{hex(target_crc)}) if current_crc target_crc: print(⚠️ 注意当前图片的宽高和CRC已经匹配若图片显示不全可能是宽高本身就是正确的或CRC也被篡改了) else: print(✅ 检测到宽高与CRC不匹配开始爆破正确宽高...) # 4. 爆破宽高可根据需要扩大范围比如range(8000) max_size 8000 correct_width None correct_height None for width in range(max_size): for height in range(max_size): # 拼接IHDR的校验数据类型 新宽度 新高度 固定字段 new_ihdr ihdr_type struct.pack(I, width) struct.pack(I, height) fixed_data # 计算CRC32 calc_crc binascii.crc32(new_ihdr) 0xffffffff # 匹配目标CRC if calc_crc target_crc: correct_width width correct_height height print(f\n✅ 找到正确宽高) print(f十进制宽 {correct_width}高 {correct_height}) print(f十六进制宽 {hex(correct_width)}高 {hex(correct_height)}) # 找到后直接退出循环 break if correct_width is not None: break # 5. 结果输出 if correct_width is None: print(f\n❌ 未找到匹配的宽高请尝试扩大max_size的范围当前{max_size}或检查图片是否损坏) else: print(f\n 操作提示用010editor打开图片把IHDR块里的高度字段修改为 {hex(correct_height)} 对应的十六进制值大端序补零到4字节保存后即可查看完整图片)去到010里面进行修改它提示是chunk[0]所以点开对应的就行修改完成保存退出看到flag