漏洞复现------Webmin 远程命令执行漏洞(CVE-2019-15107)

一,webmin简介

什么是webmin

  • Webmin是目前功能最强大的基于Web的Unix系统管理工具。管理员通过浏览器访问Webmin的各种管理功能并完成相应的管理动作
    http://www.webmin.com/
  • Webmin 是一个用 Perl 编写的基于浏览器的管理应用程序。
  • 是一个基于Web的界面,用于Unix的系统管理。使用任何支持表和表单的浏览器,可以设置用户帐户,Apache,DNS,文件共享等。

.
为什么用webmin

  • Linux系统因其高效稳定而受到广大用户的推崇与青睐,然后其管理有一定复杂性和学习周期。为了降低 Linux系统的管理难度,有时候会对公司内的Linux主机或VPS系统预装了网页管理工具webmin.

  • 在这里插入图片描述


二,漏洞概述

1、漏洞编号:CVE-2019-15107

2、漏洞描述:该漏洞允许恶意第三方在缺少输入验证的情况下而执行恶意代码

该漏洞由于password_change.cgi文件在重置密码功能中存在一个代码执行漏洞,该漏洞允许恶意第三方在缺少输入验证的情况下而执行恶意代码

3、受影响的版本:Webmin<=1.920

4,漏洞利用条件:版本满足要求,且服务器的配置文件允许修改密码时,在不知道webmin的用户和密码条件下,可以任意执行代码。


三,漏洞复现

(1)环境搭建

环境:webmin 1.910

使用docker搭建,在vulhub项目中有webmin漏洞复现的环境
在这里插入图片描述

https://192.168.44.144:10000/

在这里插入图片描述

首先进入容器,修改root用户密码(不然无法登录的啊。。。)

在这里插入图片描述

再次登录
在这里插入图片描述

    漏洞需要开启密码重置功能。
    
     在控制界面 https://ip:10000/webmin/edit_session.cgi?xnavigation=1

在这里插入图片描述

在服务器上查看webmin的配置文件

 cat /etc/webmin/miniserv.conf 

在这里插入图片描述

(2)exp

抓包获得改密码的请求包

POST /password_change.cgi HTTP/1.1
Host: 192.168.44.144:10000
Connection: close
Content-Length: 52
Cache-Control: max-age=0
Origin: https://192.168.44.144:10000
Upgrade-Insecure-Requests: 1
Content-Type: application/x-www-form-urlencoded
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36
Sec-Fetch-Mode: navigate
Sec-Fetch-User: ?1
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3
Sec-Fetch-Site: same-origin
Referer: https://192.168.44.144:10000/session_login.cgi
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.9
Cookie: redirect=1; testing=1; sessiontest=1; sid=x

user=root&pam=1&expired=2&old=123456&new1=11&new2=11
  • 在这里插入图片描述

尝试利用 || 执行命令

  • 在这里插入图片描述

思考之后,考虑有可能root是系统用户,而不是webmin的用户

尝试随便写一个用户和密码

在这里插入图片描述

尝试执行反弹shell命令
①kali监听9000端口
.
②用burp suite ,对命令编码后执行

  • 在这里插入图片描述
    在这里插入图片描述
    .

③kali收到shell

  • 在这里插入图片描述

四,漏洞分析

出问题的地方就是这个password_change.cgi

  1 #!/usr/bin/perl
  2 # password_change.cgi
  3 # Actually update a user's password by directly modifying /etc/shadow
  4 
  5 BEGIN { push(@INC, "."); };
  6 use WebminCore;
  7 
  8 $ENV{'MINISERV_INTERNAL'} || die "Can only be called by miniserv.pl";
  9 &init_config();
 10 &ReadParse();
 11 &get_miniserv_config(\%miniserv);
 12 $miniserv{'passwd_mode'} == 2 || die "Password changing is not enabled!";
 13 
 14 # Validate inputs
 15 $in{'new1'} ne '' || &pass_error($text{'password_enew1'});
 16 $in{'new1'} eq $in{'new2'} || &pass_error($text{'password_enew2'});
 17 
 18 # Is this a Webmin user?
 19 if (&foreign_check("acl")) {
 20         &foreign_require("acl", "acl-lib.pl");
 21         ($wuser) = grep { $_->{'name'} eq $in{'user'} } &acl::list_users();
 22         if ($wuser->{'pass'} eq 'x') {
 23                 # A Webmin user, but using Unix authentication
 24                 $wuser = undef;
 25                 }
 26         elsif ($wuser->{'pass'} eq '*LK*' ||
 27                $wuser->{'pass'} =~ /^\!/) {
 28                 &pass_error("Webmin users with locked accounts cannot change ".
 29                             "their passwords!");
 30                 }
 31         }
 32 if (!$in{'pam'} && !$wuser) {
 33         $miniserv{'passwd_cindex'} ne '' && $miniserv{'passwd_mindex'} ne '' ||
 34                 die "Missing password file configuration";
 35         }
 37 if ($wuser) {
 38         # Update Webmin user's password
 39         $enc = &acl::encrypt_password($in{'old'}, $wuser->{'pass'});
 40         $enc eq $wuser->{'pass'} || &pass_error($text{'password_eold'},qx/$in{'old'}/);
 41         $perr = &acl::check_password_restrictions($in{'user'}, $in{'new1'});
 42         $perr && &pass_error(&text('password_enewpass', $perr));
 43         $wuser->{'pass'} = &acl::encrypt_password($in{'new1'});
 44         $wuser->{'temppass'} = 0;
 45         &acl::modify_user($wuser->{'name'}, $wuser);
 46         &reload_miniserv();
 47         }
 48 elsif ($gconfig{'passwd_cmd'}) {
 49         # Use some configured command
 50         $passwd_cmd = &has_command($gconfig{'passwd_cmd'});
 51         $passwd_cmd || &pass_error("The password change command <tt>$gconfig{'passwd_cmd'}</tt> was not found");
 52 
 53         &foreign_require("proc", "proc-lib.pl");
 54         &clean_environment();
 55         $ENV{'REMOTE_USER'} = $in{'user'};      # some programs need this
 56         $passwd_cmd .= " ".quotemeta($in{'user'});
 57         ($fh, $fpid) = &proc::pty_process_exec($passwd_cmd, 0, 0);
 58         &reset_environment();
 59         while(1) {
 60                 local $rv = &wait_for($fh,
 61                            '(new|re-enter).*:',
 62                            '(old|current|login).*:',
 63                            'pick a password',
 64                            'too\s+many\s+failures',
 65                            'attributes\s+changed\s+on|successfully\s+changed',
 66                            'pick your passwords');
 67                 $out .= $wait_for_input;
 68                 sleep(1);
 69                 if ($rv == 0) {

。。。。。。

漏洞分析文章 http://www.cnhackhy.com/archives/541.html

作者分析这个漏洞是有很多故事的啊


五,漏洞修复

直接升级到1.930版本

临时修补方案,可以定位漏洞代码所在的行,然后剔除

在github上下载password_change.cgi文件

  • 在这里插入图片描述
  • 2
    点赞
  • 19
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值