-
-
Save hardword/d69a2c93c034212446af5f02061688b0 to your computer and use it in GitHub Desktop.
Can you spot the vulnerability?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if (!isset($_SERVER['argc']) || $_SERVER['argc'] < 1) { | |
die("Usage: cli <action> <options>"); | |
} | |
$argc = $_SERVER['argc']; | |
$argv = $_SERVER['argv']; | |
switch ($argv[1]) { | |
case "ls": | |
echo "Listing directory"; | |
break; | |
case "download": | |
if (($argc) < 4) { | |
die("Usage: cli download <url> <output-file>"); | |
} | |
$url = $argv[2]; | |
$outputFile = $argv[3]; | |
echo "Downloading ${url} to ${outputFile}"; | |
file_put_contents($outputFile, file_get_contents($url)); | |
break; | |
default: | |
die("Valid command are ls/download"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment