1、首先先说前台的吧,估计很多站都开始补了。是针对phpcms 2008的,二次攻击范畴,二次解析getshell。
在upload_field.php中
[php]
$upload_allowext = !empty($C['upload_allowext']) ? $C['upload_allowext'] : $info['upload_allowext'];
// 漏洞触发点 通过变量覆盖$upload_allowext此变量赋值为html
$upload_maxsize = !empty($C['upload_maxsize']) ? $C['upload_maxsize'] : $info['upload_maxsize']*1024;
$isthumb = isset($C['thumb_enable']) ? $C['thumb_enable'] : ($PHPCMS['thumb_enable'] && $info['isthumb'] ? 1 : 0);
$iswatermark = isset($C['watermark_enable']) ? $C['watermark_enable'] : ($PHPCMS['watermark_enable'] && $info['iswatermark'] ? 1 : 0);
$thumb_width = isset($width) ? $width : (isset($C['thumb_width']) ? $C['thumb_width'] : ($info['thumb_width'] ? $info['thumb_width'] : $PHPCMS['thumb_width']));
$thumb_height = isset($height) ? $height : (isset($C['thumb_height']) ? $C['thumb_height'] : ($info['thumb_height'] ? $info['thumb_height'] : $PHPCMS['thumb_height']));
$watermark_img = PHPCMS_ROOT.($info['watermark_img'] ? $info['watermark_img'] : $PHPCMS['watermark_img']);
$attachment = new attachment($mod); //实例化attachment上传类
if($dosubmit)
{
$attachment->upload($uploadtext, $upload_allowext, $upload_maxsize, 1);
// 漏洞触发点 引用attachment上传类
[/php]
这里我们可以通过?C[upload_allowext]=html&C[upload_maxsize]=1024000这样的方式来覆盖上传类型,达到上传我们的利用恶意脚本,但是不能直接上传php之类的,你可以跟踪一下这个attachment类文件。但是我们可以通过上传html
在preview.php中60行处
[php]
$head['description'] = $r['description'];
if(!$template) $template = $C[‘template_show’]; // 通过变量覆盖即可覆盖$template变量
include template(‘phpcms’, $template); // 调用template 模板解析函数
// 解析模板方法
function template($module = 'phpcms', $template = 'index', $istag = 0)
{
$compiledtplfile = TPL_CACHEPATH.$module.'_'.$template.'.tpl.php';
if(TPL_REFRESH && (!file_exists($compiledtplfile) || @filemtime(TPL_ROOT.TPL_NAME.'/'.$module.'/'.$template.'.html') > @filemtime($compiledtplfile) || @filemtime(TPL_ROOT.TPL_NAME.'/tag.inc.php') > @filemtime($compiledtplfile)))
{
require_once PHPCMS_ROOT.'include/template.func.php';
template_compile($module, $template, $istag); // 模板解析
}
return $compiledtplfile;
}
// 继续跟踪template_compile函数
[/php]
在template.func.php中2行处
[php]
function template_compile($module, $template, $istag = 0)
{
$tplfile = TPL_ROOT.TPL_NAME.‘/’.$module.‘/’.$template.‘.html’; // 这里$template可控
$content = @file_get_contents($tplfile); // 触发漏洞,解析构造好的恶意文件
if($content === false) showmessage("$tplfile is not exists!");
$compiledtplfile = TPL_CACHEPATH.$module.'_'.$template.'.tpl.php';
$content = ($istag || substr($template, 0, 4) == 'tag_') ? ''.template_parse($content, 1).'' : template_parse($content);
$strlen = file_put_contents($compiledtplfile, $content);
@chmod($compiledtplfile, 0777);
return $strlen;
}
[/php]
这是解析的地方
最终给出exp如下
[php]
第二步:
[/php]
2、后台低权限 getshell
很多人拿到phpcms 2008的后台苦于拿不到shell。。。苦苦琢磨琢磨啊
顾贡献一枚0day,只要后台能发个帖,你就能拿shell
他这个原理是一样的,后台上传图片的时候同样可以覆盖变量,达到getshell
原理一样,给出个exp演示
[php]
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-
评论