1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
| from Crypto.Util.number import * import sys sys.setrecursionlimit(1500)
pxorq = 47761879279815109356923025519387920397647575481870870315845640832106405230526 n = 10310021142875344535823132048350287610122830618624222175188882916320750885684668357543070611134424902255744858233485983896082731376191044874283981089774677 c = 999963120986258459742830847940927620860107164857685447047839375819380831715400110131705491405902374029088041611909274341590559275004502111124764419485191 e = 65537 leak_bits = 256 pxorq = str(bin(pxorq)[2:]).zfill(leak_bits)
def find(ph,qh,pl,ql): l = len(ph) tmp0 = ph + (leak_bits-2*l)*"0" + pl tmp1 = ph + (leak_bits-2*l)*"1" + pl tmq0 = qh + (leak_bits-2*l)*"0" + ql tmq1 = qh + (leak_bits-2*l)*"1" + ql if(int(tmp0,2)*int(tmq0,2) > n): return if(int(tmp1,2)*int(tmq1,2) < n): return if(int(pl,2)*int(ql,2) % (2**(l-1)) != n % (2**(l-1))): return
if(l == 128): pp0 = int(tmp0,2) if(n % pp0 == 0): pf = pp0 qf = n//pp0 phi = (pf-1)*(qf-1) d = inverse(e,phi) m1 = pow(c,d,n) print(long_to_bytes(m1)) exit()
else: if(pxorq[l] == "1" and pxorq[255-l] == "1"): find(ph+"1",qh+"0","1"+pl,"0"+ql) find(ph+"0",qh+"0","1"+pl,"1"+ql) find(ph+"1",qh+"1","0"+pl,"0"+ql) find(ph+"0",qh+"1","0"+pl,"1"+ql) elif(pxorq[l] == "1" and pxorq[255-l] == "0"): find(ph+"1",qh+"0","0"+pl,"0"+ql) find(ph+"0",qh+"0","0"+pl,"1"+ql) find(ph+"1",qh+"1","1"+pl,"0"+ql) find(ph+"0",qh+"1","1"+pl,"1"+ql) elif(pxorq[l] == "0" and pxorq[255-l] == "1"): find(ph+"0",qh+"0","1"+pl,"0"+ql) find(ph+"0",qh+"1","0"+pl,"0"+ql) find(ph+"1",qh+"0","1"+pl,"1"+ql) find(ph+"1",qh+"1","0"+pl,"1"+ql) elif(pxorq[l] == "0" and pxorq[255-l] == "0"): find(ph+"0",qh+"0","0"+pl,"0"+ql) find(ph+"1",qh+"0","0"+pl,"1"+ql) find(ph+"0",qh+"1","1"+pl,"0"+ql) find(ph+"1",qh+"1","1"+pl,"1"+ql)
find("1","1","1","1")
|