ncコマンドで指定されたサーバに接続すると、次のように入力を求められます。何度か試したところ、25文字までの入力を受け付けるようです。The Neverending Crypto Level 1
10
Hope you remember 1984, because you are
about to go on a journey.How many levels can you get to?
Good luck.
nc 146.148.102.236 24069
したがって、abcdefghijklmnopqrstuvwxy(a~yの25文字)を入力してみます。aが.-、bが-...という様に、モールス符号が返ってきます。そして、モールス符号で表された暗号文を復号するように入力を求められます。------------------------------------------Welcome to The Neverending Crypto!Quick, find Falkor and get through this!This is level 1, the Bookstore
これが何度も繰り返されますので、自動的に応答するプログラムをRubyで書きます。a~yに対応する符号を配列に保持しておき、半角スペースはそのまま半角スペース、これら以外をzに置き換えます。abcdefghijklmnopqrstuvwxyRound 1. Give me some text:abcdefghijklmnopqrstuvwxy encrypted is .- -... -.-. -.. . ..-. --. .... .. .--- -.- .-.. -- -. --- .--. --.- .-. ... - ..- ...- .-- -..- -.--What is .. --- .-- . -.-- --- ..- decrypted?
このプログラムを実行すると、次のとおり50問解いた後にフラグが表示されます。その後、Level 2へ進みます。require "socket"beginsock = TCPSocket.open("146.148.102.236", 24069)rescueputs "TCPSocket.open failed : #$!\n"elsewhile sock.getsbuf = $_printf( buf )STDOUT.flushif buf.start_with?("This is level 1, the Bookstore") or buf.include?("Correct!") thenstr = "abcdefghijklmnopqrstuvwxy"printf(str + "\n")sock.write(str + "\n")STDOUT.flushelsif buf.include?(" encrypted is ") thenary = buf.split(" ")#p aryelsif buf.start_with?("What is") thenenc = buf.gsub(/\s\s\s/, " _ ").split(" ")p encans = ""for e in enc doif e == "What" or e == "is" or e == "decrypted?" thennextelsif e == "_" thenans = ans + " "elsif ary.index(e) thenans = ans + str[ary.index(e) - 8].chrelseans = ans + "z"endendprintf(ans + "\n")sock.write(ans + "\n")STDOUT.flushelseendendsock.closeend
フラグは、------------------------------------------Welcome to The Neverending Crypto!Quick, find Falkor and get through this!This is level 1, the BookstoreabcdefghijklmnopqrstuvwxyRound 1. Give me some text:abcdefghijklmnopqrstuvwxy encrypted is .- -... -.-. -.. . ..-. --. .... .. .--- -.- .-.. -- -. --- .--. --.- .-. ... - ..- ...- .-- -..- -.--What is .. --- .-- . -.-- --- ..- decrypted?["What", "is", "..", "_", "---", ".--", ".", "_", "-.--", "---", "..-", "decrypted?"]i owe you:Correct!(略)abcdefghijklmnopqrstuvwxyRound 50. Give me some text:abcdefghijklmnopqrstuvwxy encrypted is .- -... -.-. -.. . ..-. --. .... .. .--- -.- .-.. -- -. --- .--. --.- .-. ... - ..- ...- .-- -..- -.--What is --. .. .- -. - - ..- .-. - .-.. . decrypted?["What", "is", "--.", "..", ".-", "-.", "-", "_", "-", "..-", ".-.", "-", ".-..", ".", "decrypted?"]giant turtle:Correct!abcdefghijklmnopqrstuvwxyRound complete!TUCTF{i_wi11_n0t_5teal}------------------------------------------You take the bookThis is level 2 the attic
TUCTF{i_wi11_n0t_5teal}です。









