Skip to content

Instantly share code, notes, and snippets.

@elliptic-shiho
Last active July 10, 2023 06:29
Show Gist options
  • Save elliptic-shiho/cfd56e9dd47c7f2041157ffb6bb7477c to your computer and use it in GitHub Desktop.
Save elliptic-shiho/cfd56e9dd47c7f2041157ffb6bb7477c to your computer and use it in GitHub Desktop.
Crypto CTF 2023: Risk (last phase only)
from sage.all import *
from Crypto.Util.number import long_to_bytes
A = 6737149052150272134972940516590980024331491319339741317342183169802474656888386084365871287308045730462954100927849817850868865189752921007067826413968051476282853264469660023301658697080152738648906257793188559177506701773637608811467111764155767760049813836531589499517889064750007039677591074035963533567
q = 15040222622096320078383580808680733765955114958694997949647342925417877088612792495485641348591026281373930569798925789027166056695954731923306109646611840570310396750856642056018981080439916663195842593441587057719678555907050674529272376248049062724657792390788687452049496308886252188791975094655675938807
F = GF(q)
PR.<x> = F[x]
l = (x ^ 6 - A).roots()
for a, b in l:
print(long_to_bytes(ZZ(a)))
Sun Jul 9 16:46:32 JST 2023 ~/Downloads/risk
> time sage solve.sage
b'\x15k\x01B<\xba\xbe\xd4\x96\xc9\xb4\xd9W\xc0f\xa0zH\xbd\x95v\x16\xb3\x92\xba\\\x15\x95)$\xce\xff/\xd6\xd2"\xbd\x98\xeb\xda\x91\n\xd6\xcap\rr\xb7\xfa\x12\xb6b\xe4ti\xd7\xad\xcc\xc3\xb4\xd3{\xbe\xf0a\xfd77\xd3\x11OO\xc7L\x1e\xc7b\x14\x17\xe5\x81p\xce\xb4\x85%\xa5Q%\xb0\x01D\x1e/\xe6:\x0f>\xe8\x16\x1f67]\x9ah\t\xe9&\xe7\x1d\xa1H\xf0\\\xccs\x9ej\xb9\x92\xdd\xe2c\x089\x16z'
b'\x14\x96\x97\x9f\xeb\x0b\xbd\xe2\xd4\x82}\x7f\x00F\xcd\x13\xbd01&\xf8\x19\xd0I\xb8|bl+\x98+F\x98\xff:\x8f\xf5\xb2\x88\xfe\xd0T\xab\x05\xa7\xde/\xb2\x12\xe0\x01\x9e\xebK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xe72\xb4\xc3\xf9)_\xf1\x8a{\x1e"\x13\xfd\xc5\xbd\xc1\xcb\xde\xa1\xc2\xcfu\x94k\xdc\xb6\xf7\xd0D\x98\xee\xb5#x\x97\xeb!\xbd(\x8b\xc8\xaf2F\xe0\re\x948\xdc\xc0T\xd1\xa0|\x07\xeaL\xf5A\x87M\xf9G\xfa\xe7\xc4\xc0&A\xee\x83\xb8\xa4"\x10\xb0\xb8\x8e'
b'CCTF{S!mP1E_A7t4cK_0n_SpEc1aL-5trucTur3D_RSA_pR1me5!}'
real 0m6.584s
user 0m6.354s
sys 0m0.236s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment