bWAPP----SQL Injection (GET/Search)

SQL Injection (GET/Search)

输入单引号

报错,在%'附近出错,猜测参数被 '%  %'这种形式包裹,没有任何过滤,直接带入了数据库查询

 

输入order by查询列

union select 确定显示位

然后分别查询用户,数据库名,数据库版本

 

根据数据库版本知道可以通过information_schema表查询信息,查询table_name,从information_schema.tables

 

查询当前数据库的tablename

查询users表的列

 

查询字段的内容

 

贴上源码

 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 }

 

 

转载于:https://www.cnblogs.com/hongren/p/7225250.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值