CPCTF 2019 Writeup Crypto Easy RSA fairy_tale NormalRSA

Crypto

Easy RSA

Description

暗号の手法で有名なRSA暗号という方式があります。 https://ja.wikipedia.org/wiki/RSA暗号 これを読んで以下の暗号を解いてみてください。

n=299 e=13 c=238

FLAGの形式はFLAG_100{復号化された数字を十進数で}とする。

RSAの複合にはRSACTFToolを使った。

https://github.com/Ganapati/RsaCtfTool

~/RsaCtfTool (master ✘)✭ ᐅ python RsaCtfTool.py -n 299 -e 13 --uncipher 238
[+] Clear text : R

Rは10進数で82

FLAG : FLAG_100{82}

fairy_tale

Description

acul, acul mlc tkqbq azgqj zu nhctc m obmgq ycajzqb umvqj nzutcnz. ucf kq dqaa zu acgq fztk m oqmptzdpa amjh muj vmbbzqj kqb. uct acul mdtqb tkzy, tkbcplk tkq vmazeq cd ycvq cd kzy dbzqujy, kq dqaa zutc jzylbmeq mt ecpbt muj fmy jzyvzyyqj. tkzy vzydcbtpuq yc xbqhqj pxcu kzy vzuj tkmt kq jzj uct acul ypbgzgq kzy jzyvzyyma—kq jzqj, aqmgzul oqkzuj kzv kzy oqmptzdpa hcpul fzdq tc dmeq tkq fcbaj macuq. dqmbzul kqb kpyomuj’y quqvzqy, ykq daqj tc tkq mykzlmbm vcputmzuy my yccu my kqb kpyomuj fmy jqmj, muj tkqbq zu tkq acuqah dcbqyty fkqbq uc cuq qgqb emvq qreqxt fccjepttqby, m azttaq och fmy ocbu tc kqb. ykq emaaqj kzv nzutmbc cb tkq lcajqu och. ucf tkq bqvmbnmoaq tkzul mocpt tkzy ekzaj fmy kzy lbqmt ytbqultk, muj my kq lbqf cajqb kq lbqf ytbculqb muj ytbculqb, yc tkmt oh tkq tzvq kq fmy qzlkt hqmby cd mlq kq fmy moaq tc ept jcfu tbqqy my wpzenah my tkq fccjepttqby. tkqu kzy vctkqb lmgq kzv m amblq mr, muj kq pyqj tc lc cpt zu tkq dcbqyt muj kqax tkq fccjepttqby, fkc emaaqj kzv “fcujqb-ekzaj,” muj kzy vctkqb tkq “caj upbyq cd tkq vcputmzuy,” dcb tkqh jzj uct nucf kqb kzlk bmun. muctkqb dmgcbztq xmytzvq cd nzutmbc’y fmy tc yvmyk px bceny muj ytcuqy. hcp emu zvmlzuq kcf ytbcul kq fmy! oh tkq fmh, tkq daml zy daml_100{tkzy_zy_uct_emqymb_ezxkqb}.

一見シーザー暗号に見えるがおそらくdamlはflagだと思われるが、damlをずらしてもflagになる鍵がなかったので、 次にsimple chipherが想定される。

solverとしてquipqiupを使った。

https://quipqiup.com/

まずはdaml=flagで試す。

