研究了下replace的注入安全问题。
一般sql注入的过滤方式就是引用addslashes函数进行过滤。

他会把注入的单引号转换成\',把双引号转换成\",反斜杠会转换成\\等
写一段php代码:
<!DOCTYPE html>
<html>
<head>
 <title></title>
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
</head>
<body>
<?php
 $x=$_GET['x'];
 $id=str_replace(addslashes($_GET['y']),'',addslashes($x));
 echo "过滤后:".addslashes($x)."<br/>";
 echo "replace替换绕过:".$id."<br/>";
 $conn = mysql_connect('127.0.0.1','root','root');//连接mysql数据库 
 mysql_select_db('test',$conn);//选择$conn连接请求下的test数据库名 
 $sql = "select * from user1 where id='$id'";//定义sql语句并组合变量id 
 $result = mysql_query($sql);//执行sql语句并返回给变量result 
 while($row = mysql_fetch_array($result)){//遍历数组数据并显示 
  echo "ID".$row['id']."</br>"; 
  echo "用户名".$row['name']."</br>"; 
 } 
 mysql_close($conn);//关闭数据库连接 
 echo "<hr>"; 
 echo "当前语句:"; 
 echo $sql;
?>
</body>
</html>
发现是引用了addslashes函数的:

一个单引号或者双引号直接被转义,字符串注入到这里基本上gg了。没戏了。
addslashes的问题:
addslashes会把