目标达成 感谢每一位支持者 — 我们达成了 100% 目标!

目标: 1000 元 · 已筹: 1336

100%

CVE-2022-40471 PoC — Clinic’s Patient Management System 代码问题漏洞

来源
关联漏洞
标题: Clinic’s Patient Management System 代码问题漏洞 (CVE-2022-40471)
Description:Clinic’s Patient Management System是Carlo Montero的一个诊所的病人管理系统。 Clinic’s Patient Management System v 1.0版本存在安全漏洞,该漏洞源于允许攻击者通过 users.php 中的个人资料图片上传功能上传任意 php webshell。
Description
RCE Exploit and Research 
介绍
# CVE-2022-40471

Remote code execution via unrestricted file upload vulnerability in the Clinic's Patient Management System v 1.0

![image](https://static.wixstatic.com/media/cf57b8_8928645050c94227991adee114f384e0~mv2.png/v1/fill/w_740,h_383,al_c,q_85,usm_0.66_1.00_0.01,enc_auto/cf57b8_8928645050c94227991adee114f384e0~mv2.png)

# Technical description:

Remote Code Execution in Clinic's Patient Management System v 1.0 allows Attacker to Upload arbitrary php webshell via profile picture upload functionality in users.php

## Affected components - Source Code

in following Source Code we can see that developer directly allows to upload any media files without restricting an a specific extenstion which means we can upload any extensions file there which is not okay for security reasons and using this functionality flaw, attacker could upload malicious webshell to gain access complete server with root privileges

###### Mitigations: Please Restrict other extenstions while uploading an image file for profile picture upload functionality and allow only .jpg .png extensions which are only image related

Vulnerable Page - users.php

```php
  // users.php
  $status = move_uploaded_file(
    $_FILES["profile_picture"]["tmp_name"],
    'user_images/' . $targetFile
  );

  if ($status) {
    try {
      $con->beginTransaction();

      $query = "INSERT INTO `users`(`display_name`,
`user_name`, `password`, `profile_picture`)
VALUES('$displayName', '$userName', '$encryptedPassword', '$targetFile');";

      $stmtUser = $con->prepare($query);
      $stmtUser->execute();

      $con->commit();

      $message = 'user registered successfully';
    } catch (PDOException $ex) {
      $con->rollback();
      echo $ex->getTraceAsString();
      echo $ex->getMessage();
      exit;
    }
  } else {
    $message = 'a problem occured in image uploading.';
  }

  header("location:congratulation.php?goto_page=users.php&message=$message");
  exit;
}
```

<!-- ![image](../CVE-2022-40471/Screenshot%202022-10-15%20103606.png) -->

# CVE-2022-40471.py usage -

```sh
# Upload a simple webshell to the target machine -
python3 CVE-2022-40471.py <target_ip> <target_port> <target_uri> <username> <password>
```

## Example -

```sh
python CVE-2022-40471.py 127.0.0.1 80 /pms/ UserName Password
```

# Proof of concept (Poc) -

![Screenshot 2022-10-13 053055](https://user-images.githubusercontent.com/65374016/195474325-7c20861d-c64d-470c-8d03-3fb1078ee3da.png)

# References -

https://drive.google.com/file/d/1m-wTfOL5gY3huaSEM3YPSf98qIrkl-TW/view?usp=sharing

https://www.sourcecodester.com/php-clinics-patient-management-system-source-code

https://www.sourcecodester.com/sites/default/files/download/oretnom23/php-cpms.zip

# Discovered & Developed by -

RashidKhan Pathan (iHexCoder), 9 September 2022.
Twitter: @itRashid
文件快照

登录后查看神龙缓存的 POC 文件快照

登录查看
备注
    1. 建议优先通过来源进行访问。
    2. 本地 POC 快照面向订阅用户开放;当原始来源失效或无法访问时,本地镜像作为订阅权益的一部分提供。
    3. 持续抓取、验证、维护这份 POC 档案需要不少投入,因此本地快照已纳入付费订阅。您的订阅是让这份资料能继续走下去的关键,由衷感谢。 查看订阅方案 →