Writeups
Search…
One Line Crypto
bruteforce X using m counting down
1
candidates = set()
2
3
x = 1
4
m = 160
5
while True:
6
while (x**(m+1) - (x+1)**m).bit_length() < 1023:
7
x += 1
8
while (num := x**(m+1) - (x+1)**m).bit_length() < 1026:
9
if isPrime(num):
10
for i in candidates:
11
if min(i, num) < max(i, num) < min(i, num) << 3 and (i*num).bit_length() == 2048:
12
phi = (i-1)*(num-1)
13
d = inverse(0x10001, phi)
14
pt = pow(flag, d, i*num)
15
try:
16
print(long_to_bytes(pt).decode())
17
quit()
18
except Exception:
19
pass
20
candidates.add(num)
21
x += 1
22
m -= 1
Copied!
Last modified 1yr ago
Export as PDF
Copy link