下载附件得到py代码:

#As a freshman starting in 2024, you should know something about XOR, so this task is for you to sign in.

from pwn import xor

#The Python pwntools library has a convenient xor() function that can XOR together data of different types and lengths

from Crypto.Util.number import bytes_to_long

key = b’New_Star_CTF’

flag=’flag{*******************}’

m1 = bytes_to_long(bytes(flag[:13], encoding=’utf-8′))

m2 = flag[13:]

c1 = m1 ^ bytes_to_long(key)

c2 = xor(key, m2)

print(‘c1=’,c1)

print(‘c2=’,c2)

”’

c1= 8091799978721254458294926060841

c2= b’;:\x1c1<\x03>*\x10\x11u;’

”’

首先,我们需要把给定的c1key进行XOR运算,来还原m1,也就是flag的前13个字符(包括'{‘和前面的字符)。然后,我们再用keyc2进行XOR运算,来还原m2,也就是flag剩下的字符。

接下来是解密脚本:

from pwn import xor  

from Crypto.Util.number import bytes_to_long, long_to_bytes  

key = b’New_Star_CTF’  

c1 = 8091799978721254458294926060841  

c2 = b’;:\x1c1<\x03>*\x10\x11u;’  

m1 = c1 ^ bytes_to_long(key)  

flag_start = long_to_bytes(m1).decode(‘utf-8’)  

m2 = xor(key, c2)  

flag_end = m2.decode(‘utf-8’)

flag = flag_start + flag_end  

print(flag)

admin

By admin

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注