MISC圖片批量處理jio本
阿新 • • 發佈:2021-10-07
此處以ctfshow中MISC入門題目作為切入點
感興趣的同學可以一邊做題一邊參照
- 批量修改PNG圖片的寬
import zlib import struct filename = "flag.png" with open(filename, 'rb') as f: all_b = f.read() #w = all_b[16:20] #h = all_b[20:24] for i in range(901, 1200): name = str(i) + ".png" f1 = open(name, "wb") im = all_b[:16] + struct.pack('>i', i) + all_b[20:] f1.write(im) f1.close()
- 批量修改JPG圖片的寬
import zlib import struct filename = "flag.jpg" with open(filename, 'rb') as f: all_b = f.read() #w = all_b[159:161] #h = all_b[157:159] for i in range(901, 1200): name = str(i) + ".jpg" f1 = open(name, "wb") im = all_b[:159] + struct.pack('>i', i) + all_b[161:] f1.write(im) f1.close()
- 批量修改GIF圖片的寬
import zlib import struct filename = "flag.gif" with open(filename, 'rb') as f: all_b = f.read() #w = all_b[38:40] #h = all_b[36:38] for i in range(901, 1200): name = str(i) + ".gif" f1 = open(name, "wb") im = all_b[:38] + struct.pack('>i', i) + all_b[40:] f1.write(im) f1.close()