プログラム knapsack.py とその出力 output.txt が与えられた。
output.txt の内容は、整数のリストb と整数 c だった。
「knapsack cipher writeup」でググると、以下のページが見つかった。
A program knapsack.py and its output output.txt were given.
The contents of output.txt was a list of integers b and an integer c.
I googled "knapsack cipher writeup" and found this page:
PlaidCTF CTF 2015: Lazy - うさぎ小屋
このページのimplementationの部分に書かれているコードをbとcをファイルから読む部分をoutput.txtの内容を直接代入するコードに置き換えた。
さらに、printの行に()を補って実行すると、以下の結果(抜粋)が得られた。
I copy-and-pasted the code in the "implementation" part of the page to b and c from a file to a code to directly assign the contents of output.txt.
I also added () to the line with print and executed the code. The (excerpt of) result was:
この数値を110011が最後の方に現れることを発見した。
そこで、ビット列をひっくり返して先頭に0を追加し、文字列に変換すると、flagが得られた。
I put this number to 110011 for "f" in "flag" appearing in the last part when I convert the number to binary.
I obtained the flag by reversing the bit sequence, adding 0 to the head, and converting to a string.