Port 53

明日のための技術メモ

picoCTF2019 Crypto WriteUP

picoCTF2019 Crypto問題のWriteUPを書きます

Crypto

The Numbers (50pt)

f:id:saturn-glave:20191020214630p:plain
The Numbers問題
上の画像が与えられる。数字はアルファベットの何番目かを示すと察した。
いちいち対応するのも辛いのでスクリプトを書く。

#coding:utf-8
#crypto numbers(50pt)

letter = ['A','B','C','D','E','F','G','H','I','J','K','L','M',
          'N','O','P','Q','R','S','T','U','V','W','X','Y','Z','{','}']
number = [16,9,3,15,3,20,6,27,20,8,5,14,21,13,2,5,18,19,13,1,19,15,14,28]
flag = []

for i in number:
    flag.append(letter[int(i)-1])

print(''.join(flag))
#PICOCTF{THENUMBERSMASON}

13 (100pt)

文字列cvpbPGS{abg_gbb_onq_bs_n_ceboyrz}をRot13で解読せよ、とのこと(つまりシーザー暗号)
CyberChefでやってもいいけどpythonにRot13できるライブラリがあった。
せっかくなのでこっちで書いてみる。

#coding:utf-8
import codecs

ans = codecs.decode('cvpbPGS{abg_gbb_onq_bs_n_ceboyrz}', 'rot13')
print(ans)
#picoCTF{not_too_bad_of_a_problem}

Easy1 (100pt)

UFJKXQZQUNBを鍵SOLVECRYPTOでデコードしろとのこと。
テーブルが渡されるが、これはヴィジュネル暗号。
CyberChefでデコードすると、CRYPTOISFUNになる。
picoCTF{CRYPTOISFUN}

ceaser (100pt)

テキストにpicoCTF{odaeeuzsftqdgnuoazxvymiumq}とあるので、
これをシーザー暗号でデコードせよとのこと。
CyberChefからROT13を選び、数字をいじって意味の通る文章を探ったところ、
14だけずらせば良いことが分かった。 picoCTF{crossingtherubiconljmawiae}

flags (200pt)

f:id:saturn-glave:20191021114110p:plain
flags.png
昔、てつのくじら館行った時に見たことあるぞこれ
国際信号側と言って、モールス信号とも縁が深い。
航海するときのコミュニケーション手段として使っているそうで。
素直に照らし合わせて、PICOCTF{F1AG5AND5TUFF}

Mr-Worldwide (200pt)

配られたテキストファイルにある内容を解読する。
どう見ても緯度経度なので、GoogleMapとかでプロットして、
都市名の頭文字を繋げるっぽい。

picoCTF{(35.028309, 135.753082)(46.469391, 30.740883)(39.758949, -84.191605)(41.015137, 28.979530)(24.466667, 54.366669)(3.140853, 101.693207)_(9.005401, 38.763611)(-3.989038, -79.203560)(52.377956, 4.897070)(41.085651, -73.858467)(57.790001, -152.407227)(31.205753, 29.924526)}

ということで、Jupyter Notebookを使い、場所を全部プロットしてみた。 都市名は後からメモったものなので、最初は番号だけでした。
これの通り実行すると地図でプロットされます。foliumライブラリを事前に入れること。
拡大して場所を読み解くだけ。一部アラビア語とか読めなかったけど、そこは
Google先生の力を借りつつ...

地図プロット用のjupyter notebook

f:id:saturn-glave:20191021162959p:plain
地図でプロットされた結果

参考

Python: foliumでJupyter Notebookに地図を描画する

Tapping (200pt)

指示通りサーバへ接続すると、こんな感じ。

~/Documents/GitHub $ nc 2019shell1.picoctf.com 37920
.--. .. -.-. --- -.-. - ..-. { -- ----- .-. ... ...-- -.-. ----- -.. ...-- .---- ... ..-. ..- -. ...-- ----. -.... ----- ---.. ..... ....- ...-- ----. --... }

