# wznqca{d4uqop0fk_q1nwofDbzg_eu}
import re
import string
origin_str='wznqca{d4uqop0fk_q1nwofDbzg_eu}'
res=re.findall('[a-z]',origin_str,re.I)
print(''.join(res),len(res))
# wznqcad4uqop0fkq1nwofDbzgeu ,len=27
# utflag
from z3 import *
x1,y1,x2,y2=Ints('x1 y1 x2 y2')
cipher=[]
plain=[]
for _1,_2 in zip('wznqca','utflag') :
cipher.append(string.ascii_letters.index(_1) )
plain.append(string.ascii_letters.index(_2))
print(cipher,plain)
ret=solve(-1<x1,x1<27,-1<x2,x2<27,-1<y1,y1<27,-1<y2,y2<27,(x1*cipher[0]+y1*cipher[1])%26==20,
(x2*cipher[0]+y2*cipher[1])%26==19,
(x1*cipher[2]+y1*cipher[3])%26==5,
(x2*cipher[2]+y2*cipher[3])%26==11)
y1 = 6
y2 = 21
x1 = 13
x2 = 3
# x1,y1= 13,6
# x2,y2= 3,21
pos=[]
decrypt=[]
# res='wznqcaduqopfkqnwofDbzgeu'
def str_index(chr1):
return string.ascii_letters.index(chr1)
for each in range(0,len(res),2):
if res[each].isupper(): #can only deal with one upper
pos.append(each)
if res[each+1].isupper():
pos.append(each+1)
decrypt.append(string.ascii_letters[(str_index(res[each])*x1+str_index(res[each+1])*y1)%26])
decrypt.append(string.ascii_letters[(str_index(res[each])*x2+str_index(res[each+1])*y2)%26])
print(decrypt)
for each in pos:
decrypt[each]=decrypt[each].upper()
# flag{d4nger0us_c1pherText_qq}
res=re.sub('[a-zA-Z]',lambda M:decrypt.pop(0),origin_str)
print(res)
07-19
1668
07-30
1740
10-15
366
07-27
674