DVWA(2)命令注入漏洞(Command Injection) LOW-HIGHT 操作记录

前言:DVWA(1)暴力破解 LOW-HIGHT 操作记录

今天带来第二期命令注入漏洞操作记录。初次接触DVWA,写下自己的操作记录,希望可以帮助每个刚接触DVWA的新手,同时希望可以提升自己的技术。注:如有操作不当的地方希望可以得到大神指导、交流。也感谢之前查阅的各种大神提供的博客。

DVWA命令注入漏洞

Low级别

输入ip得到对ip的ping内容

 尝试使用dir命令

127.0.0.1 && dir

 Mediun级别

尝试使用  127.0.0.1 && dir 

 查看源代码


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

?>

&&被替换成‘’

知识补充:

命令1 && 命令2:是先执行命令1,执行成功后在执行命令2,如果命令1没执行,则命令2也不会执行

命令1 & 命令2:先执行命令1,不管成功不成功,都会执行命令2

命令1 | 命令2如果前语句为假则直接报错,后面不执行;如果前语句为真,执行后边的语句

命令1 || 命令2如果前面命令是错的那么就执行后面的语句,否则只执行前面的语句

我们使用 &来连接

127.0.0.1 & dir

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

?>

因此我们利用

127.0.0.1 |dir

感谢阅读。

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值