Lengthy Lingo35 points  Solved 104 times  Cryptography  Zachary Taylor

Can you crack the code? We intercepted this flag but can't seem to figure out how it was encrypted.

問題で与えられたファイルencrypted.datは、下記のとおり長桁数数値のカンマ区切りデータです。

8211425851727057573810336026447657378648606436653705214471504337148868375787615020316735272873372782753586827527228, 556583248852048700547687228714654588412241548488486080714105465661031780254061717027244360672162304, 20284544651170808332373262437178385122628242586447832311283361667288254058428121357535201617453654647158765645863507, 641645284837042555065848650227830204734325151143047352176245600677525006432433761200730571563633341874, 342027254152311761208102622711476060766457874721662321275836852351517711811816000537323162350554321727074377662105763512421, 8784438522271173870658770231428186802117155301006, 851271814388572043005646253257882778080174820026, 5152278471687871386558523063450583532127073562672, 58402637862327420571743120302372687101273281802261612756601674607838448505707031861822603516351, 21785101140108815817550581106056205782745154018141824355181082370871280767676236284851681813185837715816764233114503, 75468842754437666045225283217607131215027645570708460660328830332327177142278465383661516060875106636187, 004084640437678015242077825105508301572447342665703, 61481202401520261016664357016073057166333608341162105780323515016101153863676117172660402616212, 67137581235720433002567561134576801515557488388446451143124763477488234883858782254145355582823446828621622608, 361627034030368303676028686247165018284673708054087006308645155621758746177514040254386220583106811757757625237546558, 7810385411342768056733534421023138637284441362835570732441074536146640378166087702208483061622213015864744178, 36444234330553844133752416866028452105102612312567388022042422030572063230885142576850555741308084, 802883230005082840721262220788876753001086347568658, 341534080255806735433265360040272780103741476412352186617443776772213268688384082550850845484428537731847277078525, 10333246418112336008141207026837833383757140678451737, 08134072300283626153024487365357081852686250511232665305416067844633127324036603515586215406375, 6644373087400003840177255780830815845467788518288870370882611671221084040554741222518148623811630880, 1874164531238557446382474665024343750507725185687, 3428147020402505523081340422167387373508255465066108045356323725248343273364407211447325161637834351, 38200286578137344573560145113440874422470378362628547325035243016463725708045276675313550552284628814838001320, 806347380866376761651076678847632341843, 6782405613823305448662505356202253522216848541276876268, 21610750337217487876332037857863745176424178055560780304436148466245250311600818047084626115882, 415801364313780536684357757138703605673323462440428, 1827040640335580766163300361644068715736016848530473076211533371362711571245531763264474443716843266518325024215217713, 136813170810124226561107868288233631777673006131161, 56386101645506650038634685540666532268562572660065816374610141865505515757175067044411064058384018747200824734, 23278556752387282800763002774344020550130044713620824741611878673670284345480652052374014343450, 6554573117028387718748457516242144322752878438280643878616824404212754631068253016383858715753135370265663101, 7071157615018638763862668265461074228266233868268575, 02757727801286747044647151187608680766122643671571562512023570281384607483387264016523454428300602107836128463141727, 64233458887214322415114204638805878308031453712834554240213374675128542444605317148165856405325316707363087756232244, 531847048452644248150014378663516501141163107814524, 868348813862807873166628676351868634540831417145714765101404566857555265252062402176652860660044803785874242872474, 85215280840021114401857327137683348056058207177166561135102265635132711853708453122316516272738347116321284205813607575250722

このファイルのデータをカンマで区切って、数値の桁数を文字コードとして解釈して、文字列を出力するRubyプログラムを書いてみます。

f = File.open("encrypted.dat", "r")
s = f.read
ary = s.split(",")
flag = ""
ary.each do |a|
  flag = flag + a.strip.length.chr
end
p flag

実行すると、次のとおりフラグが表示されました。

"sctf{101_th3_numb3r5_d1dn'7_3v3n_m4tt3r}"

フラグは、

sctf{101_th3_numb3r5_d1dn'7_3v3n_m4tt3r}

です。


たのしいRuby 第5版
高橋 征義
SBクリエイティブ
2016-02-26