ファイル sesame.pyc が与えられた。
まず、.pyc ファイルの逆アセンブル方法を
A file sesame.pyc was given.
Firstly I asked how to disassemble .pyc files to
Perplexity AI: How to disassemble .pyc files?
その結果を参考に、以下のコマンドで解析を行った。
According to the result, I performed an analysis using these commands.
以下の結果が得られた。
Ths is the result.
入力した文字列の文字コードを縦ベクトルとして gencave 関数が返す行列とかけ合わせ、結果が DOOR_SHAPE と一致するかをチェックしているようである。
しかし、この gencave 関数は、ループの条件である cave を書き換えるコードが for p in ps: の中にしか無く、
ps が空であるためこの中は実行されないので、無限ループとなっている。
gencave 関数の処理は素数を列挙する処理に似ているようだったので、素数を列挙するように修正し、掛けた結果が DOOR_SHAPE になるベクトルをガウスの消去法で求める以下のプログラムを作成した。
This code multiplies the character codes of the entered string as a column vector with a matrix returned from the gencave function, and checks if the product equals to DOOR_SHAPE.
However, the gencave function performs an infinite loop because cave, used in the loop condition, is modified only inside for p in ps:,
and the inner part won't be executed because the list ps is empty.
The function looked similar to a program that enumerates prime numbers, so I adjusted that to enumerate prime numbers, and wrote this program to calculate a vector multiplying that yields DOOR_SHAPE using Gaussian elimination.
このプログラムによりflagが得られた。
I obtained the flag from this program.