zoukankan      html  css  js  c++  java
  • 命令执行漏洞

    1、命令执行(Command Execution)漏洞即黑客可以直接在Web应用中执行系统命令,从而获取敏感信息或者拿下shell权限

    2、命令执行漏洞可能造成的原因是Web服务器对用户输入命令安全检测不足,导致恶意代码被执行

    3、更常见的命令执行漏洞是发生在各种Web组件,包括Web容器、Web框架、CMS软件、安全组件等

    DVWA

    low

    分析代码

     1  <?php
     2 
     3 if( isset( $_POST[ 'Submit' ]  ) ) {    
     4     // Get input
     5     $target = $_REQUEST[ 'ip' ];       //low级别中没有进行任何过滤 直接把get的值输出   
     6 
     7     // Determine OS and execute the ping command.
     8     if( stristr( php_uname( 's' ), 'Windows NT' ) ) {
     9         // Windows
    10         $cmd = shell_exec( 'ping  ' . $target );
    11     }
    12     else {
    13         // *nix
    14         $cmd = shell_exec( 'ping  -c 4 ' . $target );
    15     }
    16 
    17     // Feedback for the end user
    18     echo "<pre>{$cmd}</pre>";
    19 }
    20 
    21 ?>

    上面搭建环境是win  若是在linux下搭建环境 可执行一下命令

    • 114.114.114.114&&uname
    • 114.114.114.114&&pwd
    • 114.114.114.114&&ls -l
    • 114.114.114.114&&cat /etc/passwd    //查看用户
    • 114.114.114.114&&cat /etc/shadow  //查看密码

    medium

     1 <?php
     2 
     3 if( isset( $_POST[ 'Submit' ]  ) ) {
     4     // Get input
     5     $target = $_REQUEST[ 'ip' ];
     6 
     7     // Set blacklist
     8     $substitutions = array(
     9         '&&' => '',          //对输入的 && 和 ; 进行过滤
    10         ';'  => '',
    11     );
    12 
    13     // Remove any of the charactars in the array (blacklist).
    14     $target = str_replace( array_keys( $substitutions ), $substitutions, $target );
    15 
    16     // Determine OS and execute the ping command.
    17     if( stristr( php_uname( 's' ), 'Windows NT' ) ) {
    18         // Windows
    19         $cmd = shell_exec( 'ping  ' . $target );
    20     }
    21     else {
    22         // *nix
    23         $cmd = shell_exec( 'ping  -c 4 ' . $target );
    24     }
    25 
    26     // Feedback for the end user
    27     echo "<pre>{$cmd}</pre>";
    28 }
    29 
    30 ?> 

     实例应用

     命令执行漏洞防御

    1、各种框架、插件等位置都有可能出现命令执行,升级到新版本,多打补丁

    2、关注行业最新安全动态,一旦爆发命令执行漏洞,迅速修复,避免造成更大影响

    3、少用框架/CMS

  • 相关阅读:
    JVM(一)--Java内存区域
    leetcode33 搜索旋转排序数组
    二叉树的相关算法(一)
    分别求二叉树前、中、后序的第k个节点
    【蓝桥杯】历届试题 买不到的数目
    JAVA的JVM的内存可分为3个区:堆(heap)、栈(stack)和方法区(method)
    【蓝桥杯】核桃的数量
    Java内存分析之对象实例化操作初步分析
    【蓝桥杯】算法训练 K好数
    【蓝桥杯】基础练习试题
  • 原文地址:https://www.cnblogs.com/unixcs/p/10475131.html
Copyright © 2011-2022 走看看