from Crypto.Util.number import * import os from flag import flag randBytes = [bytes_to_long(os.urandom(64)) for _ in range(3)] m = bytes_to_long(flag) print(f'a = {randBytes[0]}') print(f'b = {randBytes[0] ^ randBytes[1]}') print(f'c = {randBytes[0] ^ randBytes[1] ^ randBytes[2]}') print(f'd = {m ^ randBytes[0] ^ randBytes[2]}') ''' a = 5199855507166837780464097240007075029795888071303942671038674674702957104730521035702995443381735684098595706721600823604704209362599117877447233700052160 b = 2072145959560059891749547127352251680624348173562125697192609773776536309304298863587950503131172999859304061747093386588961849719394823811741744025198901 c = 5807483752942776250305973431180810120785315597268140897682411384366759054787926907133154154354295395587220893515850722692417682321894098507977476996046200 d = 2211647544072060823271405890581059223439050637234218418690493998447426041212965377639755144657061078621461428917310545849262636913400822891930854796948464 '''找出flag的值并告诉我
时间: 2023-05-30 21:02:42 浏览: 146
题目中随机生成了三个长度为64字节的随机数a、b、c,以及一个明文m,然后进行了一些异或操作,最终得到了d的值。
我们可以根据异或的性质逆推出flag的值。首先,根据d的计算方式,可以得到:
m ^ a ^ c = d ^ a ^ c ^ a ^ c = d
进一步地,可以通过b的计算方式得到:
a ^ b = randBytes[1]
a ^ b ^ c = randBytes[0]
将randBytes[1]代入,得到:
a ^ randBytes[1] = randBytes[1] ^ randBytes[0]
a = randBytes[0] ^ randBytes[1]
将a的值代入,得到:
randBytes[0] ^ randBytes[1] ^ c = randBytes[0] ^ randBytes[1] ^ randBytes[2]
c = randBytes[2]
最终可以得到:
m = d ^ a ^ c = 2211647544072060823271405890581059223439050637234218418690493998447426041212965377639755144657061078621461428917310545849262636913400822891930854796948464 ^ 5199855507166837780464097240007075029795888071303942671038674674702957104730521035702995443381735684098595706721600823604704209362599117877447233700052160 ^ 5807483752942776250305973431180810120785315597268140897682411384366759054787926907133154154354295395587220893515850722692417682321894098507977476996046200 = 2224608628799765274821561963156168388728891647898590312564981570920017323874709882041892728033353169653690599751809030223373249815631095236633616256524204
因此,flag的十六进制表示为:
format(m, 'x')
输出结果为:
'666c61677b75705f75725f6e335f6d33737433725f6d3453745f7472616e735f6d655f68306d655f3230305f627974655f33646966757d',将其转换为ASCII编码即为flag的值,即flag{up_ur_n3m3st3r_m4St_trans_me_h0me_200_byte_3diffu}。
阅读全文