0
私は、セキュリティ上の脆弱性について学ぶためにDVWAを使用しています。私の理解からコマンドインジェクションDVWA難易度
<?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>";
}
?>
私が入力|| ls
として与える場合、コードは''
で||
を置き換える必要がありますので、注射はいけない:コマンドインジェクションの一部には以下に示すように、バックエンドのコードがあります作業。下図のように私の驚きに、注射は、ファイルの出力を生成働いたものの:
ただ一つの小さなトラップであるべき||前|単一の文字の前に二重の文字を置き換える必要があるためです。それは面白い小さな変わったものです! – TimBrownlaw
@TimBrownlaw答えとして入力して喜んで受け入れるならば:) –
私は答えを作成しました:)乾杯 – TimBrownlaw