DVWA——File Upload(low)

File Upload

界面

在这里插入图片描述

源代码


<?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>";
    }
}

?>

代码分析

        用户点击upload按钮后,服务器将选择的文件上传到服务器上去,并打印:“…/…/hackable/uploads/文件名 successfully uploades!”。可以看到,虽然要求传输image,但代码并未对上传的文件进行审查,可以传输任何文件类型。通过上传一句话木马,然后使用中国菜刀或者蚁剑进行获取webshell

渗透步骤

第一步:构建一句话木马,将一句话木马上传到DVWA上去。
在这里插入图片描述
第二步:使用中国菜刀进行连接,成功连接到DVWA,获取到webshell
在这里插入图片描述
在这里插入图片描述

遇到的问题

1、一句话木马上传成功,但菜刀连接不上。
解决方法1:可能是用的是PHP7,将PHP7改为PHP5就好了。
在这里插入图片描述
解决方法2:不更改PHP版本,使用蚁剑连接一句话木马

猜你喜欢

转载自blog.csdn.net/qq_37589805/article/details/112251615