ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

【靶场训练_DVWA】Command Execution

2019-09-13 22:01:19  阅读:190  来源: 互联网

标签:shell target exec cmd ping DVWA echo Command Execution


low

利用:

;ls ../../

 

 

 源码分析:

<?php

if( isset( $_POST[ 'submit' ] ) ) 
{
    //将ip对应的值复制给target
    $target = $_REQUEST[ 'ip' ];
    
    if (stristr(php_uname('s'), 'Windows NT')) 
    { 
        //如果是winds就直接ping
    
        $cmd = shell_exec( 'ping  ' . $target );
        echo '<pre>'.$cmd.'</pre>';
        
    } 
    else 
    { 
        //如果是Linux就默认ping 3个包
        $cmd = shell_exec( 'ping  -c 3 ' . $target );
        echo '<pre>'.$cmd.'</pre>';
        
    }
    
}
?>
  • $_REQUEST[]具用$_POST[] $_GET[]的功能,但是$_REQUEST[]比较慢。通过post和get方法提交的所有数据都可以通过$_REQUEST数组获得
  • php_uname — 返回运行 PHP 的系统的有关信息
  • stristr() 函数搜索字符串在另一字符串中的第一次出现
  • php_uname('s'):返回操作系统名称

 

Medium

利用:

|| 或者  &;& 或者 &

 

源码分析:

 就多了一点过滤,但是没过滤完整

<?php

if( isset( $_POST[ 'submit'] ) ) 
{

    $target = $_REQUEST[ 'ip' ];

    // 过滤了 &&,;命令分割符
    $substitutions = array(
        '&&' => '',
        ';' => '',
    );

    $target = str_replace( array_keys( $substitutions ), $substitutions, $target );
    
    // Determine OS and execute the ping command.
    if (stristr(php_uname('s'), 'Windows NT')) { 
    
        $cmd = shell_exec( 'ping  ' . $target );
        echo '<pre>'.$cmd.'</pre>';
        
    } else { 
    
        $cmd = shell_exec( 'ping  -c 3 ' . $target );
        echo '<pre>'.$cmd.'</pre>';
        
    }
}

?>

High

无能为力了Orz,只有诸如“数字.数字.数字.数字”的输入才会被接收执行.

<?php

if( isset( $_POST[ 'submit' ] ) ) 
{

    $target = $_REQUEST["ip"];
    
    /*
        stripslashes() 函数删除由 addslashes() 函数添加的反斜杠。
     */
    
    $target = stripslashes( $target );
    
    
    // Split the IP into 4 octects
    $octet = explode(".", $target);
    
    // Check IF each octet is an integer
    if ((is_numeric($octet[0])) && (is_numeric($octet[1])) && (is_numeric($octet[2])) && (is_numeric($octet[3])) && (sizeof($octet) == 4)  ) 
    {
    
    // If all 4 octets are int's put the IP back together.
    $target = $octet[0].'.'.$octet[1].'.'.$octet[2].'.'.$octet[3];
    
    
        // Determine OS and execute the ping command.
        if (stristr(php_uname('s'), 'Windows NT')) 
        { 
    
            $cmd = shell_exec( 'ping  ' . $target );
            echo '<pre>'.$cmd.'</pre>';
        
        } 
        else 
        { 
    
            $cmd = shell_exec( 'ping  -c 3 ' . $target );
            echo '<pre>'.$cmd.'</pre>';
        
        }
    
    }
    else
    {
        echo '<pre>ERROR: You have entered an invalid IP</pre>';
    }
    
}

?>

 

标签:shell,target,exec,cmd,ping,DVWA,echo,Command,Execution
来源: https://www.cnblogs.com/chrysanthemum/p/11517770.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有