l??g, l??g ag? there li?ed i? ???t? a ?ra?e s?ldier ?amed ?i?t??i. ??? he fell i? l??e ?ith a ?ea?tif?l lad? a?d married her. ??t l??g after this, thr??gh the mali?e ?f s?me ?f his frie?ds, he fell i?t? disgra?e at ???rt a?d ?as dismissed. this misf?rt??e s? ?re?ed ???? his mi?d that he did ??t l??g s?r?i?e his dismissal—he died, lea?i?g ?ehi?d him his ?ea?tif?l ????g ?ife t? fa?e the ??rld al??e. feari?g her h?s?a?d’s e?emies, she fled t? the ashigara m???tai?s as s??? as her h?s?a?d ?as dead, a?d there i? the l??el? f?rests ?here ?? ??e e?er ?ame e??e?t ???d??tters, a little ??? ?as ??r? t? her. she ?alled him ?i?tar? ?r the g?lde? ???. ??? the remar?a?le thi?g a???t this ?hild ?as his great stre?gth, a?d as he gre? ?lder he gre? str??ger a?d str??ger, s? that ?? the time he ?as eight ?ears ?f age he ?as a?le t? ??t d??? trees as ??i??l? as the ???d??tters. the? his m?ther ga?e him a large a?, a?d he ?sed t? g? ??t i? the f?rest a?d hel? the ???d??tters, ?h? ?alled him “???der-?hild,” a?d his m?ther the “?ld ??rse ?f the m???tai?s,” f?r the? did ??t ???? her high ra??. a??ther fa??rite ?astime ?f ?i?tar?’s ?as t? smash ?? r???s a?d st??es. ??? ?a? imagi?e h?? str??g he ?as! ?? the ?a?, the flag is flag_100{this_is??t?aesar_?i?her}.

this_isまで見えたのでこのまま行けそう。 ??t?aesar?i?herもここまで見えればcaesar_cipherが想像できる。

daml=flag,tkzy=this,zy=is,emqymb=caesar,ezxkqb=cipherを与える。

l??g, l??g ag? there li?ed i? k??t? a bra?e s?ldier ?amed ki?t?ki. ??? he fell i? l??e ?ith a bea?tif?l lad? a?d married her. ??t l??g after this, thr??gh the malice ?f s?me ?f his frie?ds, he fell i?t? disgrace at c??rt a?d ?as dismissed. this misf?rt??e s? pre?ed ?p?? his mi?d that he did ??t l??g s?r?i?e his dismissal—he died, lea?i?g behi?d him his bea?tif?l ????g ?ife t? face the ??rld al??e. feari?g her h?sba?d’s e?emies, she fled t? the ashigara m???tai?s as s??? as her h?sba?d ?as dead, a?d there i? the l??el? f?rests ?here ?? ??e e?er came e?cept ???dc?tters, a little b?? ?as b?r? t? her. she called him ki?tar? ?r the g?lde? b??. ??? the remarkable thi?g ab??t this child ?as his great stre?gth, a?d as he gre? ?lder he gre? str??ger a?d str??ger, s? that b? the time he ?as eight ?ears ?f age he ?as able t? c?t d??? trees as ??ickl? as the ???dc?tters. the? his m?ther ga?e him a large a?, a?d he ?sed t? g? ??t i? the f?rest a?d help the ???dc?tters, ?h? called him “???der-child,” a?d his m?ther the “?ld ??rse ?f the m???tai?s,” f?r the? did ??t k??? her high ra?k. a??ther fa??rite pastime ?f ki?tar?’s ?as t? smash ?p r?cks a?d st??es. ??? ca? imagi?e h?? str??g he ?as! b? the ?a?, the flag is flag_100{this_is_??t_caesar_cipher}.

uct=notかなー。

FLAG : FLAG_100{this_is_not_caesar_cipher}.

NormalRSA

Description

RSA暗号の続きです。Easy RSAから解くのをお勧めします。

n=210889639797316464508559945308161209518351399491829608537409 e=65537 c=109726428425835169918727792916150531910899362712925617636978

Easy RSAと同じくRSACTFtoolを使う。

~/RsaCtfTool (master ✘)✭ ᐅ python RsaCtfTool.py -n 210889639797316464508559945308161209518351399491829608537409 -e 65537 --uncipher 109726428425835169918727792916150531910899362712925617636978
[+] Clear text : FLAG_200{RSA_is_fun!!!!}

FLAG : FLAG_200{RSA_is_fun!!!!}