DVWA之文件上传(File Upload)

这篇博客详细介绍了DVWA中的文件上传安全等级,从low到impossible,分析了每个等级中服务器对上传文件的检查措施,包括文件类型、大小、内容的限制,以及如何应对这些安全级别中的漏洞。在high级别中提到了防止00截断的方法,并在impossible级别中讨论了文件重命名、Anti-CSRF token和内容检查如何阻止恶意脚本上传。
摘要由CSDN通过智能技术生成

文件上传(File Upload)

Security Level: low

源码

<?php

if( isset( $_POST[ 'Upload' ] ) ) {
   
    // Where are we going to be writing to?
    $target_path  = DVWA_WEB_PAGE_TO_ROOT . "hackable/uploads/";
    $target_path .= basename( $_FILES[ 'uploaded' ][ 'name' ] );

    // Can we move the file to the upload folder?
    if( !move_uploaded_file( $_FILES[ 'uploaded' ][ 'tmp_name' ], $target_path ) ) {
   
        // No
        echo '<pre>Your image was not uploaded.</pre>';
    }
    else {
   
        // Yes!
        echo "<pre>{
     $target_path} succesfully uploaded!</pre>";
    }
}

?> 

分析

服务器对上传文件的类型、内容没有做任何的检查、过滤,存在明显的文件上传漏洞,生成上传路径后,服务器会检查是否上传成功并返回相应提示信息。

进行下方的实验

在这里插入图片描述

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

Security Level: medium

源码

<?php

if( isset( $_POST[ 'Upload' ] ) ) {
   
    // Where are we going to be writing to?
    $target_path  = DVWA_WEB_PAGE_TO_ROOT . "hackable/uploads/";
    $target_path .= basename( $_FILES[ 'uploaded' ][ 'name' ] );

    // File information
    $uploaded_name = $_FILES[ 'uploaded' ][ 'name' ];
    $uploaded_type = $_FILES[ 'uploaded' ][ 'type' ];</
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值