f = open('info.csv', 'r') l0 = [int(i) for i in f.readline().split(',')[1:]] l1 = [int(i) for i in f.readline().split(',')[1:]] l2 = [int(i) for i in f.readline().split(',')[1:]] l3 = [int(i) for i in f.readline().split(',')[1:]] l4 = [int(i) for i in f.readline().split(',')[1:]] k = '' for i inrange(3000): if l1[i] + l2[i] + l3[i] + l4[i] == 1: if (l0[i] == 1or l0[i] == 2) and (l1[i] != 1and l2[i] != 1): continue elif (l0[i] == 3or l0[i] == 4) and (l3[i] != 1and l4[i] != 1): continue elif l0[i] == 1or l0[i] == 3: k += '0' elif l0[i] == 2or l0[i] == 4: k += '1' else: exit(0)
print(k) m = len(k) print(len(k)) a = 1709 b = 2003 x = 17 k1 = '' for i inrange(336): k1 += k[x] x = (x*a+b)%m print(k1) k1 = int(k1,2) print(k1) c = m = k1^c from Crypto.Util.number import * print(long_to_bytes(m))
badKey1
定位到唯一有可能会出问题的代码:
1 2 3
if Integer(n).gcd(d) != 1: raise ValueError("RSA private exponent is not coprime to modulus") # Modulus must be product of 2 primes
e = 65537 whileTrue: q = getPrime(512) for k2 inrange(e): x = (q-1)*k2 x %= e if x == 0: continue if ((q-1)*k2-1) % x == 0: p = ((q-1)*k2-1)//x if isPrime(p) and p.bit_length()==512: print(p,q) break