System32 Rsa101 Writeup

LeeDoHyun · April 22, 2020

문제 내용은 대충 이렇습니다.

p = 11820547749265118607908336189140061659994883367758644383099900753008997316272341754974105712436833864387373302687964986221522289414610698068230842231006759
q = 2076478388690715447644222392295584753007140199740835763821170999934221864895193172716587341806099928941239417181782165665806324184552950128351328886814107
e = 65537
c = 15175007508230661949213125841853820919948368859221761481847700530363990883761097704372435675552656459480039957857925187102590466676354015036181849182155680399350099015532296504916485091012255771133872737687990897080899160898509685794777509104691093814282101492973637294053730555124794841034604131492169339102

p, q, e, c값을 주는데 여기서 우리가 복호화 하는데 필요한것은 c, d, n값입니다.

p, q를 이용하여 n값과 phi값을 구한뒤, phi에대한 e의 곱셈의 역원을 구해주면 복호화가 가능합니다.

solve.py

#!/usr/bin/env python2
#-*-ccoding:utf8-*-

from Crypto.Util.number import *

p = 11820547749265118607908336189140061659994883367758644383099900753008997316272341754974105712436833864387373302687964986221522289414610698068230842231006759
q = 2076478388690715447644222392295584753007140199740835763821170999934221864895193172716587341806099928941239417181782165665806324184552950128351328886814107
e = 65537
c = 15175007508230661949213125841853820919948368859221761481847700530363990883761097704372435675552656459480039957857925187102590466676354015036181849182155680399350099015532296504916485091012255771133872737687990897080899160898509685794777509104691093814282101492973637294053730555124794841034604131492169339102

n = p * q
phi = (p - 1) * (q - 1)
d = inverse(e, phi)
flag = pow(c, d, n)
print ('{}'.format(long_to_bytes(flag)))

Twitter, Facebook