Command Injection
Low Security Level
<?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
echo "<pre>{$cmd}</pre>";
}
?>Simplemente poniendo ";", podremos escapar y ejecutar comandos.
Medium Security Level
Malas practicas de seguridad.
En este caso, nos elimina el ";" y el "&&" pero no el "||", y con este ultimo podremos ejecutar comandos.
High Security Level
Malas prácticas más duras o alternativas.
En este caso, simplemente ejecutando "|" y el comando de seguido. ej: |whoami nos ejecutara el comando.
Última actualización