首 页文章中心黑客工具黑吧学院技术论坛安全培训免费频道最近更新瑞星在线杀毒黑吧百度繁體中文
  设为首页
加入收藏
发布作品
   
栏目导航
· 漏洞公告
热门文章
· 如何封别人QQ
· 充QQ币的疯狂——宽...
· 免费得QB
· 400秒远程攻破你的Q...
· [图文] QQ免费建400个群
· [组图] 给你一台永远不关机...
· [注意] QQ宠物砸蛋秘诀
· 再次有机会免费获得...
· 想的挂QQvip的进
· 在QQ中将自己从对方...
相关文章
php utf8 decode漏洞
作者:佚名  来源:转载  发布时间:2008-10-9 3:01:16  发布人:黑客动画吧

减小字体 增大字体

漏洞说明: php是一款被广泛使用的编程语言,可以被嵌套在html里用做web程序开发。但是在php里使用的某些编码函数在处理畸形的utf8序列时会产生不正确的结果,这样在某些情况下可能会引起应用程序的安全漏洞,绕过某些逻辑过滤等等。

漏洞成因:php在处理utf8编码时,对畸形的序列处理不当,如

...
0xc0a7
0xe0c0a7
0xf0c0c0a7
...

均会被错误地解码为一个0×27,这样就导致安全漏洞的产生。譬如utf8_decode函数的源代码如下:
PHPAPI char *xml_utf8_decode(const XML_Char *s, int len, int *newlen, const XML_Char *encoding)
{
int pos = len;
char *newbuf = emalloc(len + 1);
unsigned short c;
char (*decoder)(unsigned short) = NULL;
xml_encoding *enc = xml_get_encoding(encoding);
*newlen = 0;
if (enc) {
decoder = enc->decoding_function;
}
if (decoder == NULL) {
/* If the target encoding was unknown, or no decoder function
* was specified, return the UTF-8-encoded data as-is.
*/
memcpy(newbuf, s, len);
*newlen = len;
newbuf[*newlen] = ‘\0′;
return newbuf;
}
while (pos > 0) {
c = (unsigned char)(*s);
if (c >= 0xf0) { /* four bytes encoded, 21 bits */
c = ((s[0]&7)<<18) | ((s[1]&63)<<12) | ((s[2]&63)<<6) | (s[3]&63);
s += 4;
pos -= 4;
} else if (c >= 0xe0) { /* three bytes encoded, 16 bits */
c = ((s[0]&63)<<12) | ((s[1]&63)<<6) | (s[2]&63);
s += 3;
pos -= 3;
} else if (c >= 0xc0) { /* two bytes encoded, 11 bits */
c = ((s[0]&63)<<6) | (s[1]&63);
s += 2;
pos -= 2;
} else {
s++;
pos–;
}
newbuf[*newlen] = decoder ? decoder(c) : c;
++*newlen;
}
if (*newlen < len) {
newbuf = erealloc(newbuf, *newlen + 1);
}
newbuf[*newlen] = ‘\0′;
return newbuf;
}

xml_utf8_decode函数被广泛用于xml和wddx的编码处理中,在处理utf8编码时并没有严格按照utf8的解码规则来校验数据的正确性,导致出现问题。另外在php的htmlspecialchars等函数中处理utf8编码时也存在类似问题。

漏洞测试:
<?php
$ill=chr(0xf0).chr(0xc0).chr(0xc0).chr(0xa7);
$ill=addslashes($ill);
echo utf8_decode("$ill");
echo htmlspecialchars ($ill,ENT_QUOTES,"utf-8" );
?>

漏洞影响:可能影响所有php版本
漏洞状态:已经通知php官方
本站内容均为原创,转载请务必保留署名与链接!
php utf8 decode漏洞:http://www.80sec.com/php-utf8-decode-vul.html
[ ] [返回上一页] [打 印] [收 藏]
下一篇文章:路由器的利用与渗透
 
关于本站 - 网站帮助 - 广告合作 - 下载声明 - 网站导航 - 作品发布
互联网备案登记:粤ICP备05008775号
友情提示:浏览本站,请使用IE6.0浏览,并将分辩率设置为1024*768 为佳
Copyright © 2002-2005 Hack58.Com. All Rights Reserved .