蓝桥杯决赛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")
相关推荐
ThreeYear_s12 分钟前
【FPGA+DSP系列】——MATLAB simulink仿真三相桥式全控整流电路
开发语言·matlab·fpga开发
yugi98783814 分钟前
MATLAB实现白噪声与色噪声仿真
开发语言·matlab
面向星辰31 分钟前
机器学习过拟合和正则化
python
似水এ᭄往昔33 分钟前
【C++】--模板进阶
开发语言·c++
浔川python社37 分钟前
《Python 小程序编写系列》(第三部):简易文件批量重命名工具
python·小程序·apache
QD.Joker1 小时前
高德MCP服务接入
python
孤客网络科技工作室1 小时前
孤客截图工具 Pro - 从开发到打包的完整指南
python
Q_Q19632884751 小时前
python+django/flask的医院财务管理系统
spring boot·python·django·flask·node.js
yue0081 小时前
C# 求取整数的阶乘
java·开发语言·c#
herogus丶1 小时前
【LLM】LLaMA-Factory 训练模型入门指南
python·ai编程·llama