-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathchecker.py
26 lines (21 loc) · 1.13 KB
/
checker.py
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
from Crypto.Util.number import getPrime
p = 176158282986746982240266723315539113194265645059289946167508170177003284015952246598622309007383783776431677319511900896550770656954421845455806488352793716430680038822335053544732829075484400828106842292496259374352682656329951651195556343598920389869481201735312755104126688354313796523263368135288804198807
target = 156068260753162326389131601053013379068481891260689073819373386976988711198991229988977057135239333025127264023815862892705566458896325300327267083685162030794665611354092408411934601042942303873251991350025956054000540414510537241391337611736612951252775259439088010202728989041330968193636085468063887251970
def f(x):
return (1 * x + 3) * pow(3 * x + 7, -1, p) % p
flag = input("Flag: ").encode()
if len(flag) != 32:
print("Bad flag")
exit()
if not flag.startswith(b"ictf{") or not flag.endswith(b"}"):
print("Bad flag")
exit()
x = int.from_bytes(flag[: len(flag) // 2], "big")
y = int.from_bytes(flag[len(flag) // 2 :], "big")
r = x * pow(y, -1, p) % p
for _ in range(1 << (1 << 1337)):
r = f(r)
if r == target:
print("Correct!")
else:
print("Incorrect!")