BARIH0x
GITHUBHTB
  • 📀BARIHO
    • 📜 CERTIFICACIONES
      • ✅eJPT
      • ✅OSWP
      • OSCP
  • 🛡️ PROYECTOS
    • ⚙️HOME LAB
      • 🍓PI-HOLE
      • 🗄️OPENMEDIAVAULT
      • ⛓️HOME ASSISTANTS [TRABAJANDO]
      • 🌐OPNSense [PROXIMO]
    • ⛔T-POT
  • ⚔️ WALKTHROUGH
    • 📄 HackTheBox
      • Legacy
      • Blue
      • Lame
    • 📄 TryHackme
      • 27 ~ Cmess - Linux
      • 26 ~ Battery - Linux
      • 25 ~ ConvertMyVideo - Linux
      • 24 ~ DogCat - Linux
      • 23 ~ Wonderland - Linux
      • 22 ~ Lian_Yu - Linux
      • 21 ~ Tomghost - Linux
      • 20 ~ LazyAdmin - Linux
      • 19 ~Boiler CTF - Linux
      • 18 ~ Couchdb - Linux
      • 17 ~ 0day - Linux
      • 16 ~ Brute It - Linux
      • 15 ~ Blog - Linux
      • 14 ~ Madness - Linux
      • 13 ~ Year Of The Rabbit - Linux
      • 12 ~ Inclusion - Linux
      • 11 ~ UltraTech - Linux
      • 10 ~ Anonymous - Linux
      • 9 ~ Ignite - Linux
      • 8 ~ Vulnversity - Linux
      • 7 ~ Basic Pentesting - Linux
      • 6 ~ MrRobot - Linux
      • 5 ~ Agent-Sudo - Linux
      • 4 ~ EasyCTF - Linux
      • 3 ~ Thompson - Linux
      • 2 ~ RootMe - Linux
      • 1 ~ Bounty Hacker - Linux
    • 🎮 OverTheWire
      • BANDIT
      • NATAS
        • Natas 0
    • 🎮 DVWA
      • Instalación DVWA (XAMPP)
      • Instalación DVWA (DOCKER)
      • Command Injection
      • File Inclusion
      • SQL Injection
  • 🛠️RECURSOS
  • Herramientas
  • 🗃️ Scripts
    • KillSSH
  • 💣 Maquinas
    • Login Wordpress - MrRobot
    • Fuzzing - Madness
  • 🔎 LINKS DE INTERERES
Con tecnología de GitBook
En esta página
  • Low Security Level
  • Medium Security Level
  • High Security Level
  1. ⚔️ WALKTHROUGH
  2. 🎮 DVWA

Command Injection

Low Security Level

No tiene medida de seguridad.

<?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.

<?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>";
}

?>

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.

<?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>";
}

?>

En este caso, simplemente ejecutando "|" y el comando de seguido. ej: |whoami nos ejecutara el comando.

AnteriorInstalación DVWA (DOCKER)SiguienteFile Inclusion

Última actualización hace 3 años