0%

[CyBRICS 2019]Fast Crypto m0feng的WriteUp

2023-07-07 06:42By
m0feng
Crypto
from tqdm import *

#在线网站就可以分解了
phi=1
s=[1123 , 1931 , 2027 , 5347 , 6143 , 8419 , 9091 , 9151 , 9187 , 9719 , 11027 , 11731 , 12739 , 12967 , 14923 , 17623 , 17971 , 18367 , 18947 , 19207 , 19739 , 20051 , 20431 , 21139 , 21179 , 22283 , 23971 , 24379 , 24391 , 25643 , 25679 , 26347 , 26959 , 27743 , 28151 , 28867 , 29663 , 30539 , 32251 , 33827 , 34871 , 35107 , 35831 , 37307 , 37987 , 38371 , 39499 , 42391 , 43223 , 44123 , 45587 , 45979 , 46723 , 47431 , 48311 , 49363 , 49451 , 49871 , 50683 , 50707 , 52919 , 53759 , 53987 , 56263 , 58271 , 58727 , 61603 , 61627 , 62423 , 63331 , 65167 , 65407]

for i in s:
    phi*=(i-1)
print(phi)
# power**O = k*phi +b

def get_next(a, power, N):
    b =pow(a,power,N)
    return b, b % 256

formal=[0x52 ,0x49 ,0x46 ,0x46]     #翻一下wav文件的前四位特征位
now=[0x46 ,0x83 ,0x49 ,0x44]        #ida64

N=73882271767225067628282422302548400069735434660808564149855701357643617388546710750167259617348302921921308565033188464703728096338599435641707966042336489111486646451993143053931136428343207443971020988133537590763029595507074481482058514976650388077801669364711731111970923913958083815347282871017052613916475670517
O= 31337
"""                  爆破 
x=True                 
for power in range(2,16):
    for j in tqdm(range(1,2**16)):
        seed = j
        b=pow(power,O,phi)
        x=True
        seed=pow(seed,b,N)
        for i in range(4):
            seed, bt = get_next(seed, power, N)
            if(bt != formal[i]^now[i]):
                x=False
                break
        if(x):
            print(power,j)
            exit(0)
"""

power=7
seed0=4485
b = pow(power, O, phi)
seed = pow(seed0, b, N)

with open("enc.wav",'rb') as f:            #解密
    data=f.read()
    with open("dec.wav",'wb') as o:
        for i in tqdm(range(len(data))):
            seed, bt = get_next(seed, power, N)
            o.write(bytes([data[i] ^ bt]))

然后就是语言识别,尝试flag。(字符都是小写的

还没有人赞赏,快来当第一个赞赏的人吧!
  
© 著作权归作者所有

加载中...

加载失败
广告
×
评论区
添加新评论