【靶场训练_DVWA】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>‘;
    }

}

?>

原文地址:https://www.cnblogs.com/chrysanthemum/p/11517770.html

时间: 2024-11-19 09:28:18

【靶场训练_DVWA】Command Execution的相关文章

struts2 CVE-2012-0392 S2-008 Strict DMI does not work correctly allows remote command execution and arbitrary file overwrite

catalog 1. Description 2. Effected Scope 3. Exploit Analysis 4. Principle Of Vulnerability 5. Patch Fix 1. Description Struts2框架存在一个DevMode模式,方便开发人员调试程序.如果启用该模式,攻击者可以构造特定代码导致OGNL表达式执行,以此对主机进行入侵Remote command execution and arbitrary file overwrite, St

Fatal error encountered during command execution

MySQL + .net + EF 开发环境,调用一处sql语句报错: Fatal error encountered during command execution[sql] view plain copy print?SELECT @r AS cateid,(SELECT @r := b.ParentId FROM cmscontentcategory b WHERE b.id = cateid) AS parentid FROM (SELECT @r := '75422ccd151c48

struts2 CVE-2010-1870 S2-005 XWork ParameterInterceptors bypass allows remote command execution

catalog 1. Description 2. Effected Scope 3. Exploit Analysis 4. Principle Of Vulnerability 5. Patch Fix 1. Description XWork是一个命令模式框架,用于支持Struts 2及其他应用  在Atlassian Fisheye,Crucible和其他产品中使用的Struts 2.0.0至2.1.8.1版本中的Xwork中的OGNL表达式赋值功能使用许可的白名单,远程攻击者可以借助

PowerShell vs. PsExec for Remote Command Execution

Posted by Jianpeng Mo / January 20, 2014 Monitoring and maintaining large-scale, complex, highly distributed and interconnected systems can be extremely challenging for network administrators. Traditional IT management approaches are ill-equipped to

MYSQL报Fatal error encountered during command execution.错误的解决方法

{MySql.Data.MySqlClient.MySqlException (0x80004005): Fatal error encountered during command execution. ---> MySql.Data.MySqlClient.MySqlException (0x80004005): Fatal error encountered attempting to read the resultset. ---> MySql.Data.MySqlClient.MyS

Remote Command Execution via CouchDB

11 Sep 2016 ? Pentest, Database 背景介绍 CouchDB是一个开源的面向文档的数据库管理系统,可以通过 RESTful JavaScript Object Notation (JSON) API 访问.CouchDB可以安装在大部分POSIX系统上,包括Linux和Mac OS X. 漏洞介绍 Couchdb默认会在5984端口开放Restful的API接口,如果使用SSL的话就会监听在6984端口,用于数据库的管理功能.其HTTP Server默认开启时没有进行

struts2 CVE-2013-1965 S2-012 Showcase app vulnerability allows remote command execution

catalog 1. Description 2. Effected Scope 3. Exploit Analysis 4. Principle Of Vulnerability 5. Patch Fix 1. Description OGNL provides, among other features, extensive expression evaluation capabilities. A request that included a specially crafted requ

struts2 CVE-2013-2251 S2-016 action、redirect code injection remote command execution

catalog 1. Description 2. Effected Scope 3. Exploit Analysis 4. Principle Of Vulnerability 5. Patch Fix 1. Description struts2中有2个导航标签(action.redirect),后面可以直接跟ongl表达式,比如 1. test.action?action:${exp} 2. test.action?redirect:${exp} Struts2的DefaultActio

MS Office 2007 and 2010 - OLE Arbitrary Command Execution

之前看到freebuf上面的一篇文章,被台湾黑客拿去搞APT.期待了好久,终于放出POC了. Xecure lab在10月17号发现变种的0day漏洞 沙虫(CVE-2014-4114 )已经被用在针对台湾政府以及各单位的APT攻击中,目前主流的杀毒软件还没办法有效地检测.该变种能够直接内嵌恶意软件,并本地触发执行,不需要再从远程共享服务器上下载恶意代码. http://www.freebuf.com/vuls/48601.html http://www.exploit-db.com/explo