Created
September 16, 2011 03:19
-
-
Save jonmaim/1221124 to your computer and use it in GitHub Desktop.
Really unsecure php image proxy.
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 | |
$filename = $_GET['url']; | |
$ext = pathinfo($filename, PATHINFO_EXTENSION); | |
switch ($ext) { | |
case "gif": | |
header('Content-Type: image/gif'); | |
readfile($filename); | |
break; | |
case "png": | |
header('Content-Type: image/png'); | |
readfile($filename); | |
break; | |
case "jpg": | |
default: | |
header('Content-Type: image/jpeg'); | |
readfile($filename); | |
break; | |
} | |
?> |
how to fix ?
by changing:
readfile($filename);
to:
readfile('./images/' . $filename);
Very insecure, my friend.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
curl http://localhost/unsecure_php_image_proxy.php?url=/etc/passwd