Medium
Command Injection level Medium on DVWA
Di bawah ini adalah source-code dari command injection level medium di DVWA.
vulnerabilities/exec/source/medium.php
<?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>";
}
?>
Mencari Informasi
Terlihat dibaris ke-7 sampai 11, terdapat blacklist untuk string &&
dan ;
pada inputan. Tetapi seperti yang telah di bahas sebelumnya terdapat alternatif lain yaitu |
. 😁
Melakukan Serangan
Cukup ganti inputan menjadi menggunakan tanda |
, dan hasilnya akan seperti berikut:
Last updated
Was this helpful?