【CTF-crypto-维吉尼亚密码】变种题

【CTF-crypto-维吉尼亚密码】变种题

题目


密码表:

a b c d e f g h i j k l m n o p q r s t uvw x y z{}a a b c d e f g h i j k l m n o p q r s t uvw x y z{}b b c d e f g h i j k l m n o p q r s t uvw x y z{}a c c d e f g h i j k l m n o p q r s t uvw x y z{}a b d d e f g h i j k l m n o p q r s t uvw x y z{}a b c e e f g h i j k l m n o p q r s t uvw x y z{}a b c d f f g h i j k l m n o p q r s t uvw x y z{}a b c d e g g h i j k l m n o p q r s t uvw x y z{}a b c d e f h h i j k l m n o p q r s t uvw x y z{}a b c d e f g i i j k l m n o p q r s t uvw x y z{}a b c d e f g h j j k l m n o p q r s t uvw x y z{}a b c d e f g h i k k l m n o p q r s t uvw x y z{}a b c d e f g h i j l l m n o p q r s t uvw x y z{}a b c d e f g h i j k m m n o p q r s t uvw x y z{}a b c d e f g h i j k l n n o p q r s t uvw x y z{}a b c d e f g h i j k l m o o p q r s t uvw x y z{}a b c d e f g h i j k l m n p p q r s t uvw x y z{}a b c d e f g h i j k l m n o q q r s t uvw x y z{}a b c d e f g h i j k l m n o p r r s t uvw x y z{}a b c d e f g h i j k l m n o p q s s t uvw x y z{}a b c d e f g h i j k l m n o p q r t t uvw x y z{}a b c d e f g h i j k l m n o p q r s u uvw x y z{}a b c d e f g h i j k l m n o p q r s tvvw x y z{}a b c d e f g h i j k l m n o p q r s t u w w x y z{}a b c d e f g h i j k l m n o p q r s t uvx x y z{}a b c d e f g h i j k l m n o p q r s t uvw y y z{}a b c d e f g h i j k l m n o p q r s t uvw x z z{}a b c d e f g h i j k l m n o p q r s t uvw x y{{}a b c d e f g h i j k l m n o p q r s t uvw x y z}}a b c d e f g h i j k l m n o p q r s t uvw x y z{

加密脚本:

importstringfromsecretimportflagfromsecretimportencryptimportrandom dicts=string.ascii_lowercase+"{}"key=(''.join([random.choice(dicts)foriinrange(4)]))*8assert(len(flag)==32)assert(len(key)==32)cipher=encrypt(flag,key)print(cipher)# tsejk}gbxyiutfchpm}ylm}a}amuxlmg

解密

密码字典dicts

dicts=string.ascii_lowercase+"{}"

创建包含所有小写字母和花括号的字符串
dicts为:abcdefghijklmnopqrstuvwxyz{}

生成密钥

key = (‘’.join([random.choice(dicts) for i in range(4)])) * 8

标识四个字符被用了8遍,如a19e被使用八遍,则为:a19ea19ea19ea19ea19ea19ea19ea19e,这就是密钥

根据其他题目答案,猜测前7个明文为:ayyctf{

由于前五个密文为:tsejk}g,假设明文为ayyctf{

猜测第一个密钥为:j

猜测第二个密钥为:g

猜测第三个密钥为:u

猜测第四个密钥为:v

从密码表中,推断4位密钥:jguv
完整密钥: jguvjguvjguvjguvjguvjguvjguvjguv

计算明文

ayyctf{wecanalwaystrustvigenere}