Picoctf 2019 Minirsa

LeeDoHyun · December 1, 2019

#MiniRSA - 300p

Lets decrypt this: ciphertext? Something seems a bit small

N: 29331922499794985782735976045591164936683059380558950386560160105740343201513369939006307531165922708949619162698623675349030430859547825708994708321803705309459438099340427770580064400911431856656901982789948285309956111848686906152664473350940486507451771223435835260168971210087470894448460745593956840586530527915802541450092946574694809584880896601317519794442862977471129319781313161842056501715040555964011899589002863730868679527184420789010551475067862907739054966183120621407246398518098981106431219207697870293412176440482900183550467375190239898455201170831410460483829448603477361305838743852756938687673
e: 3

ciphertext (c): 2205316413931134031074603746928247799030155221252519872649602375643231006596573791863783976856797977916843724727388379790172135717557077760267874464115099065405422557746246682213987550407899612567166189989232143975665175662662107329564517 

간단한 RSA 문제 입니다. N값이 매우크고, e값이 작을때 사용할 수 있는 방법입니다. ChiperText에서 e제곱근을 해주면됩니다.

from Crypto.Util.number import *
from gmpy2 import *

n = 29331922499794985782735976045591164936683059380558950386560160105740343201513369939006307531165922708949619162698623675349030430859547825708994708321803705309459438099340427770580064400911431856656901982789948285309956111848686906152664473350940486507451771223435835260168971210087470894448460745593956840586530527915802541450092946574694809584880896601317519794442862977471129319781313161842056501715040555964011899589002863730868679527184420789010551475067862907739054966183120621407246398518098981106431219207697870293412176440482900183550467375190239898455201170831410460483829448603477361305838743852756938687673
e = 3
c = 2205316413931134031074603746928247799030155221252519872649602375643231006596573791863783976856797977916843724727388379790172135717557077760267874464115099065405422557746246682213987550407899612567166189989232143975665175662662107329564517

with local_context() as ctx:
    ctx.precision = 3000
    m = long_to_bytes(cbrt(c))
    print m

여기서 gmpy2모듈의 cbrt를 사용해줬는데, cbrt는 3제곱근을 해주는 역할을 합니다.

picoCTF{n33d_a_lArg3r_e_11db861f}

Twitter, Facebook