
需要的环境:dvwa
使用的工具:PHP手册
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 ' .
本文详述了DVWA靶场高难度命令执行的代码审计过程,包括trim函数去除字符串首尾空白字符、array函数创建数组、array_keys获取数组键名、str_replace函数实现字符串替换以及stristr函数在操作系统版本判断中的应用。
最低0.47元/天 解锁文章
3462

被折叠的 条评论
为什么被折叠?



