加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

php – 如何防止LDAP注入

发布时间:2020-12-13 13:30:35 所属栏目:PHP教程 来源:网络整理
导读:我们正在构建一个通过php使用LDAP的应用程序,我想到有什么可以做到注入LDAP更好,但更好的是如何防止LDAP注入? 构建LDAP过滤器时,必须确保根据 RFC2254 处理过滤器值: Any control characters with an ACII code 32 as well as the characters with special
我们正在构建一个通过php使用LDAP的应用程序,我想到有什么可以做到注入LDAP更好,但更好的是如何防止LDAP注入?
构建LDAP过滤器时,必须确保根据 RFC2254处理过滤器值:

Any control characters with an ACII
code < 32 as well as the characters
with special meaning in LDAP filters
“*”,“(“,“)”,and “” (the backslash)
are converted into the representation
of a backslash followed by two hex
digits representing the hexadecimal
value of the character.

Zend_Ldap例如使用以下例程

//[...]
$val = str_replace(array('','*','(',')'),array('5c','2a','28','29'),$val);
for ($i = 0; $i<strlen($val); $i++) {
    $char = substr($val,$i,1);
    if (ord($char)<32) {
        $hex = dechex(ord($char));
        if (strlen($hex) == 1) $hex = '0' . $hex;
        $val = str_replace($char,'' . $hex,$val);
    }
}
//[...]

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读