2008-07-15 (火)
■ ヌルバイト攻撃への対策
以下の記事に対するツッコミ。
で、これをPHPで対処するには下記のコードを使えとある。もちろん他のどのサイトをみてもそうしろと書いてある。
// 終端文字列を空に $v = str_replace( "\0", '', $v );ただし、このコード、自分が試したPHP4系ではまったくもってスルーされてしまい、例えば値が空の場合を期待するようなコード、
If($v == '' ){ echo 'hello'; }なんてのは格好の餌食。なぜなら\0が入ってるのでマッチしないから。。。正しく動くコードは下記の通り。
// 終端文字列を空に $v = str_replace( '\0', '', $v );なんてことはなく、"(ダブルクォーテーション)を'(シングルクォーテーション)に変えるだけなのだけど、PHP5系だと逆の動作になるところがまたややこしい。。。ちなみに、微妙だけどちゃんと空にしているかは下記のコマンドで検証できる。
wget --post-data="v=%00" http://foo.com/bar.php※ 08/04/28追記 php-5.2.6では'\0'や"\\0"じゃないとマッチしないことを確認。。。
そんなばかな、と思ったので確認してみる。
<?php
$str = "abc\0def";
echo bin2hex($str) . "\n";
echo bin2hex(str_replace("\0", '', $str)) . "\n";
これを実行すると、私のところでは、
61626300646566 616263646566
と表示されて、ちゃんと "\0" で NULL 文字を表せるんですけどねぇ。 (Debian の PHP 4.3.10 と PHP 5.2.6 で確認)
[コメントを書く]
本日のリンク元
- 14 http://codezine.jp/bookmark/hatena.aspx
- 13 http://www.google.co.jp/ig?hl=ja
- 12 http://b.hatena.ne.jp/entry/http://www.revulo.com/...
- 11 google検索(ヌルバイト攻撃)
- 7 google検索(ヌルバイト攻撃)
- 7 http://www.google.co.jp/
- 7 http://labs.ceek.jp/hbnews/list.cgi
- 6 google検索(ヌルバイト)
- 5 google検索(php ヌルバイト)
- 4 http://www.google.co.jp/webhp?hl=ja
- 4 google検索(ヌルバイト攻撃)
- 4 http://www.google.co.jp/reader/view/
- 4 http://d.hatena.ne.jp/hotkeyword
- 4 http://codezine.jp/bookmark/hatena.aspx?dt=2008071...
- 3 http://www.revulo.com/
- 3 google検索(ヌルバイト攻撃)
- 3 google検索(PHP ヌルバイト)
- 3 google検索(ヌルバイト)
- 3 google検索(ヌルバイト攻撃)
- 3 google検索(ヌルバイト攻撃)
- 3 http://www.google.co.jp/ig?hl=ja&source=iglk
- 3 http://codezine.jp/bookmark/hatena.aspx?dt=2008071...
- 2 http://www.mixclips.org/recent/3/
- 2 google検索(php ヌルバイト)
- 2 google検索(ヌルバイト)
- 2 google検索(ヌルバイト攻撃)
- 2 google検索(ヌルバイト攻撃)
- 2 google検索(ヌルバイ)
- 2 google検索(ヌルバイト攻撃 対策)
- 2 google検索(ヌルバイト攻撃 対処法)
- 2 google検索(ヌルバイト 対策)
- 2 google検索(php ヌルバイト攻撃)
- 2 google検索(ヌルバイト攻撃)
- 2 google検索(ヌルバイト攻撃)
- 2 google検索(ヌルバイト攻撃対策)
- 2 google検索(ヌルバイト攻撃)
- 2 google検索(ヌルバイト)
- 2 http://www.google.co.jp/reader/view/?hl=ja&utm_sou...
- 2 http://planet.php.gr.jp/delphinus.php
- 2 http://labs.ceek.jp/hbnews/
- 2 http://feed.hotphpper.net/
- 2 http://d.hatena.ne.jp/f-star/20080716/p19
- 2 http://d.hatena.ne.jp/f-star/20080716
- 1 http://www.revulo.com/notify-NotifyUser_NONE_07121...
- 1 http://www.mixclips.org/recent/
- 1 google検索(php ヌルバイト)
- 1 google検索(ヌルバイト)
- 1 google検索(ヌルバイト攻撃)
- 1 google検索(php ヌルバイト)
- 1 google検索(POST 攻撃 PHP)
- 1 google検索(ヌルバイト攻撃 )
- 1 google検索(ヌルバイト攻撃)
- 1 google検索(れぶろぐ)
- 1 google検索(php NULL文字対策)
- 1 google検索(php ヌルバイト)
- 1 google検索(ヌルバイト攻撃)
- 1 google検索(php ヌルバイト)
- 1 google検索(phpで攻撃)
- 1 google検索(ヌルバイト攻撃)
- 1 google検索(zend framework ヌルバイト)
- 1 google検索(ヌルバイト php)
- 1 google検索(php bin2hex 逆)
- 1 google検索(ヌルバイト攻撃 対策)
- 1 google検索(・ヌルバイト攻撃)
- 1 google検索(ヌルバイト攻撃)
- 1 google検索(php 攻撃)
- 1 google検索(ヌルバイト攻撃 PHP)
- 1 google検索(str_replace("\0",)
- 1 google検索(PHP ヌルバイト)
- 1 google検索(php ヌルバイト)
- 1 http://www.google.co.jp/webhp?rls=ig
- 1 google検索(ヌルバイト攻撃)
- 1 google検索(PHP 攻撃)
- 1 google検索(ヌルバイト)
- 1 google検索(ヌルバイト攻撃)
- 1 google検索(ヌルバイト攻撃)
- 1 google検索(ヌルバイト 攻撃)
- 1 google検索(ヌルバイト PHP)
- 1 google検索(php str_replace \0)
- 1 google検索(php 攻撃)
- 1 google検索(t)
- 1 google検索(t)
- 1 google検索(t)
- 1 google検索(ヌルバイト php)
- 1 google検索(ヌルバイト)
- 1 google検索(ヌルバイト攻撃)
- 1 google検索(php ヌルバイト)
- 1 google検索(ヌルバイト攻撃)
- 1 google検索(php 攻撃)
- 1 google検索(php ヌルバイト)
- 1 google検索(php ヌルバイト攻撃)
- 1 google検索(PHP 攻撃)
- 1 google検索(PHP 攻撃)
- 1 google検索(PHP ヌルバイト)
- 1 google検索(ファイル名 変更 ヌルバイト)
- 1 google検索(ヌルバイト PHP)
- 1 google検索(ヌルバイト PHP)
- 1 google検索(ヌルバイト PHP)
- 1 google検索(ヌルバイト OR nullbyte 対策)
- 1 google検索(ヌルバイト文字 ファイル名)
