@settyan117
みんな
q = p + 8みたいに簡単な式でqを決めるからハックされちゃうんだよ。こんなふうに複雑な関数でpからqを計算してやれば…
初心者向けのヒント:
challenge.pyの実行結果がoutput.txtに保存されています。challenge.pyを読んでみると、secrets.pyからflagという値を読み込み、暗号化して出力していることがわかります。secret.pyは配布ファイルに含まれていないので、challenge.pyとその出力から、flagの中身を突き止めてやりましょう!flagは文字列(正確にはバイト列)ですが、暗号化するためにm = int.from_bytes(flag, 'big')というコードで対応する整数に変換しています。このmを求めることができれば、m.to_bytes((m.bit_length()-1)//8 + 1, 'big')というコードでもとのflagを得ることができます。
You should not use simple function like
f(p) = p + 8to getq. It surely becomes secure iff(p)is complicated!
Hints for beginners:
- The result of running
challenge.pyis stored inoutput.txt. - If you read
challenge.py, you will see that it reads theflagfromsecrets.py, encrypts it, and outputs it. Assecret.pyis not included in distributed files, readchallenge.pycarefully and find the vulnerability! - The original
flagis a string (more precisely, a byte string), but to encrypt it, it is converted to the corresponding integermwith the codem = int.from_bytes(flag, 'big'). If you getm, then you can obtain theflagwith the codem.to_bytes((m.bit_length()-1)//8 + 1, 'big').
beginner