この大会は2021/7/31 14:00(JST)~2021/8/2 2:00(JST)に開催されました。
今回もチームで参戦。結果は670点で327チーム中7位でした。
自分で解けた問題をWriteupとして書いておきます。
Identifying an Attack (OSINT 10)
AppleのBluetoothを介してリモートコード実行をする攻撃のCVEを答える問題。検索すると、以下のURLが見つかる。
https://support.apple.com/de-de/HT212146
その中のBluetoothのCVEの一つがフラグとして通った。
RTL{CVE-2021-1794}
Bad Developers (Reversing 10)
pastebinの内容は以下のようになっている。
a = "LTR" b = "0D" c = "S1" inp = input("> ") if len(inp) != 17: print("Wrong size.") exit() if (inp[0] == a[2] and inp[1] == a[1] and inp[2] == a[0]) and inp[3] == "{" and \ ((inp[4] + inp[5]) == b[::-1]) and (inp[6] == "N" and inp[7] == "T" and inp[8] == chr(95)) and \ (inp[9] + inp[10] == b[::-1]) and (inp[11] + inp[12] + inp[13] == "_TH") and (inp[14] + inp[15] == c[::-1]) and \ (inp[16] == "}"): print("Good job.") else: print("Flag is incorrect.")
このコードからフラグを構成する。
RTL{D0NT_D0_TH1S}
The gate of ultimate success (Reversing 50)
Ghidraでデコンパイルする。
int main(int _Argc,char **_Argv,char **_Env) { int iVar1; char *_Source; size_t sVar2; ulonglong uVar3; byte local_68 [32]; byte local_48 [31]; byte local_29; char *local_28; int local_1c; __main(); local_28 = "/5:/)4+62/(46>):(82(:9"; printf("Enter the key to unlock the ultimate door of success: "); scanf("%s",local_48); _Source = strrev((char *)local_48); strcpy((char *)local_48,_Source); local_1c = 0; while( true ) { uVar3 = SEXT48(local_1c); sVar2 = strlen((char *)local_48); if (sVar2 <= uVar3) break; local_29 = local_48[local_1c] ^ 0x7b; local_68[local_1c] = local_29; local_1c = local_1c + 1; } local_68[local_1c] = 0; iVar1 = strcmp((char *)local_68,local_28); if (iVar1 == 0) { puts("Congratulations! You have opened the ultimate door of success!!"); puts("The Key is the Flag!"); } else { puts("Not Quite!\nTry Harder :)"); } return 0; }
入力した文字列を逆順にし、0x7bとのXORを以下と比較している。
"/5:/)4+62/(46>):(82(:9"
元に戻してみる。
s = '/5:/)4+62/(46>):(82(:9' flag = '' for c in s: flag += chr(ord(c) ^ 0x7b) flag = flag[::-1] print flag
実行結果は以下の通り。
BASICSAREMOSTIMPORTANT
RTL{BASICSAREMOSTIMPORTANT}
Bites (Reversing 50)
Pythonアセンブリが添付されている。このコードを見ると以下のことがわかる。以下の鍵でXORをして暗号化している。
・インデックス奇数番目 ・'w'のASCIIコードとのXOR ・インデックス偶数番目 ・'w'のhexエンコードを10進数としてXOR
以上を元に復号する。
with open('flag.txt', 'r') as f: enc = map(int, f.read().split(' ')) key = 'w' key_1 = ord(key) key_2 = int(key.encode('hex')) keyes = [key_1, key_2] flag = '' for i in range(len(enc)): if i % 2 == 1: flag += chr(enc[i] ^ keyes[0]) else: flag += chr(enc[i] ^ keyes[1]) print flag
RTL{H4x_ByT3$$}
Basic (Web 10)
SQLインジェクション。以下でログインボタンを押したらフラグが表示された。
Username: ' or 1=1 -- - Password: (空欄)
RTL{b@s1c_5ql}
WDigest (Windows 50)
lsassのダンプファイルが添付されている。mimikatzでパスワードを取り出してみる。
>mimikatz .#####. mimikatz 2.2.0 (x64) #18362 Aug 14 2019 01:31:47 .## ^ ##. "A La Vie, A L'Amour" - (oe.eo) ## / \ ## /*** Benjamin DELPY `gentilkiwi` ( benjamin@gentilkiwi.com ) ## \ / ## > http://blog.gentilkiwi.com/mimikatz '## v ##' Vincent LE TOUX ( vincent.letoux@gmail.com ) '#####' > http://pingcastle.com / http://mysmartlogon.com ***/ mimikatz # sekurlsa::minidump lsass1.DMP Switch to MINIDUMP : 'lsass1.DMP' mimikatz # sekurlsa::logonPasswords Opening : 'lsass1.DMP' file for minidump... Authentication Id : 0 ; 783428 (00000000:000bf444) Session : Interactive from 1 User Name : d4rckh Domain : WIN-243AVCIFKOS Logon Server : WIN-243AVCIFKOS Logon Time : 2021/06/29 16:09:31 SID : S-1-5-21-2990196461-2075781814-3459016515-1000 msv : [00000003] Primary * Username : d4rckh * Domain : WIN-243AVCIFKOS * NTLM : 1e4cc5210241270de3af54fbf3d0f479 * SHA1 : 871a0de3b4e7df24b36d2c092c600850e11ee525 tspkg : wdigest : * Username : d4rckh * Domain : WIN-243AVCIFKOS * Password : RTL{WD1G3ST_1S_B4D} kerberos : * Username : d4rckh * Domain : WIN-243AVCIFKOS * Password : (null) ssp : KO credman : : :
パスワードにフラグが設定されていた。
RTL{WD1G3ST_1S_B4D}
HIVE Registration Office (Windows 50)
NTUSER.DATと、SAM, SYSTEM, SOFTWAREのファイルが添付されている。以下の4つの問題の答えを"_"区切りで結合したものがフラグとなる。
・最後にパスワードを変更した日時(Format: hh:mn:sc yyyy/mm/dd) ・このPCの製造社の名前 ・このPCのBIOSベンダの名前 ・このユーザのログイン回数
Registry ViewerでSAMを開く。[SAM]>[Domains]>[Account]>[Users]配下のUserを見ていく。
有効なユーザはUSERの1名で以下のようになっていることがわかる。
・Last Password Change Timeは 2020/04/19 15:54:49 UTC ・Logon Countは 2817
次にRegistry ViewerでSYSTEMを開く。[SYSTEM]>[HardwareConfig]>[{952fccf7-...}]のハードウェア情報を見ていく。
この情報から以下がわかる。
・PCの製造元「SystemManufaturer」はHP ・BIOS情報「SystemBiosVersion」からベンダはINSYDE
以上の情報からフラグにする。
RTL{15:54:49 2020/04/19_HP_Insyde_2817}
Expic (Forensics 15)
$ file photo photo: JPEG image data, JFIF standard 1.01, resolution (DPI), density 72x72, segment length 16, progressive, precision 8, 1000x667, frames 3 $ mv photo photo.jpg $ exiftool photo.jpg ExifTool Version Number : 10.80 File Name : photo.jpg Directory : . File Size : 136 kB File Modification Date/Time : 2021:07:05 19:19:49+09:00 File Access Date/Time : 2021:07:31 17:38:44+09:00 File Inode Change Date/Time : 2021:07:05 19:19:49+09:00 File Permissions : rwxrwxrwx File Type : JPEG File Type Extension : jpg MIME Type : image/jpeg JFIF Version : 1.01 Resolution Unit : inches X Resolution : 72 Y Resolution : 72 XMP Toolkit : Image::ExifTool 12.16 Author : p4ul Number : 68747470733a2f2f706173746562696e2e636f6d2f514632557a6a56590a Profile CMM Type : Linotronic Profile Version : 2.1.0 Profile Class : Display Device Profile Color Space Data : RGB Profile Connection Space : XYZ Profile Date Time : 1998:02:09 06:49:00 Profile File Signature : acsp Primary Platform : Microsoft Corporation CMM Flags : Not Embedded, Independent Device Manufacturer : Hewlett-Packard Device Model : sRGB Device Attributes : Reflective, Glossy, Positive, Color Rendering Intent : Perceptual Connection Space Illuminant : 0.9642 1 0.82491 Profile Creator : Hewlett-Packard Profile ID : 0 Profile Copyright : Copyright (c) 1998 Hewlett-Packard Company Profile Description : sRGB IEC61966-2.1 Media White Point : 0.95045 1 1.08905 Media Black Point : 0 0 0 Red Matrix Column : 0.43607 0.22249 0.01392 Green Matrix Column : 0.38515 0.71687 0.09708 Blue Matrix Column : 0.14307 0.06061 0.7141 Device Mfg Desc : IEC http://www.iec.ch Device Model Desc : IEC 61966-2.1 Default RGB colour space - sRGB Viewing Cond Desc : Reference Viewing Condition in IEC61966-2.1 Viewing Cond Illuminant : 19.6445 20.3718 16.8089 Viewing Cond Surround : 3.92889 4.07439 3.36179 Viewing Cond Illuminant Type : D50 Luminance : 76.03647 80 87.12462 Measurement Observer : CIE 1931 Measurement Backing : 0 0 0 Measurement Geometry : Unknown Measurement Flare : 0.999% Measurement Illuminant : D65 Technology : Cathode Ray Tube Display Red Tone Reproduction Curve : (Binary data 2060 bytes, use -b option to extract) Green Tone Reproduction Curve : (Binary data 2060 bytes, use -b option to extract) Blue Tone Reproduction Curve : (Binary data 2060 bytes, use -b option to extract) Image Width : 1000 Image Height : 667 Encoding Process : Progressive DCT, Huffman coding Bits Per Sample : 8 Color Components : 3 Y Cb Cr Sub Sampling : YCbCr4:2:0 (2 2) Image Size : 1000x667 Megapixels : 0.667
Numberにあやしいhex文字列があるので、デコードする。
$ echo 68747470733a2f2f706173746562696e2e636f6d2f514632557a6a56590a | xxd -r -p https://pastebin.com/QF2UzjVY
ここにアクセスすると、base64文字列が書いてある。
T0tLIApSVEx7MTBiYmE5YTUyNDE3MDk1ZGU1MWRiOTQ1NjM2MWQ3NDR9Cg==
この文字列をbase64デコードする。
$ echo T0tLIApSVEx7MTBiYmE5YTUyNDE3MDk1ZGU1MWRiOTQ1NjM2MWQ3NDR9Cg== | base64 -d OKK RTL{10bba9a52417095de51db9456361d744}
RTL{10bba9a52417095de51db9456361d744}
Manipulated (Forensics 50)
PNGの幅と高さが大き過ぎる。おそらく間違っているので、まず幅から総当たりで画像を出力してみる。
import struct import binascii with open('corr.png', 'rb') as f: data = f.read() head = data[:16] tail = data[33:] h = 512 for w in range(1, 1024): width = struct.pack('>I', w) height = struct.pack('>I', h) ihdr = 'IHDR' + width + height + '\x08\x06\x00\x00\x00' crc = struct.pack('!l', binascii.crc32(ihdr)) out = head + width + height out += '\x08\x06\x00\x00\x00' out += crc + tail fname = 'png/corr_fix_w%04d.png' % w with open(fname, 'wb') as f: f.write(out)
幅が829のときに画像がきれいに表示された。次に高さを総当たりでCRCが合うものを探す。
import struct import binascii with open('corr.png', 'rb') as f: data = f.read() head = data[:16] tail = data[33:] orig_crc = data[29:33] w = 829 for h in range(1, 1024): width = struct.pack('>I', w) height = struct.pack('>I', h) ihdr = 'IHDR' + width + height + '\x08\x06\x00\x00\x00' crc = struct.pack('!l', binascii.crc32(ihdr)) if crc == orig_crc: out = head + width + height out += '\x08\x06\x00\x00\x00' out += crc + tail fname = 'corr_fix_w%04d_h%04d.png' % (w, h) with open(fname, 'wb') as f: f.write(out) break
復元すると画像の右下にフラグが書いてあった。
RTL{IHDR_chunk_m4nipulat10n}
Welcome (Crypto 5)
base64デコードする。
$ echo UlRMe0g0VkVfRlVOX1BMNFkxTkchfQ== | base64 -d RTL{H4VE_FUN_PL4Y1NG!}
RTL{H4VE_FUN_PL4Y1NG!}
Wait, what! (Crypto 20)
Vigenere暗号。https://www.dcode.fr/vigenere-cipherでkeyを調整しながら復号する。
この結果KEYは"WIN"で復号できた。
RTL{9b175777156c5608a3b889f5ab9215f2}
Ciphers Galore! (Crypto 40)
hastebinにこう書いてある。
$&Es6a@I+v5;|`h_$)q?2Kq75w=p|%tK+)8K)K}d!b_l
これをrot47をする。
SUtDe2oxZGdjM190SXBnazBfdHlAMTEzZXgzXzN5P30=
さらにbase64デコードする。
$ echo SUtDe2oxZGdjM190SXBnazBfdHlAMTEzZXgzXzN5P30= | base64 -d IKC{j1dgc3_tIpgk0_ty@113ex3_3y?}
今度はシーザー暗号。https://www.geocachingtoolbox.com/index.php?lang=en&page=caesarCipherで復号する。
Rotation 17: RTL{s1mpl3_cRypt0_ch@113ng3_3h?}
RTL{s1mpl3_cRypt0_ch@113ng3_3h?}
Last Words (Crypto 50)
hastebinにこう書いてある。
n=654922591808399471401115531725039933804976416275178080902192760929946158327379913921397815675866572368514471928883646492843129515545704650288455484139194674085479767043433916059634120332033088959269854607488937394748966549930683612344765680930825877346853207413052755531377359101713133223003902598963694672505995923904179391456221568627581198379796103905853274401142025181753922563551760475421349438387207814101835728396617249777551918738205026251791041540304166035801169367444769632368098508148321283516990672280903943844076578831127878464804361185261171218008337510295988058766597378522306523707845029512326086281153969312238517561678149326216382068770238520736531273600941471546492734984885174688640769745572963612242607879009754765129567334064867941063826839593018197528692242502124648098963061951119350954396467735643056862091298259178844956622094028547135110211632557488448742742990287309014601421331198088078262672918791473250793328827598271675543610977104049017695062380578362377174224228163980223055437425220689053314587171763084816067718392663203432596767350691383811865855862699762433397509373202656517 e=65537 ct=100710438795162977079348743974088808865381156915931230652674830564884952723797964737417330704790990449847640350694313826907540645947517771309102468382620491151431303509245971254205327928401285858105844273322941744709730235138404791133855224230464330311543377527034287444040442497607564368033381652353025668428244301303066924437016815162803737278638329823899949834679835580778760115487417517224721370787073698165030607724383674378473550370840265887300696291636301457816942477342875386648871368111343762416276747522564143279926396047848536514023846050160848670498687478441942327283357707903465054287238235065476035197766241316080918681581228125031794197267118491412751434265211623073108630476746894061360362486334754179185179035203622586839918393560491482900365894224904151749064929247038688878617389856012413316816710758669316380134350637155478806193340543320655839127039864941782215970914222744836875559787971645305231571859542782671984468965485858145740868483956306860449187868403601170785547890022967337275595188765793071937500328605240827441496747925821120273130333043107613757070639870802278814019421139964349
nを素因数分解する。
n = 86842034747506493609419721799469420931995622862762177911235982167541270872531314416635530661571139759415845637249847122973461307626071732001202620839724983790638777821431490624281206999841752934471207639839705304729136564852048258975833304653350042975893538110232832319190920640420813884920174219068423676798778919245766035367660194191901644604977395931936301500921652573 ** 3
p = 86842034747506493609419721799469420931995622862762177911235982167541270872531314416635530661571139759415845637249847122973461307626071732001202620839724983790638777821431490624281206999841752934471207639839705304729136564852048258975833304653350042975893538110232832319190920640420813884920174219068423676798778919245766035367660194191901644604977395931936301500921652573
pを上のように定義すると、phi = p**2 * (p - 1) になる。このことを使って、復号する。
from Crypto.Util.number import * n = 654922591808399471401115531725039933804976416275178080902192760929946158327379913921397815675866572368514471928883646492843129515545704650288455484139194674085479767043433916059634120332033088959269854607488937394748966549930683612344765680930825877346853207413052755531377359101713133223003902598963694672505995923904179391456221568627581198379796103905853274401142025181753922563551760475421349438387207814101835728396617249777551918738205026251791041540304166035801169367444769632368098508148321283516990672280903943844076578831127878464804361185261171218008337510295988058766597378522306523707845029512326086281153969312238517561678149326216382068770238520736531273600941471546492734984885174688640769745572963612242607879009754765129567334064867941063826839593018197528692242502124648098963061951119350954396467735643056862091298259178844956622094028547135110211632557488448742742990287309014601421331198088078262672918791473250793328827598271675543610977104049017695062380578362377174224228163980223055437425220689053314587171763084816067718392663203432596767350691383811865855862699762433397509373202656517 e = 65537 ct = 100710438795162977079348743974088808865381156915931230652674830564884952723797964737417330704790990449847640350694313826907540645947517771309102468382620491151431303509245971254205327928401285858105844273322941744709730235138404791133855224230464330311543377527034287444040442497607564368033381652353025668428244301303066924437016815162803737278638329823899949834679835580778760115487417517224721370787073698165030607724383674378473550370840265887300696291636301457816942477342875386648871368111343762416276747522564143279926396047848536514023846050160848670498687478441942327283357707903465054287238235065476035197766241316080918681581228125031794197267118491412751434265211623073108630476746894061360362486334754179185179035203622586839918393560491482900365894224904151749064929247038688878617389856012413316816710758669316380134350637155478806193340543320655839127039864941782215970914222744836875559787971645305231571859542782671984468965485858145740868483956306860449187868403601170785547890022967337275595188765793071937500328605240827441496747925821120273130333043107613757070639870802278814019421139964349 p = 86842034747506493609419721799469420931995622862762177911235982167541270872531314416635530661571139759415845637249847122973461307626071732001202620839724983790638777821431490624281206999841752934471207639839705304729136564852048258975833304653350042975893538110232832319190920640420813884920174219068423676798778919245766035367660194191901644604977395931936301500921652573 assert p**3 == n phi = p**2 * (p - 1) d = inverse(e, phi) m = pow(ct, d, n) flag = long_to_bytes(m) print flag
RTL{1_c0uld_pr0b4bly_m4k3_th15_al0t_h4rd3r_next_t1m3!!!-e82fac7a780f72579c47b6ce0d5b7fd82eb6192ed65949ca485309b5}
Prime Wars (Crypto 100)
hastebinにこう書いてある。
n1 = 566221739863977646736721682011333807796590102966100695194310620218470729461275722292140482319899778713820060265923869893401521906205305368328306043579187706853485437921831371029214961811494122192337930065696018951462828665445615141091183534841940599838093770320461133391699075222247939819900121236110971700696105489971565251454461137332565728668519630702868390984968809890411002433675500435307965852077572726635810080149258801398685400547485878192424615765944731391973340241846002730195767759151858997916762387216730149076597675542290642832111947822631082336363112334980996139059508422962559340348499296207795252061098275087667409311341213411634790680066485631312469912396445799421274265217859663940963061971356082309326483768076487799281518290731656493691162323931795237278586585545623367010915334179583541995626560880636503957382134319206023123411349833472056481644952778792848785667709711485672892988797716902447369616972465400006278253452208972021357410241170776071179703665052803439192312431636333268490272499358694737414368063546325534729939683367397457925327583795681246653779995480876013766855878053276985288388511748855392360325294682863748252671552839924011611195986097044722822094665795811187083443436124185380849823320269 n2 = 530687960326989199343319641769468735056719687565676116773867349194199707584560078068423386135890862967492083649259423619534829360312312415859971577871205607317501227240337115190745493433956081180884413305800300580884184696296161434330167968026660523557985565886533238297825809579994229108489059297432098391309435372101680113632239869822673544784768505792706364410485518925618258042094875462603213572787841216570345262199686710412603549897422189614969582861864254420417299634404604836686002844474219985576430743265948197527474248491388705441130953941181556617683221203362472944098134461408751346998476446586666834971737908058449883435726587949913025269736607729697079862492284704316292035894525557178639119313839639367173374112578867607756303094321269575690336950882905280053919054235370449932609315382297618889670977059330701026607153879782197738829120356489708220812077499925959245646215072631870621249929738039796464674137188432418358322322951396160305358390892407264446374303126859071550310106586658423478700243720364032486757394301046359926113959148905015787118727956636757598958649450053440979270941138362644625329056253564482473075514932905256742399555775172390368620357545582366617322603645755305557295237798218160825818028141 c1 = 541153229095037579858295446778781172580884760385284002147542196003293531706169322960419234627569448144454740037897824182763794136447630757453376634579718740889293827421101038528096128202725311128856550252391329972697194691055771487521623294763797972162804659018656693772784475703082077246581189924112745802615273945459021693817260332729156074315476144345570299302453664151948339053713643786820031594973122213751914815311678013684404652242883165684206203052286412805274780026118894445296355748197875829240333586988104756334241102699330573777392273876291720218348933387763312640822902812957421714195326933601605321965709074451400653731014764106019599722795539834325135751763748535818245279349879282209883358546352004025727567368992723027658796034538642700094030498932061027265715879714641028273752382847514213009506808354344932707617158448818354068769701862616100339045667459331188727567895267106823657493354380767172450502114171361684932534502241769497123329590345257756472987942810598170216656539701267821411429342523220745000710941105058620823772704687332908554259583914517043335169990317116173107543607214237003882719965328248495192877057980130140435959212771456749734889259597913342498941690494257669128891366353841619609756468921 c2 = 254995434157499094074740522382653621037683865648217139039983930708198788191604658271710855356490733399654161006910038154620981573866101234344287987438243674727015451767752359204059726091404920699248900600731198907902943821415385868340903420608124994228491370751247056929503984979851323391697177354816426431850758247280384447390337838329405467881123751494398120341651866069192129528281599223102780529318685134788757786889067516080883688672346336894714129591857173409977371931952391183625743359104241029151189312962972792281315749538605826756768473316038049796835635589004389296836167765473708147029138883114826871178964183235758399250652660883721790259823584072358804375705646051403907609048390491677793908468748713509583596713778535934151102923682351421382031077628225365089849689017916396722184824218580154786982944998381313733006433456871650537316172524799446574879129947133779006211264007941650032669379067206952767031734008491060404429453666781467192068866951706138107308158417730524621195117216907305295460018473142138099891895507309673542435440468021685601317053971788683791808873561776467354349919631751772535099532988995232543637786525488499494159113757641523815672849159932102361116353214010806562143397856767159948326787376 e = 65537
RSA暗号のようだ。n1とn2の最大公約数が素数になっている。
n1 = p * q1 n2 = p * q2
素因数分解できたので、あとはそれぞれ復号するが、printableな文字にはならない。いろいろと試した結果、復号した数字をそのまま文字として結合して、その数字を文字にしたら、フラグになった。
from Crypto.Util.number import * n1 = 566221739863977646736721682011333807796590102966100695194310620218470729461275722292140482319899778713820060265923869893401521906205305368328306043579187706853485437921831371029214961811494122192337930065696018951462828665445615141091183534841940599838093770320461133391699075222247939819900121236110971700696105489971565251454461137332565728668519630702868390984968809890411002433675500435307965852077572726635810080149258801398685400547485878192424615765944731391973340241846002730195767759151858997916762387216730149076597675542290642832111947822631082336363112334980996139059508422962559340348499296207795252061098275087667409311341213411634790680066485631312469912396445799421274265217859663940963061971356082309326483768076487799281518290731656493691162323931795237278586585545623367010915334179583541995626560880636503957382134319206023123411349833472056481644952778792848785667709711485672892988797716902447369616972465400006278253452208972021357410241170776071179703665052803439192312431636333268490272499358694737414368063546325534729939683367397457925327583795681246653779995480876013766855878053276985288388511748855392360325294682863748252671552839924011611195986097044722822094665795811187083443436124185380849823320269 n2 = 530687960326989199343319641769468735056719687565676116773867349194199707584560078068423386135890862967492083649259423619534829360312312415859971577871205607317501227240337115190745493433956081180884413305800300580884184696296161434330167968026660523557985565886533238297825809579994229108489059297432098391309435372101680113632239869822673544784768505792706364410485518925618258042094875462603213572787841216570345262199686710412603549897422189614969582861864254420417299634404604836686002844474219985576430743265948197527474248491388705441130953941181556617683221203362472944098134461408751346998476446586666834971737908058449883435726587949913025269736607729697079862492284704316292035894525557178639119313839639367173374112578867607756303094321269575690336950882905280053919054235370449932609315382297618889670977059330701026607153879782197738829120356489708220812077499925959245646215072631870621249929738039796464674137188432418358322322951396160305358390892407264446374303126859071550310106586658423478700243720364032486757394301046359926113959148905015787118727956636757598958649450053440979270941138362644625329056253564482473075514932905256742399555775172390368620357545582366617322603645755305557295237798218160825818028141 c1 = 541153229095037579858295446778781172580884760385284002147542196003293531706169322960419234627569448144454740037897824182763794136447630757453376634579718740889293827421101038528096128202725311128856550252391329972697194691055771487521623294763797972162804659018656693772784475703082077246581189924112745802615273945459021693817260332729156074315476144345570299302453664151948339053713643786820031594973122213751914815311678013684404652242883165684206203052286412805274780026118894445296355748197875829240333586988104756334241102699330573777392273876291720218348933387763312640822902812957421714195326933601605321965709074451400653731014764106019599722795539834325135751763748535818245279349879282209883358546352004025727567368992723027658796034538642700094030498932061027265715879714641028273752382847514213009506808354344932707617158448818354068769701862616100339045667459331188727567895267106823657493354380767172450502114171361684932534502241769497123329590345257756472987942810598170216656539701267821411429342523220745000710941105058620823772704687332908554259583914517043335169990317116173107543607214237003882719965328248495192877057980130140435959212771456749734889259597913342498941690494257669128891366353841619609756468921 c2 = 254995434157499094074740522382653621037683865648217139039983930708198788191604658271710855356490733399654161006910038154620981573866101234344287987438243674727015451767752359204059726091404920699248900600731198907902943821415385868340903420608124994228491370751247056929503984979851323391697177354816426431850758247280384447390337838329405467881123751494398120341651866069192129528281599223102780529318685134788757786889067516080883688672346336894714129591857173409977371931952391183625743359104241029151189312962972792281315749538605826756768473316038049796835635589004389296836167765473708147029138883114826871178964183235758399250652660883721790259823584072358804375705646051403907609048390491677793908468748713509583596713778535934151102923682351421382031077628225365089849689017916396722184824218580154786982944998381313733006433456871650537316172524799446574879129947133779006211264007941650032669379067206952767031734008491060404429453666781467192068866951706138107308158417730524621195117216907305295460018473142138099891895507309673542435440468021685601317053971788683791808873561776467354349919631751772535099532988995232543637786525488499494159113757641523815672849159932102361116353214010806562143397856767159948326787376 e = 65537 p = GCD(n1, n2) q1 = n1 // p q2 = n2 // p assert isPrime(p) assert isPrime(q1) assert isPrime(q2) phi1 = (p - 1) * (q1 - 1) phi2 = (p - 1) * (q2 - 1) d1 = inverse(e, phi1) d2 = inverse(e, phi2) m1 = pow(c1, d1, n1) m2 = pow(c2, d2, n2) assert pow(m1, e, n1) == c1 assert pow(m2, e, n2) == c2 m = int(str(m1) + str(m2)) flag = long_to_bytes(m) print flag
RTL{th3r3_pr1m35_4nd_0pt1m4l_pr1m35_wh1ch_do_y0u_u53??-a1b8f0d453def3be67ebf3a313550f73e76951672b05b3bdd39da3e5}
Diffie Hellman (Crypto 100)
$ nc 139.59.252.147 19012 g:5 p:23 Send your public message to BOB.Intercepted Alice's message: 4 5 Send your public message to ALICE.Intercepted Bob's message: 10 6 The message is encrypted.Bob sends message:X^Fq>i=n382l?<9=3<lho:n?l;n:3>i9>2h?w
0で渡せば0を何乗しても0のため、暗号化されないと推測する。
$ nc 139.59.252.147 19012 g:5 p:23 Send your public message to BOB.Intercepted Alice's message: 4 0 Send your public message to ALICE.Intercepted Bob's message: 10 0 The message is encrypted.Bob sends message:RTL{4c7d928f563796fbe0d5f1d094c348b5}
RTL{4c7d928f563796fbe0d5f1d094c348b5}