攻防世界-密碼學-ecb,_it’s_easy_as_123


1. 題目信息

附件提供了背景介紹(Somebody leaked a still from the upcoming Happy Feet Three movie, which will be released in 4K, but Warner Bros. was smart enough to encrypt it. But those idiots used a black and white bmp format, and that wasn't their biggest mistake. Show 'em who's boss and get the flag.),與一個bmp文件。

2. 分析

根據背景介紹,原圖片應該是bmp格式,經ecb工作模式加密得ecb.bmp;由於ecb工作模式不會掩蓋明文的統計規律,因此只要能夠修復ecb.bmp就可以見到明文,要修復ecb.bmp,則要求文件的前128字節為bmp文件格式特有的字節。

3. 解題

將ecb.bmp的前128字節替換為bmp文件格式特有的字節,則可以見到明文信息,實現的Python腳本如下:

from Crypto.Util.number import long_to_bytes

with open('ecb.bmp','rb') as f:
    data=f.read()
pre=0x424d76483f00000000007600000028000000000f000070080000010004000000000000483f00000000000000000000000000000000000000000000008000008000000080800080000000800080008080000080808000c0c0c0000000ff0000ff000000ffff00ff000000ff00ff00ffff0000ffffff00ffffffffffffffffffffL
out=long_to_bytes(pre)+data[128:]

with open('out.bmp','wb') as g:
    g.write(out)

out.bmp可被照片查看器打開,從而見到flag。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM