我的逃生功能真的很安全吗? [英] Is my escape function really safe?

查看:145
本文介绍了我的逃生功能真的很安全吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:

在PHP中停止SQL注入的最佳方法

最终的清洁/安全功能

我的网站被sql注入攻击,现在我需要改进。我在PHP 中创建一个函数escape(),它返回一个字符串的转义版本。我不是一个黑客,所以请帮我改善我的逃生功能。以下是当前版本:

My website was attacked via sql injection and now I need to improve it. I'm creating a function in PHP escape(), that returns the escaped version of a string. I'm not a hacker so please help me to improve my escape function. Here is the current version:

function escape($string){

    $string = stripslashes($string);
    $string = mysql_real_escape_string($string);
    $string = strip_tags($string);
    $string = str_replace('%','',$string);
    $string = str_replace('_','',$string);

    return $string;

}

我的问题是:这是可以,如果它比如何解决?谢谢!

My question is: is this hackable, if it is than how to fix it? Thanks!

推荐答案

这个功能绝对与安全无关。

它几乎不能保护你免受某些各种XSS注射。这就是全部。

this function has absolutely nothing to do with safety.
it's barely protects you from some kinds of XSS injections. that's all.

这篇关于我的逃生功能真的很安全吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