image.png
    以一个题为例说明记录:上面打开图片明显发现报错
    然后下面是一些需要记录的东西:
    image.png
    当前的宽高可以通过查看图片的属性得到:
    image.png

    1. import struct
    2. import zlib
    3. def hexStr2bytes(s):
    4. b = b""
    5. for i in range(0,len(s),2):
    6. temp = s[i:i+2]
    7. b +=struct.pack("B",int(temp,16))
    8. return b
    9. str1="49484452"#Chunk[0] IHDR
    10. str2="0806000000"#Bit depth、ColorType、Compression method、Filter method、Interlace method
    11. bytes1=hexStr2bytes(str1)
    12. bytes2=hexStr2bytes(str2)
    13. wid,hei = 1308,1280#当前宽高
    14. crc32 = "0x6f03ad71"#图片原来的CRC
    15. for w in range(wid,wid+2000):
    16. for h in range(hei,hei+2000):
    17. width = hex(w)[2:].rjust(8,'0')
    18. height = hex(h)[2:].rjust(8,'0')
    19. bytes_temp=hexStr2bytes(width+height)
    20. if eval(hex(zlib.crc32(bytes1+bytes_temp+bytes2))) == eval(crc32):
    21. print(hex(w),hex(h))

    image.png