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 ...
随机推荐
- 20165101 学习基础和C语言基础调查
学习基础和C语言基础调查 技能学习心得 看了15级学长学姐丰富的技能之后,我感到很惭愧.我的课外技能可以说是很糟糕.唱歌的话,小时候还可以用假声唱一下,变声之后就是高音上不去,低音下不来.体育更是差劲 ...
- 练习题目 :if for while else range、xrange、zip
range在内存中直接生成指定的序列,当序列非常大时会浪费内存资源: xrange则不会直接生成一个list,而是每次调用返回其中的一个值,而非直接全部生成存于内存中 range([start,] s ...
- 汇编语言入门(在debug中编辑和调试程序)
2013-06-02 17:09 4252人阅读 评论(2) 收藏 举报 分类: 汇编语言(1) 版权声明:本文为博主原创文章,未经博主允许不得转载. 我们在Windows中进入的Dos方式,实际 ...
- 三维bfs
胜利大逃亡 Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submi ...
- mysql 在windows server下发生系统错误 1067, 进程意外终止的解决方法
mysql 在windows server下发生系统错误 1067, 进程意外终止,请检查系统盘下的windows目录下是否存在mysql的配置文件my.ini,如存在,将其删除或改名即可.
- Nexus4_换电池
1.参考帖子:http://tieba.baidu.com/p/2444904362 ([图片]直播nexus4拆机换电池,勿插_nexus4吧_百度贴吧.html) 主要的内容是: (1).(5楼) ...
- 英语发音规则---ai字母组合发音
英语发音规则---ai字母组合发音 一.总结 一句话总结:字母组合ai在音词中一般发字母a的音/eɪ/,通常出现在闭音节中.这里要注意的是单词中air字母组合与ai字母组合发音的区别,air发/eə/ ...
- Centos安装SZRZ方便文件传输
方便Centos服务器传输文件, 要用到szrz命令, 具体安装如下: # wget http://freeware.sgi.com/source/rzsz/rzsz-3.48.tar.gz# ta ...
- WCF寄宿(Host)之自我寄宿(Self-Hosting)简单实例【Console应用为宿主】
前言: 由于最近的项目 中需要用到WCF,所以又回头翻了翻,阅读了大量园中大神的博文,故而做个总结. 谬误之处,万望不吝指教! 闲话不叙! 一.寄宿(Host)WCF服务 1)一种是为一组WCF服务 ...
- 一些有意思的面试题(持续更新) .C语言编程技巧札记
一些有意思的面试题(持续更新) http://blog.csdn.net/wangyuling1234567890/article/details/38565239 C语言编程技巧札记 http:// ...
