php如何快速查找数据库中恶意代码

发布时间:2021-09-02 11:43:18 作者:小新
来源:亿速云 阅读:136

这篇文章主要为大家展示了“php如何快速查找数据库中恶意代码”,内容简而易懂,条理清晰,希望能够帮助大家解决疑惑,下面让小编带领大家一起研究并学习一下“php如何快速查找数据库中恶意代码”这篇文章吧。

具体如下:

数据库被输入恶意代码,为了保证你的数据库的安全,你必须得小心去清理。有了下面一个超级方便的功能,即可快速清除数据库恶意代码。

function cleanInput($input) {
 $search = array(
  '@]*?>.*?@si', // Strip out javascript
  '@<[\/\!]*?[^<>]*?>@si', // Strip out HTML tags
  '@
]*?>.*?
@siU', // Strip style tags properly
  '@@' // Strip multi-line comments
 );
  $output = preg_replace($search, '', $input);
  return $output;
 }
function sanitize($input) {
  if (is_array($input)) {
    foreach($input as $var=>$val) {
      $output[$var] = sanitize($val);
    }
  }
  else {
    if (get_magic_quotes_gpc()) {
      $input = stripslashes($input);
    }
    $input = cleanInput($input);
    $output = mysql_real_escape_string($input);
  }
  return $output;
}
// Usage:
$bad_string = "Hi! It's a good day!";
$good_string = sanitize($bad_string);
// $good_string returns "Hi! It\'s a good day!"
// Also use for getting POST/GET variables
$_POST = sanitize($_POST);
$_GET = sanitize($_GET);

以上是“php如何快速查找数据库中恶意代码”这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注亿速云行业资讯频道!

推荐阅读:
  1. 初识恶意代码之------网络蠕虫
  2. 防止恶意代码注入XSS(cross site scripting)

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

php 数据库

上一篇:php如何上传图片客户端和服务器端

下一篇:VS2012发布网站的详细步骤

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》