蓝桥杯决赛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")
相关推荐
沙白猿12 小时前
【TJXT】Day3
java·开发语言
长安牧笛12 小时前
让车学会耍赖式安全停车,危险时优先靠边停车,不是硬刹,颠覆紧急制动逻辑,输出平稳停车。
python·编程语言
Loo国昌12 小时前
【AI应用开发实战】05_GraphRAG:知识图谱增强检索实战
人工智能·后端·python·语言模型·自然语言处理·金融·知识图谱
一个处女座的程序猿O(∩_∩)O12 小时前
Python面向对象的封装特性详解
开发语言·python
zhaoyin199412 小时前
python基础
开发语言·python
Joker Zxc12 小时前
【前端基础(Javascript部分)】2、JavaScript的变量和数据类型
开发语言·前端·javascript
罗超驿12 小时前
JavaSE高频答疑:内部类同名变量访问全解 + Comparable与Comparator核心区别
java·开发语言·idea
宇木灵12 小时前
C语言基础-十一、递归与分治(完结)
c语言·开发语言·学习·算法
geovindu13 小时前
python: Template Method Pattern
开发语言·python·设计模式·模板方法模式
sycmancia13 小时前
C++——析构函数的调用顺序、const修饰对象、类成员
开发语言·c++