モールス信号を解読するとフラグがもらえそう。 CyberChefで解読して、PICOCTF{M0RS3C0D31SFUN3960854397}

le chifra de (200pt)

指示通りにサーバへ接続すると、暗号文が出てくる。

~/Downloads $ nc 2019shell1.picoctf.com 32203
Encrypted message:
Ne iy nytkwpsznyg nth it mtsztcy vjzprj zfzjy rkhpibj nrkitt ltc tnnygy ysee itd tte cxjltk

Ifrosr tnj noawde uk siyyzre, yse Bnretèwp Cousex mls hjpn xjtnbjytki xatd eisjd

Iz bls lfwskqj azycihzeej yz Brftsk ip Volpnèxj ls oy hay tcimnyarqj dkxnrogpd os 1553 my Mnzvgs Mazytszf Merqlsu ny hox moup Wa inqrg ipl. Ynr. Gotgat Gltzndtg Gplrfdo 

Ltc tnj tmvqpmkseaznzn uk ehox nivmpr g ylbrj ts ltcmki my yqtdosr tnj wocjc hgqq ol fy oxitngwj arusahje fuw ln guaaxjytrd catizm tzxbkw zf vqlckx hizm ceyupcz yz tnj fpvjc hgqqpohzCZK{m311a50_0x_a1rn3x3_h1ah3x54ioc1h9}

Yse lncsz bplr-izcarpnzjo dkxnroueius zf g uzlefwpnfmeznn cousex mzwkapr, cfd mgip axtfnj 1467 gj Lkty Bgyeiyyl Argprzn.

Ehk Atgksèce Inahkw ts zmprkkzrk xzmkytmkx narqpd zmp Argprzn Oiyh zr Gqmexyt Cousex.

Ny 1508, Jumlntjd Txnehkrtuy nyvkseej yse yt-narqpd zfmurf ceiyl (a sferoc zf ymtfzjo arusahjes) zmlt ctflj qltkw me g hciznnar hzmvtyety zf zmp Volpnèxj Nivmpr.

Hjwlgxz’s yjnoti moupwez fapkfcej ny 1555 ay f notytnafeius zf zmp fowdt. Zmp lubpr nfwvkx zf zmp arusahjes gwp nub dhokeej wpgaqlrrd, muz yse gqahggpty fyd zmp itipx rjetkwd axj xidjo be rpatx zf g ryestyii ppy vmcayj, hhohs cgs me jnqfkwpnz bttn jlcn hzrxjdpusoety.

問題のタイトルがフランス語なので、ヴィジュネル暗号を疑う。

www.guballa.de

CyberChefは、鍵が分かっていれば使えるが今回はそうでないので、
自動的に鍵まで解いてもらった。言語を英語にして解読すると、

It is interesting how in history people often receive credit for things they did not create

During the course of history, the Vigenère Cipher has been reinvented many times

It was falsely attributed to Blaise de Vigenère as it was originally described in 1553 by Giovan Battista Bellaso in his book La cifra del. Sig. Giovan Battista Bellaso 

For the implementation of this cipher a table is formed by sliding the lower half of an ordinary alphabet for an apparently random number of places with respect to the upper halfpicoCTF{b311a50_0r_v1gn3r3_c1ph3r54ddc1b9}

The first well-documented description of a polyalphabetic cipher however, was made around 1467 by Leon Battista Alberti.

The Vigenère Cipher is therefore sometimes called the Alberti Disc or Alberti Cipher.

In 1508, Johannes Trithemius invented the so-called tabula recta (a matrix of shifted alphabets) that would later be a critical component of the Vigenère Cipher.

Bellaso’s second booklet appeared in 1555 as a continuation of the first. The lower halves of the alphabets are now shifted regularly, but the alphabets and the index letters are mixed by means of a mnemonic key phrase, which can be different with each correspondent.

鍵はflagだったそうです。