先看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. 修改push动画的方向

    CATransition *animation = [CATransition animation]; animation.duration = 0.4; animation.timingFuncti ...

  2. 如何拯救一台glibc被干掉的Linux服务器

    原文: 如何拯救一台glibc被干掉的Linux服务器? 首先如果 libc.so.6 没有被删除, 直接使用LD_PRELOAD就可以恢复 LD_PRELOAD=/lib64/libc-2.12.s ...

  3. EntityFramework 学习 一 Spatial Data type support in Entity Framework 5.0

    MS SQl Server引进两种特殊的数据类型geography and geometry public partial class Course { public Course() { this. ...

  4. 使用JobControl控制MapReduce任务

    代码结构 BeanWritable:往数据库读写使用的bean ControlJobTest:JobControl任务控制 DBInputFormatApp:将关系型数据库的数据导入HDFS,其中包含 ...

  5. Memory Layout (Virtual address space of a C process)

    Memory Layout (Virtual address space of a C process) 分类: C语言基础2012-12-06 23:16 2174人阅读 评论(0) 收藏 举报 f ...

  6. 012_流式计算系统(Mahout协同过滤)

    课程介绍 课程内容 1.Mahout是什么 l  Mahout是一个算法库,集成了很多算法. l  Apache Mahout 是 Apache Software Foundation(ASF)旗下的 ...

  7. artdialog插件--iframe穿透特性

    使用artdialog可以实现嵌套页面间的通信. 一.引入插件 //artdialog是建立在jquery上面的所以要首先引入jquery <script src="__CLASSTP ...

  8. 分享知识-快乐自己:FastDFS 图片服务器的搭建

    使用一台虚拟机来模拟,只有一个Tracker.一个Storage服务,配置nginx访问图片. 1):安装依赖包 yum -y install zlib zlib-devel pcre pcre-de ...

  9. 利用Python进行文章特征提取(二)

    本篇blog是利用Python进行文章特征提取的续篇,主要介绍构建带TF-IDF权重的文章特征向量. In [1]: # 带TF-IDF权重的扩展词库 # 在第一篇文档里 主要是利用词库模型简单判断单 ...

  10. 【leetcode】Construct Binary Tree from Inorder and Postorder Traversal

    Given inorder and postorder traversal of a tree, construct the binary tree. Note:You may assume that ...