Skip to content

Instantly share code, notes, and snippets.

@PinkDraconian
Created February 28, 2022 12:57
Show Gist options
  • Save PinkDraconian/97495727974ef097cd571531e5b219d5 to your computer and use it in GitHub Desktop.
Save PinkDraconian/97495727974ef097cd571531e5b219d5 to your computer and use it in GitHub Desktop.
Can you spot the vulnerability?
<?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");
}
@gekk05
Copy link

gekk05 commented Mar 1, 2022

SSRF via file_get_contents()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment