phpinfo.phpとかやめようよ このエントリをはてなブックマークに>追加

PHPの関数にphpinfo()というものがあり、これをPHPファイルに含めるとPHPの設定・動作状況が分かるので使ったことのある方は多いだろう。しかしそのPHPファイルをサイトのドキュメント・ルートに、「phpinfo.php」や「info.php」などと非常に分かりやすい名前で設置している例を非常によく見かける。1度や2度ではない。

本人はすぐ消すから大丈夫だと思ってそうしているのだろうが、人間は忘れる動物である。その証拠に私が発見した事例は全て「運用中」のサイトであり、つまりは「消し忘れ」であった。

PHPの設定・動作状況を他人に晒すことは、セキュリティ・ホールの発見のお手伝いをしているのと同じなのでもっと注意深く設置する必要がある。

対策の一つとしては、パスワードで保護された領域にこれを置くことである。しかしこれは現実性を欠く。既にそういう領域があるならよいが、たかが設定情報をみるためにパスワードで保護された領域を作るなんて面倒だ(大抵の場合、phpinfo()を使うのは急いでいる時である)。面倒なことは人間はやらない。やらないから「phpinfo.php」を置いてしまう。

現実的な対策としては、パスワードのように慎重に選ばれたランダムな文字列をファイル名に使うことだ。Webブラウザ側から当該ディレクトリの内容を表示できないようにしておくのは言うまでもない。

「ランダムな文字列」と言ってもキーボードをデタラメに打たない方がいい。これは概して同じような文字列を生みやすい(それでも「phpinfo.php」よりは幾分マシである)。手軽なのはmkpasswdのようなコマンドを利用するか、ユーザーの目に触れない適当なファイルのハッシュ値を利用するものである。強度については保証しない。「phpinfo.php」に比べればずっとマシだということだ。例を示す。

% md5 /HTTPDDIR/logs/error_log
MD5 (/HTTPDDIR/logs/error_log) = d2ab851dc39a79617a41ce44323b5bbc
% echo '<?php phpinfo(); ?>' > d2ab851dc39a79617a41ce44323b5bbc.php                  

当然、確認が終わったらそのファイルは削除されなければならない。大抵のシェルには補完機能があるのだから、ファイルを選択するのはそう苦ではないはずだ。

追記

phpinfo.phpをgoogleで検索してみたら、なんと日本だけで1万件、Web全体で30万件ものヒットがあった。これを設置して動かなくて困っているもの、チュートリアルとして設置することを指示しているもの、中にはプロバイダのマニュアルの中にさえphpinfo.phpを作れという表記が見受けられた。時にはBASIC認証をコード中に科している几帳面な方もいたが、ほとんどは無防備である。「あとで消すこと」を推奨していないサイトが多いのにも驚いた。思いのほかphpinfo.php病は進行しているようだ。

29 件のコメント - “phpinfo.phpとかやめようよ”

  1. Highland Property Management のコメント

    Awesome website

    […]the time to read or visit the content or sites we have linked to below the[…]…

  2. gift baskets toronto のコメント

    Superb website

    […]always a big fan of linking to bloggers that I love but don’t get a lot of link love from[…]…

  3. Solar Panels のコメント

    Yahoo results

    While browsing Yahoo I found this page in the results and I thought it looked interesting

  4. Estate agents Edinburgh のコメント

    Dreary Day

    It was a dreary day here today, so I just took to messing around online and realized

  5. webcam sex のコメント

    Read was interesting, stay in touch…

    […]please visit the sites we follow, including this one, as it represents our picks from the web[…]…

  6. people planking のコメント

    Online Article…

    […]The information mentioned in the article are some of the best available […]…

  7. gamesgames games のコメント

    You should check this out

    […] Wonderful story, reckoned we could combine a few unrelated data, nevertheless really worth taking a look, whoa did one learn about Mid East has got more problerms as well […]…

  8. Christmas dessert recipes のコメント

    Cool site, I hope mine will be this good some day

    […]My partner and I stumbled over here by a different web address and thought I might check things out. I like what I see so i am just following you. Look forward to looking at your web page for a second time.[…]

  9. neumaticos madrid のコメント

    Websites you should visit

    […]below you’ll find the link to some sites that we think you should visit[…]…

  10. Sophia Allison のコメント

    Sources

    […]check below, are some totally unrelated websites to ours, however, they are most trustworthy sources that we use[…]…

  11. Gera のコメント

    You should check this out

    […] Wonderful story, reckoned we could combine a few unrelated data, nevertheless really worth taking a look, whoa did one learn about Mid East has got more problerms as well […]…

  12. Slow Computer のコメント

    Interesting….

    A very unique post.

  13. Brisbane copywriter のコメント

    Websites we think you should visit

    […]although websites we backlink to below are considerably not related to ours, we feel they are actually worth a go through, so have a look[…]…

  14. Egg Pudding Recipe のコメント

    Great website…

    […]here are some hyper-links to sites that we link to as we feel they are really worth browsing[…]…

  15. AMG Services のコメント

    Blogs ou should be reading

    […]Here is a Great Blog You Might Find Interesting that we Encourage You[…]…

  16. AMG Services のコメント

    Sites we Like…

    […] Every once in a while we choose blogs that we read. Listed below are the latest sites that we choose […]…

  17. Solar Panels のコメント

    Informative and precise

    Its hard to find informative and accurate info but here I found

  18. Sua banda no site balada365 のコメント

    Interesting….

    A very interesting post.

  19. black pumps shoes のコメント

    Websites worth visiting

    […]here are some links to sites that we link to because we think they are worth visiting[…]…

  20. excel class のコメント

    Sites we Like…

    […] Every once in a while we choose blogs that we read. Listed below are the latest sites that we choose […]…

  21. solar panels のコメント

    Tumblr article

    I saw someone talking about this on Tumblr and it linked to

  22. how to make a girl squirt のコメント

    Visitor recommendations

    […]one of our visitors recently recommended the following website[…]…

  23. how to pay off my credit card のコメント

    Sources

    […]check below, are some totally unrelated websites to ours, however, they are most trustworthy sources that we use[…]…

  24. biznes のコメント

    Recent Blogroll Additions…

    […]usually posts some very interesting stuff like this. If you’re new to this site[…]…

  25. equity release のコメント

    Superb website

    […]always a big fan of linking to bloggers that I love but don’t get a lot of link love from[…]…

  26. hemsida のコメント

    Visitor recommendations

    […]one of our visitors recently recommended the following website[…]…

  27. buy secret commission system のコメント

    Gems form the internet

    […]very few websites that happen to be detailed below, from our point of view are undoubtedly well worth checking out[…]…

  28. IT Certifications のコメント

    Cheers,Well it appears this internet site is somewhat sizzling, congratulations towards the owner! I try to go .through as much as feasible on the web when I’ve extra time. However it is beginning to get the norm for men and women to invest all day for the internet instead of of basically,By far the most concise and up to date information I have found on this topic.

  29. IT Exams のコメント

    Hey there could you please tell me which hosting company you’re working with? Also can you recommend an honest web hosting provider at a normal price? Thank you, in advance!

コメントをどうぞ。

使用できる XHTML タグ : <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>