蓝桥杯决赛2023 RE CyberChef2

思路很清晰,爆IV

但是题目出的有点屎,六位字符串,62的6次方,要我爆到猴年马月?

就当练习脚本吧

python 复制代码
#Cyber2 wp
from Crypto.Cipher import DES, AES  
from Crypto.Util.Padding import pad, unpad  
  
key_des = b'0a0b0c0d'  # DES key must be 8 bytes long  
#print(key_des)
cipher = bytes.fromhex("416935cabeb8e30cd9b56db3aa6778fa25ad5c3a5105d1c6aad4cba5f109f18afeaf5edcb8fd4e80aca82d75b42d751c40337f08df6c5231140b8c0b947362812df3dd5b5666447043240728a23da1da5cb4c7b197523b960106960cdcb6d48578667aae17caf1cb") 
#print(cipher)
import string
import itertools

table=string.ascii_letters+string.digits
#print(table)
for i in itertools.product(table,repeat = 6):
    x=''.join(i).encode()
    iv = "01" + x.decode()
    #print(iv)
    # Decryption  
    decipher_des = DES.new(key_des, DES.MODE_CBC, (str(iv).zfill(8)).encode('utf-8'))  
    decryptedtext_des = unpad(decipher_des.decrypt(cipher), DES.block_size)  
    #print(decryptedtext_des)
    key_aes = b'0102030405060708'  # AES key must be 16, 24, or 32 bytes long  
    cipher_aes = pad(decryptedtext_des, AES.block_size)
    # Note: You must also store the initialization vector (IV) for decryption  
    iv_aes = b'0807060504030201'
    # Decryption 
    decipher_aes = AES.new(key_aes, AES.MODE_CBC, iv=iv_aes)  
    decryptedtext_aes = pad(decipher_aes.decrypt(cipher_aes), AES.block_size)  
    if (decryptedtext_aes.startswith(b"flag{")) & (decryptedtext_aes.endswith(b"}")):  
        print(decryptedtext_aes)  
    else:  
        continue 

print("end")
相关推荐
Zzj_tju3 分钟前
Java 从入门到精通(六):抽象类与接口到底怎么选?
java·开发语言
2401_879693871 小时前
Python深度学习入门:TensorFlow 2.0/Keras实战
jvm·数据库·python
@PHARAOH1 小时前
HOW - Go 开发入门(一)
开发语言·后端·golang
xixihaha13247 小时前
将Python Web应用部署到服务器(Docker + Nginx)
jvm·数据库·python
xixihaha13248 小时前
Python游戏中的碰撞检测实现
jvm·数据库·python
myloveasuka8 小时前
Java与C++多态访问成员变量/方法 对比
java·开发语言·c++
2301_821700538 小时前
C++编译期多态实现
开发语言·c++·算法
奥地利落榜美术生灬8 小时前
c++ 锁相关(mutex 等)
开发语言·c++
xixihaha13248 小时前
C++与FPGA协同设计
开发语言·c++·算法
重庆小透明8 小时前
【java基础篇】详解BigDecimal
java·开发语言