Skip to content

Instantly share code, notes, and snippets.

@theoremoon

theoremoon/solve.sage Secret

Created Oct 11, 2020
Embed
What would you like to do?
SECCON 2020 Online CTF - solution for urara
exec(open("output.txt").read())
def gcd(a, b):
while b != 0:
a, b = b, a % b
return a
PR.<x> = PolynomialRing(Zmod(n))
f1 = (3*x^2 + a)^2 - 2*x*4*(x^3 + a*x + b) - Q[0]*4*(x^3 + a*x + b)
f2 = (x + t)^65537 - c
r = gcd(f1, f2)
k = inverse_mod(Integer(r[1]), n)
m = -k * r[0]
print(bytes.fromhex(hex(m)[2:]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment