朋友发的一个ctf题,做了好久才做出来,记录一下。
0x01 源码
highlight_file(__FILE__);
@mkdir("./upload");
if (isset($_POST['submit'])) {
$is_upload = false;
$text = null;
if(!empty($_FILES['upload_file'])){
$allow_type = array('image/jpeg','image/png','image/gif');
if(!in_array($_FILES['upload_file']['type'],$allow_type)){
$text = "type forbidden";
}else{
$file = empty($_POST['save_name']) ? $_FILES['upload_file']['name'] : $_POST['save_name'];
$temp_name = $_FILES['upload_file']['tmp_name'];
if (!is_array($file)) {
$file = explode('.', strtolower($file));
}
$ext = end($file);
$allow_suffix = array(&