Rating: 1.0

一文字ずつ順に復号していきます.

```py
import random
import string

def encrypt(x, cnt):
def do_thing(a, b):
return ((a << 1) & b) ^ ((a << 1) | b)

if len(x) != 25:
print("WRONG!!!!!")
else:
random.seed(997)
k = [random.randint(0, 256) for _ in range(len(x))]
a = { b: do_thing(ord(c), d) for (b, c), d in zip(enumerate(x), k) }
b = list(range(len(x)))
random.shuffle(b)
c = [a[i] for i in b[::-1]]
kn = [47, 123, 113, 232, 118, 98, 183, 183, 77, 64, 218, 223, 232, 82, 16, 72, 68, 191, 54, 116, 38, 151, 174, 234, 127]
valid = len(list(filter(lambda s: kn[s[0]] == s[1], enumerate(c))))
return valid==cnt+1
if valid == len(x):
print("Password is correct! Flag:", x)
else:
print("WRONG!!!!!!")

pw = ['#']*25

for i in range(25):
for c in "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!\"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~":
pw[i]=c
if encrypt(''.join(pw), i):
break
print(''.join(pw))
```

```sh
M########################
Me#######################
Met######################
Meta#####################
MetaC####################
MetaCT###################
MetaCTF##################
MetaCTF{#################
MetaCTF{y################
MetaCTF{yO###############
MetaCTF{yOu##############
MetaCTF{yOu_#############
MetaCTF{yOu_w############
MetaCTF{yOu_w!###########
MetaCTF{yOu_w!N##########
MetaCTF{yOu_w!N_#########
MetaCTF{yOu_w!N_t########
MetaCTF{yOu_w!N_th#######
MetaCTF{yOu_w!N_th1######
MetaCTF{yOu_w!N_th1$#####
MetaCTF{yOu_w!N_th1$_####
MetaCTF{yOu_w!N_th1$_0###
MetaCTF{yOu_w!N_th1$_0n##
MetaCTF{yOu_w!N_th1$_0n3#
MetaCTF{yOu_w!N_th1$_0n3}
```