关于magic_quotes_sybase 's

admin 2017年5月2日03:45:08评论319 views字数 1455阅读4分51秒阅读模式
摘要

当php.ini设置magic_quotes_sybase为on时会覆盖magic_quotes_gpc为on的处理,然而magic_quotes_sybase仅仅是转义了nullbyte和把’变成了” :)

当php.ini设置magic_quotes_sybase为on时会覆盖magic_quotes_gpc为on的处理,然而magic_quotes_sybase仅仅是转义了nullbyte和把’变成了” 关于magic_quotes_sybase  's

author: ryat#wolvez.org
team:http://www.80vul.com
date:2009-04-14

一 描叙

magic_quotes_gpc为on时,php在注册变量时会调用addslashes()函数处理[既转义单引号、双引号、反斜线和nullbyte],但php.ini中还有另外一个选项影响着magic_quotes_gpc和addslashes()函数:当php.ini设置magic_quotes_sybase为on时会覆盖magic_quotes_gpc为on的处理,然而magic_quotes_sybase仅仅是转义了nullbyte和把’变成了”

二 分析

先来看下addslashes的php源码:

// string.c PHPAPI char *php_addslashes(char *str, int length, int *new_length, int should_free TSRMLS_DC) {  return php_addslashes_ex(str, length, new_length, should_free, 0 TSRMLS_CC); } ... PHPAPI char *php_addslashes_ex(char *str, int length, int *new_length, int should_free, int ignore_sybase TSRMLS_DC) { ...  if (!ignore_sybase && PG(magic_quotes_sybase)) { // 如果ignore_sybase=0[默认为0]且magic_quotes_sybase为on就执行下面的代码   while (source < end) {    switch (*source) {     case '/0':      *target++ = '//';      *target++ = '0';      break;     case '/'':      *target++ = '/'';      *target++ = '/'';      break;     default:      *target++ = *source;      break;    }    source++; // 从上面的代码可以看到只是把null变成了/0,'变成了''   }  } else { // 执行常规的转义 ...

由上面的代码可以看到,如果magic_quotes_sybase为on就会覆盖magic_quotes_gpc为on时的默认处理效果[而magic_quotes_sybase仅仅是转义了nullbyte和把’变成了” :)]

然后我们看看关于magic_quotes_sybase定义的部分:

// main.c  STD_PHP_INI_BOOLEAN("magic_quotes_sybase", "0",  PHP_INI_ALL,  OnUpdateBool,   magic_quotes_sybase, php_core_globals, core_globals)

可以看到,magic_quotes_sybase在php.ini里默认是关闭的,但是属于PHP_INI_ALL类型的指令,那么就可以在.htaccess或者httpd.conf里来更改magic_quotes_sybase的设置了. 如:
// .htaccess
php_flag magic_quotes_sybase on

三 测试代码

四 实际应用

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2017年5月2日03:45:08
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   关于magic_quotes_sybase 'shttp://cn-sec.com/archives/44749.html

发表评论

匿名网友 填写信息