欢迎光临 随枫玉雨的个人网站

PHP5.4版本适用的SQL防注入代码

这是在PHP5.4上测试通过的防注入代码,由于新版本php已经抛弃eregi函数,
使用中会报错Function eregi() is deprecated,以上代码经过修正,可在php5.4上正常运行。
测试方法为在php文件名后加参数,例如http://127.0.0.1/index.php?id=select

<?php
function inject_check($sql_str)
{
   return preg_match(“/select|insert|update|delete|\’|\`|\/\*|\*|\.\.\/|\.\/|union|into|load_file|outfile/i”, $sql_str);     // 进行关键字过滤
}
if(!empty($_GET[‘id’])){
if (inject_check($_GET[‘id’])) exit(‘发现注入参数’);
echo $sql = “select * from `table` where `id` ='”.$_GET[‘id’].”‘”;
}
?>

 

BY:随枫玉雨 http://www.sdhack.com qq号码免费申请 申请qq号免费 免费申请qq号

 

QQ号码免费申请,申请QQ号免费,免费申请QQ号,QQ版本更新官方网站

关于我们加入我们