输入单引号php
报错,在%'附近出错,猜想参数被 '% %'这种形式包裹,没有任何过滤,直接带入了数据库查询mysql
输入order by查询列sql
union select 肯定显示位数据库
而后分别查询用户,数据库名,数据库版本fetch
根据数据库版本知道能够经过information_schema表查询信息,查询table_name,从information_schema.tablesspa
查询当前数据库的tablename3d
查询users表的列code
查询字段的内容orm
贴上源码blog
1 <?php 2 if(isset($_GET["title"])) 3 { 4 5 $title = $_GET["title"]; 6 7 $sql = "SELECT * FROM movies WHERE title LIKE '%" . sqli($title) . "%'"; 8 9 $recordset = mysql_query($sql, $link); 10 11 if(!$recordset) 12 { 13 14 // die("Error: " . mysql_error()); 15 16 ?> 17 18 <tr height="50"> 19 20 <td colspan="5" width="580"><?php die("Error: " . mysql_error()); ?></td> 21 <!-- 22 <td></td> 23 <td></td> 24 <td></td> 25 <td></td> 26 --> 27 28 </tr> 29 <?php 30 31 } 32 33 if(mysql_num_rows($recordset) != 0) 34 { 35 36 while($row = mysql_fetch_array($recordset)) 37 { 38 39 // print_r($row); 40 41 ?>
防护代码
function sqli($data) { switch($_COOKIE["security_level"]) { case "0" : $data = no_check($data); break; case "1" : $data = sqli_check_1($data); break; case "2" : $data = sqli_check_2($data); break; default : $data = no_check($data); break;
low
没有过滤
medium
function sqli_check_1($data) { return addslashes($data);
high
1 function sqli_check_2($data) 2 { 3 4 return mysql_real_escape_string($data); 5 6 }