Level 2は、a~yの入力に対して、以下の通り、n~z{|}~と半角スペースに戻って'(シングルクォーテーション)に暗号化されます。zは'(シングルクォーテーション)の次の(に暗号化されると思われます。したがって、-(ハイフン)だけが以上のルールから外れますので半角スペースに対応する暗号化と思われます。The Neverending Crypto Level 2
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
"------------------------------------------\n""You take the book\n""This is level 2 the attic\n""Round 1. Give me some text:abcdefghijklmnopqrstuvwxy encrypted is nopqrstuvwxyz{|}~ !\"\#$%&'\n"
["n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "{", "|", "}", "~", " ", "!", "\"", "#", "$", "%", "&", "'"]
"What is z||{-puvyq decrypted?\n"
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 |
n | o | p | q | r | s | t | u | v | w | x | y | z | { | | | } | ~ | ! | " | # | $ | % | & | ' | ( |
このルールをLevel 1で書いたRubyプログラムに追加します。
実行すると、Level 2を50問解いた後にフラグが表示されます。require "socket"beginsock = TCPSocket.open("146.148.102.236", 24069)rescueputs "TCPSocket.open failed : #$!\n"elselevel = 1while sock.getsbuf = $_p bufif buf.start_with?("This is level 1") or buf.include?("Correct!") thenstr = "abcdefghijklmnopqrstuvwxy"printf(str + "\n")sock.write(str + "\n")STDOUT.flushelsif buf.include?(" encrypted is ") thenif level == 1 thenary = buf.split(" ")elsif level == 2 thenbuf = buf[buf.index("encrypted is ") + "encrypted is ".length, str.length]ary = buf.split("")p aryend#p aryelsif buf.start_with?("What is") thenans = ""if level == 1 thenenc = buf.gsub(/\s\s\s/, " _ ").split(" ")#p encfor 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"endendelsif level == 2 thenbuf.slice!("What is ")buf.slice!(" decrypted?\n")enc = buf.split("")p encfor e in enc doif ary.index(e) thenans = ans + str[ary.index(e)].chrelsif e == "-" thenans = ans + " "elseans = ans + "z"endendendprintf(ans + "\n")sock.write(ans + "\n")STDOUT.flushelsif buf.start_with?("Round complete!") thenlevel += 1elseendendsock.closeend
(略)"------------------------------------------\n""You take the book\n""This is level 2 the attic\n""Round 1. Give me some text:abcdefghijklmnopqrstuvwxy encrypted is nopqrstuvwxyz{|}~ !\"\#$%&'\n"["n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "{", "|", "}", "~", " ", "!", "\"", "#", "$", "%", "&", "'"]"What is z||{-puvyq decrypted?\n"["z", "|", "|", "{", "-", "p", "u", "v", "y", "q"]moon child":Correct!\n"(略)"Round 50. Give me some text:abcdefghijklmnopqrstuvwxy encrypted is nopqrstuvwxyz{|}~ !\"\#$%&'\n"["n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "{", "|", "}", "~", " ", "!", "\"", "#", "$", "%", "&", "'"]"What is %ryp|zr-n\" r'# decrypted?\n"["%", "r", "y", "p", "|", "z", "r", "-", "n", "\"", " ", "r", "'", "#"]welcome atreyu":Correct!\n"abcdefghijklmnopqrstuvwxy"Round complete!\n""TUCTF{c4n_s0me0ne_turn_a_1ight_0n}\n"
TUCTF{c4n_s0me0ne_turn_a_1ight_0n}