dvwa———— 命令执行漏洞

声明: 本文章仅限于安全技术交流,禁止用于非法途径,如读者作出危害网络安全的行为后果自负,与作者无关!


前言

今天我们来讲一下,命令执行漏洞。

什么是命令执行漏洞?

命令执行漏洞简介命令执行漏洞就是黑客可以直接在web应用中执行系统命令,从而获取敏感信息或者拿下shell权限

low

我们先来看一下页面效果
在这里插入图片描述
这里看到是尝试ping 一个ip地址。我们再来看一下他的代码

<?php

if( isset( $_POST[ 'Submit' ]  ) ) {
    // Get input
    $target = $_REQUEST[ 'ip' ];

    // Determine OS and execute the ping command.
    if( stristr( php_uname( 's' ), 'Windows NT' ) ) {
        // Windows
        $cmd = shell_exec( 'ping  ' . $target );
    }
    else {
        // *nix
        $cmd = shell_exec( 'ping  -c 4 ' . $target );
    }

    // Feedback for the end user
    echo "<pre>{$cmd}</pre>";
}

?> 

这里看到传入的参数,没有任何过滤,所以我们这里可以拿拼接语句,拼接恶意命令。
在这里插入图片描述
这里看到我们就直接得到了服务器的内网地址。

medium

我们还是先来看页面效果
在这里插入图片描述
页面效果还是一样的,我们来看一下代码

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import warnings
warnings.filterwarnings('ignore')
import  ssl
ssl._create_default_https_context = ssl._create_unverified_context

2.读入数据

代码如下(示例):

<?php

if( isset( $_POST[ 'Submit' ]  ) ) {
    // Get input
    $target = $_REQUEST[ 'ip' ];

    // Set blacklist
    $substitutions = array(
        '&&' => '',
        ';'  => '',
    );

    // Remove any of the charactars in the array (blacklist).
    $target = str_replace( array_keys( $substitutions ), $substitutions, $target );

    // Determine OS and execute the ping command.
    if( stristr( php_uname( 's' ), 'Windows NT' ) ) {
        // Windows
        $cmd = shell_exec( 'ping  ' . $target );
    }
    else {
        // *nix
        $cmd = shell_exec( 'ping  -c 4 ' . $target );
    }

    // Feedback for the end user
    echo "<pre>{$cmd}</pre>";
}

?> 

这里看到定义了一个黑名单,把&&和;替换为空,但是我拼接的字符串有很多,就不差这两个。
在这里插入图片描述
使用low的语句还是可以被执行的。

high

还是一样来看页面效果
在这里插入图片描述
页面还是一样,进行来看代码

<?php

if( isset( $_POST[ 'Submit' ]  ) ) {
    // Get input
    $target = trim($_REQUEST[ 'ip' ]);

    // Set blacklist
    $substitutions = array(
        '&'  => '',
        ';'  => '',
        '| ' => '',
        '-'  => '',
        '$'  => '',
        '('  => '',
        ')'  => '',
        '`'  => '',
        '||' => '',
    );

    // Remove any of the charactars in the array (blacklist).
    $target = str_replace( array_keys( $substitutions ), $substitutions, $target );

    // Determine OS and execute the ping command.
    if( stristr( php_uname( 's' ), 'Windows NT' ) ) {
        // Windows
        $cmd = shell_exec( 'ping  ' . $target );
    }
    else {
        // *nix
        $cmd = shell_exec( 'ping  -c 4 ' . $target );
    }

    // Feedback for the end user
    echo "<pre>{$cmd}</pre>";
}

?> 

这里的黑名单明显多了不少,但是在|后面竟然有个空格,这就有点扯淡了,那这里我就利用他这个漏洞来写,这种拼接字符串,可以不用空格也是可以的。
在这里插入图片描述


总结

说实话这个漏洞也算比较简单的,只要熟悉了windows和linux的基础命令,这里基本都玩的明白,这个漏洞也算是高危的,如果实战遇到直接起飞。好啦,以上内容为我个人理解,不喜勿喷,如有写错欢迎指出!

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值