DVWA(0629)

DVWA靶场搭建

  • 将文件拷入虚拟机
  • 修改数据库配置文件/dvwa_2.0.1/config/config.inc.php
$_DVWA[ 'db_server' ]   = '127.0.0.1';
$_DVWA[ 'db_database' ] = 'dvwa_201';
$_DVWA[ 'db_user' ]     = 'root';
$_DVWA[ 'db_password' ] = 'root';
$_DVWA[ 'default_security_level' ] = 'low';
  • 重启数据库之后就可进入登录界面

    image-20230629101758960.png

  • 账号admin 密码password

  • image-20230629101840706.png

对搭建的靶场上传图片马

image-20230629102021655.png

image-20230629102603164.png

  • 准备一句话木马并改后缀

image-20230629102725270.png

  • low难度直接上传成功
  • image-20230629103204866.png

medium 难度

image-20230629110132545.png

在不修改的情况下,上传失败

打开bp进行修改上传

image-20230629110312151.png

将content-type修改为图片,上传成功

image-20230629110543331.png

high难度

使用中等难度的上传方法已经不能完成

查看代码

<?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_ext  = substr( $uploaded_name, strrpos( $uploaded_name, '.' ) + 1);
    $uploaded_size = $_FILES[ 'uploaded' ][ 'size' ];
    $uploaded_tmp  = $_FILES[ 'uploaded' ][ 'tmp_name' ];

    // Is it an image?
    if( ( strtolower( $uploaded_ext ) == "jpg" || strtolower( $uploaded_ext ) == "jpeg" || strtolower( $uploaded_ext ) == "png" ) &&
        ( $uploaded_size < 100000 ) &&
        getimagesize( $uploaded_tmp ) ) {

        // Can we move the file to the upload folder?
        if( !move_uploaded_file( $uploaded_tmp, $target_path ) ) {
            // No
            echo '<pre>Your image was not uploaded.</pre>';
        }
        else {
            // Yes!
            echo "<pre>{$target_path} succesfully uploaded!</pre>";
        }
    }
    else {
        // Invalid file
        echo '<pre>Your image was not uploaded. We can only accept JPEG or PNG images.</pre>';
    }
}

?>

可得:文件上传后缀白名单检测,文件内容检测

上传报错

image-20230629111433371.png

打开bp修改如下:

image-20230629111626428.png

上传成功

posted @ 2023-06-29 17:13  W-xzg  阅读(27)  评论(0)    收藏  举报
1 2 3
4