from Crypto.Util.number import * from secret import FLAG p = getPrime(128) step = len(FLAG) // 3 xs = [bytes_to_long(FLAG[:step]), bytes_to_long(FLAG[step:2*step]), bytes_to_long(FLAG[2*step:])] a = getPrime(64) b = getPrime(64) c = getPrime(64) a = 18038175596386287827 b = 15503291946093443851 c = 17270168560153510007 p = 307956849617421078439840909609638388517
from Crypto.Util.number import * from secret import FLAG p = getPrime(128) step = len(FLAG) // 3 xs = [bytes_to_long(FLAG[:step]), bytes_to_long(FLAG[step:2*step]), bytes_to_long(FLAG[2*step:])]
这一步将flag分成三等份,由bytes_to_long转换位数字,用于加密计算。
1 2 3 4 5 6 7
a = getPrime(64) b = getPrime(64) c = getPrime(64) a = 18038175596386287827 b = 15503291946093443851 c = 17270168560153510007 p = 307956849617421078439840909609638388517
给出a、b、c、p的数值
1 2 3
for _ inrange(10): new_state = (a*xs[0] + b*xs[1] + c*xs[2]) % p xs = xs[1:] + [new_state]