BUUCTF:[羊城杯 2020]signin

https://buuoj.cn/challenges#[%E7%BE%8A%E5%9F%8E%E6%9D%AF%202020]signin

在这里插入图片描述
signin.txt

BCEHACEIBDEIBDEHBDEHADEIACEGACFIBDFHACEGBCEHBCFIBDEGBDEGADFGBDEHBDEGBDFHBCEGACFIBCFGADEIADEIADFH

Toy Cipher: https://eprint.iacr.org/2020/301.pdf
在这里插入图片描述
先将密文四个一组对照第二张表转换,简单Python处理

cipherdic = {'M':'ACEG','R':'ADEG','K':'BCEG','S':'BDEG','A':'ACEH','B':'ADEH','L':'BCEH','U':'BDEH','D':'ACEI','C':'ADEI','N':'BCEI','V':'BDEI','H':'ACFG','F':'ADFG','O':'BCFG','W':'BDFG','T':'ACFH','G':'ADFH','P':'BCFH','X':'BDFH','E':'ACFI','I':'ADFI','Q':'BCFI','Y':'BDFI'}
ciphertext = ''
with open('signin.txt','r') as f:
    f = f.read()
    for i in range(0,len(f),4):
        block = f[i:i+4]
        for j in cipherdic:
            if block == cipherdic[j]:
                ciphertext += j
                #print('{}: {}'.format(block,j))
print(ciphertext)

得到如下字符

LDVUUCMEXMLQSSFUSXKEOCCG

再按照提示的意思,将第二张表倒序排列,再对比一次

ciphertext = 'LDVUUCMEXMLQSSFUSXKEOCCG'

original_list = ['M','R','K','S','A','B','L','U','D','C','N','V','H','F','O','W','T','G','P','X','E','I','Q','Y']
reversed_list = original_list[::-1]

flag = ''
for char in ciphertext:
    for olist in original_list:
        if char == olist:
            oindex = original_list.index(olist)
            flag += reversed_list[oindex]

flag = flag.replace('GWHT','GWHT{')
flag = flag.replace('COOL','COOL}')
print(flag)

在这里插入图片描述

flag{TOYSAYGREENTEAISCOOL}
相关推荐
©️2020 CSDN 皮肤主题: 撸撸猫 设计师:马嘣嘣 返回首页