2. DVWA亲测命令执行漏洞

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

<?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级别:


<?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(
'&&' => '',
';' => '',
);



<?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 :

<?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(); ?>

这里直接限制了输入IP的格式,有效地防止了命令注入
系统
|
命令
|
windows
|
ping 127.0.0.1 -n 5 > null
|
linux
|
sleep 5
|
系统
|
命令
|
windows
|
ping , telnet 等
|
linux
|
wget , curl 等
|
2. DVWA亲测命令执行漏洞的更多相关文章
- 2. DVWA亲测文件包含漏洞
Low级: 我们分别点击这几个file.php文件 仅仅是配置参数的变化: http://127.0.0.1/DVWA/vulnerabilities/fi/?page=file3.php 如 ...
- DVWA靶机的命令执行漏洞
之前在打攻防世界的时候出现过类似的题目,这里再重温一下 (靶机一共低中高三个安全等级,这里只演示低中等级) (1)Security:low 根据提示让我们输入地址ping一下,之后返回以下内容,可以判 ...
- 1.2 DVWA亲测sql注入漏洞(blind)
LOW等级 我们尝试输入: 即如果页面返回为假,则说明后面的语句成功注入 据此我们可以知道 1' and 真 --> 页面显示 “User ID exists in the data ...
- 1.3 DVWA亲测sql注入漏洞
LOW等级 我们先输入1 我们加上一个单引号,页面报错 我们看一下源代码: <?php if( isset( $_REQUEST[ 'Submit' ] ) ) { // Get input ...
- PHP的命令执行漏洞学习
首先我们来了解基础 基础知识来源于:<web安全攻防>徐焱 命令执行漏洞 应用程序有时需要调用一些执行系统命令的函数,如在PHP中,使用system.exec.shell_exec.pas ...
- DVWA之Command injection(命令执行漏洞)
目录 Low Medium Middle Impossible 命令执行漏洞的原理:在操作系统中, & .&& .| . || 都可以作为命令连接符使用,用户通过浏览器 ...
- 小白日记36:kali渗透测试之Web渗透-手动漏洞挖掘(二)-突破身份认证,操作系统任意命令执行漏洞
手动漏洞挖掘 ###################################################################################### 手动漏洞挖掘 ...
- Kali学习笔记30:身份认证与命令执行漏洞
文章的格式也许不是很好看,也没有什么合理的顺序 完全是想到什么写一些什么,但各个方面都涵盖到了 能耐下心看的朋友欢迎一起学习,大牛和杠精们请绕道 实验环境: Kali机器:192.168.163.13 ...
- 文件包含上传漏洞&目录遍历命令执行漏洞
文件上传漏洞: 一句话木马 一句话木马主要由两部分组成:执行函数与 接收被执行代码的变量 执行函数: eval() assert() create_function() array_map() arr ...
随机推荐
- web框架详解之tornado 一 模板语言以及框架本质
一.概要 Tornado 是 FriendFeed 使用的可扩展的非阻塞式 web 服务器及其相关工具的开源版本.这个 Web 框架看起来有些像web.py 或者 Google 的 webapp,不过 ...
- POJ1182 食物链 并查集
#include<iostream>#include<stdio.h>#include<string.h>using namespace std;const int ...
- iptables原理及使用教程
注意 修改iptables可能导致连接断开, 对于远程连接的用户, 需要在经过充分测试后在修改, 对于懒人可以设置一个crontab, 在你修改iptables的过程中每隔30分钟清空一次iptabl ...
- python第七篇:Python 列表操作详解
Python列表操作详解 list函数 list() #生成一个空的列表 list(iterable) #用可迭代对象初始化一个列表 列表的 and 运算和 or 运算 列表and运算 > ...
- C++(六)— 输入方式
1.输入包含空格的字符串 使用 getline(cin, str)读取一行字符串,遇到换行符停止:cin>>str,是遇到空格就停止. 实现:输入两个字符,在第一个字符中删除第二个字符中出 ...
- php和mysql连接方式(短 长 池)
一个php work进程只能处理一个请求,当完成一个请求了,才能处理下一次的请求 2.短连接: 执行到php关闭mysql连接的代码时,就断开,否则在处理本次请求结束的时候,释放mysql连接 实验: ...
- C\C++的转义字符
C\C++的转义字符 所有的ASCII码都可以用"\"加数字(一般是8进制数字)来表示.而C中定义了一些字母前加"\"来表示常见的那些不能显示的ASCII字符, ...
- FEC之我见二
前面简单说了一下FEC,以及它的配合使用的方法.下面我想详细说一下FEC算法: 曾经有位大神在帖子里这么写着:采用改进型的vandermonde矩阵RS算法.其优点算法运算复杂度更低且解决了利用矩阵构 ...
- 【整理】如何选取后缀数组&&后缀自动机
后缀家族已知成员 后缀树 后缀数组 后缀自动机 后缀仙人掌 后缀预言 后缀Splay ? 后缀树是后缀数 ...
- 每天一个linux命令(7):rmdir命令
版权声明更新:2017-05-11博主:LuckyAlan联系:liuwenvip163@163.com声明:吃水不忘挖井人,转载请注明出处! 1 文章介绍 本文介绍了Linux下面的rmdir命令. ...