D^3CTF

d3noisy

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
from Crypto.Util.number import *
import gmpy2
with open('out.txt') as f:
n=int(f.readline()[4:])
p=eval(f.readline()[4:])
s=eval(f.readline()[4:])
c=eval(f.readline()[4:])

P0=1
L=[]
for i in p:
P0=P0*i
print(P0)

for i in range(15):
t=inverse(P0//p[i],p[i])
L.append(t*(P0//p[i]))

B=getPrime(3211)
M=matrix(ZZ,15*15+1,15*15+1)
for i in range(15):
for j in range(15):
t=i*15+j
M[t+1,t+1]=B
M[t+1,0]=s[i][j]*L[i]
M[0,0]=P0
x=M.LLL()
print("LLL done")
d=0
for i in range(15):
d =(d ^^ int(x[i][0]))
d = gmpy2.next_prime(int(d))
print(d)
print(long_to_bytes(pow(c,d,n)))
# antd3ctf{0c85f77e-bfee-da57-78f2-e961ffd4ca45}

D^3CTF
https://sch01ar.github.io/2023/05/07/d3ctf2023/
作者
Roo1e
发布于
2023年5月7日
许可协议