php和蝉知,蝉知getshell

from 90sec

漏洞文件:

/system/module/file/model.phppublic function pasteImage($data, $uid)

{

$data = str_replace('"', '"', $data);

if(!$this->checkSavePath()) return false;

ini_set('pcre.backtrack_limit', strlen($data));

preg_match_all('/(S+);base64,(S+))/U', $data, $out);

foreach($out[3] as $key => $base64Image)

{

$imageData = base64_decode($base64Image);

$imageSize = array('width' => 0, 'height' => 0);

$file['id'] = $key;

$file['extension'] = $out[2][$key];

$file['size'] = strlen($imageData);

$file['addedBy'] = $this->app->user->account;

$file['addedDate'] = helper::today();

$file['title'] = basename($file['pathname']);

$file['pathname'] = $this->setPathName($file);

$file['editor'] = 1;

file_put_contents($this->savePath . $file['pathname'], $imageData);

$this->compressImage($this->savePath . $file['pathname']);

$imageSize = $this->getImageSize($this->savePath . $file['pathname']);

$file['width'] = $imageSize['width'];

$file['height'] = $imageSize['height'];

$file['lang'] = 'all';

$this->dao->insert(TABLE_FILE)->data($file)->exec();

$_SESSION['album'][$uid][] = $this->dao->lastInsertID();

$data = str_replace($out[1][$key], $this->webPath . $file['pathname'], $data);

}

return $data;

}

主要观察的地方是file_put这里,我们看看哪里可控。$imageData是由穿入的内容经过正则匹配然后遍历经过base64解码出来的内容。

$this->savePath . $file['pathname']

$this->savePath 不可控,$file['pathname']目前不知道

先看看这个函数从哪里调用过来的

关联文件:/system/module/file/control.phppublic function ajaxPasteImage($uid)

{

if($_POST)

{

echo $this->file->pasteImage($this->post->editor, $uid);

}

}

Uid就不多说了,首先肯定是当post请求的时候才能够进入我们发现隐患的函数,这个不困难

data是由editor参数传入的,uid不确定是否能够控制但目前的条件来说无关紧要,继续回到原来的地方foreach($out[3] as $key => $base64Image)

{

$imageData = base64_decode($base64Image);

$imageSize = array('width' => 0, 'height' => 0);

$file['id'] = $key;

$file['extension'] = $out[2][$key];

$file['size'] = strlen($imageData);

$file['addedBy'] = $this->app->user->account;

$file['addedDate'] = helper::today();

$file['title'] = basename($file['pathname']);

$file['pathname'] = $this->setPathName($file);

$file['editor'] = 1;

Data既然是可控的,那么自然out[3]也是可控内容,这里的 $file['extension'] = $out2 = $this->setPathName($file);我们唯一不能控值的pathname是从这里赋出来的,先跟入函数看看public function setPathName($file, $objectType = 'upload')

{

if(strpos('slide,source,themePackage', $objectType) === false)

{

$sessionID = session_id();

$randString = substr($sessionID, mt_rand(0, strlen($sessionID) - 5), 3);

$pathName = date('Ym/dHis', $this->now) . $file['id'] . mt_rand(0, 10000) . $randString;

}

elseif($objectType == 'source')

{

/* Process file path if objectType is source. */

$template = $this->config->template->{$this->app->clientDevice}->name;

$theme = $this->config->template->{$this->app->clientDevice}->theme;

return "source/{$template}/{$theme}/{$file['title']}.{$file['extension']}";

}

elseif($objectType == 'themePackage')

{

return "{$file['title']}.{$file['extension']}";

}

/* rand file name more */

list($path, $fileName) = explode('/', $pathName);

$fileName = md5(mt_rand(0, 10000) . str_shuffle(md5($fileName)) . mt_rand(0, 10000));

return $path . '/f_' . $fileName . '.' . $file['extension'];

}

前面的if都是不具备条件的自然是执行最后的操作,但这里看见没$file['extension']是后缀,是我们可以控制的,那么就是可以getshell了。。。。

本地复现下试试:

a5b48baedf97f4f60a42c8fed501286d.png

f8b79e15f182a67716b877da343ca49e.png

f842de5e65e5cf353fe96def9ffc5886.png

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值