zoukankan      html  css  js  c++  java
  • 实战DVWA!

    DVWA漏洞训练系统,来个大图^-^

     

     

     

     

    1.首先试了下DVWA的命令执行漏洞command execution     这是我在Low级别上测试的,另外附上low级别代码:

    <?php

    if( isset( $_POST[ 'submit' ] ) ) {     //isset()函数,若变量不为NULL或空则返回true 

        $target = $_REQUEST[ 'ip' ];       //$_REQUEST[]  获取标签值为ip的里的的内容<input id="ip" type="text">

        // Determine OS and execute the ping command.
        if (stristr(php_uname('s'), 'Windows NT')) {  //stristr()函数贴个例子吧,判断是WINDOWS还是Linux,php_uname() 返回了运行 PHP 的操作系统的描述,'s':操作系统名称。
     
    /*
    <?php
      $email = 'USER@EXAMPLE.com';
      echo stristr($email, 'e'); // 输出 ER@EXAMPLE.com
      echo stristr($email, 'e', true); // 自 PHP 5.3.0 起,输出 US
    ?>
    */
        
            $cmd = shell_exec( 'ping  ' . $target );  //shell_exec()函数执行命令作用呗
            echo '<pre>'.$cmd.'</pre>';
            
        } else {        
        
            $cmd = shell_exec( 'ping  -c 3 ' . $target );  //执行linux命令
            echo '<pre>'.$cmd.'</pre>';
            
        }
        
    }
    ?>
    发现$target直接接收了没有过滤过得值,window 和 linux 下可以直接用&&和;来执行多条命令,所以提交127.0.0.1&&net user做测试


     
    接下来是medium级别的代码
     
    <?php

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

        $target = $_REQUEST[ 'ip' ];

        // Remove any of the charactars in the array (blacklist).
        $substitutions = array(        //建立php数组 array('key' => 'value')
            '&&' => '',
            ';' => '',
        );

        $target = str_replace( array_keys( $substitutions ), $substitutions, $target );  
    /*array_keys返回数组键名,str_replace(search,replace,subject)三个参数search作为匹配,匹配subject中的字符,若匹配到用replace代替 */
        
        // Determine OS and execute the ping command.
        if (stristr(php_uname('s'), 'Windows NT')) { //判断是不是windows  
        
            $cmd = shell_exec( 'ping  ' . $target );
            echo '<pre>'.$cmd.'</pre>';
            
        } else { 
        
            $cmd = shell_exec( 'ping  -c 3 ' . $target );
            echo '<pre>'.$cmd.'</pre>';
            
        }
    }

    ?>
     
     

    medium里面吧&&和;都过滤了,但是可以尝试提交 1||net user  ||的意思是若前面没有执行成功则执行后面的内容

    =========================================未完待续======================================================

  • 相关阅读:
    QML用Qt.labs.settings实现保存用户设置
    周练1
    Django的Hello World
    python 笔记
    Qt Creator 搭配Git 版本控制
    Windows系统下在Git Bash中把文件内容复制到剪贴板的命令
    【转】Qt之JSON保存与读取
    Qt Creator 中文编译失败 怎么办
    Treap树 笔记
    【POJ1037】A decorative fence(DP)
  • 原文地址:https://www.cnblogs.com/elliottc/p/3812734.html
Copyright © 2011-2022 走看看