先看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. HTTP1.1与HTTP1.0

    本文转载自: http://www.cnblogs.com/shijingxiang/articles/4434643.html 1.可扩展性 a.在消息中增添版本号,用于兼容判断,版本号只能判断逐段 ...

  2. web框架详解之tornado 二 cookie

    一.tornado之cookie一 目录: <!DOCTYPE html> <html lang="en"> <head> <meta c ...

  3. pathinfo()的用法

    pathinfo() 返回一个关联数组包含有 path 的信息. 包括以下的数组元素: [dirname] [basename] [extension] 提示和注释 注释:如果不是要求取得所有单元,则 ...

  4. 大话设计模式--外观模式 Facade -- C++实现实例

    1.  外观模式: 为子系统中的一组接口提供一个一致的界面,此模式定义了一个高层接口,这个接口使得这个子系统更加容易使用. 外观模式的使用场合: A: 设计初期阶段,应该要有意识的将不同的两个层分离. ...

  5. CSS缎带效果

    1. [代码]ribbon.html     <!DOCTYPE HTML><html><head><style type="text/css&qu ...

  6. jq js 的date()使用

    Js获取当前日期时间及其它操作 var myDate = new Date();myDate.getYear(); //获取当前年份(2位)myDate.getFullYear(); //获取完整的年 ...

  7. django使用html模板减少代码

    看下面两个页面: —————————————————————————————————————————————————————————————————————————————————— 一个显示文章列表 ...

  8. vmware在桥接模式下配置centos7网络

    首先要将Vmware10.0.3设置为桥接模式. CentOS 7.0默认安装好之后是没有自动开启网络连接的! cd  /etc/sysconfig/network-scripts/  #进入网络配置 ...

  9. IBM V3500存储恢复步骤实例(linux)

    本环境是一有台IBM3500存储,将存储挂载至linux的/data目录,模拟测试当主服务器挂了,将数据恢复到另一台服务器,存储有两个地址,我配置的是192.168.80.59是用于web管理,192 ...

  10. Java_io_02_从一个目录拷贝文件到另一个目录下

    java从一个目录拷贝文件到另一个目录下   http://www.cnblogs.com/langtianya/p/4857524.html ** * 复制单个文件 * @param oldPath ...