
23.04.2021, 10:39
|
|
Участник форума
Регистрация: 15.09.2018
Сообщений: 236
С нами:
4033046
Репутация:
212
|
|
Flatpress 1.2
Сайт - flatpress.org
Показалось забавным - пусть здесь побудет.
Аплоад в админке. Есть какие-то проверки, блек лист, но мы все равно можем загрузить php.
Суть в том, что проверка расширения происходит у tmp файла php[\da-zA-Z]{6}
если быть точнее, до нее не доходит, так как расширения нет.
Ну и плюс проверка mime-типа такой констркуцией
PHP код:
[COLOR="#000000"][COLOR="#0000BB"]$finfo[/COLOR][COLOR="#007700"]=[/COLOR][COLOR="#0000BB"]finfo_open[/COLOR][COLOR="#007700"]([/COLOR][COLOR="#0000BB"]FILEINFO_MIME_TYPE[/COLOR][COLOR="#007700"]); [/COLOR][COLOR="#0000BB"]$mime[/COLOR][COLOR="#007700"]=[/COLOR][COLOR="#0000BB"]finfo_file[/COLOR][COLOR="#007700"]([/COLOR][COLOR="#0000BB"]$finfo[/COLOR][COLOR="#007700"],[/COLOR][COLOR="#0000BB"]__FILE__[/COLOR][COLOR="#007700"]); [/COLOR][COLOR="#0000BB"]finfo_close[/COLOR][COLOR="#007700"]([/COLOR][COLOR="#0000BB"]$finfo[/COLOR][COLOR="#007700"]); [/COLOR][/COLOR]
возвращает text/x-php для
PHP код:
[COLOR="#000000"][COLOR="#0000BB"][/COLOR][COLOR="#007700"] $error) {
if ($error == UPLOAD_ERR_OK) { $tmp_name = $_FILES ["upload"] ["tmp_name"] [$key]; // #1 ===================================== $name = $_FILES ["upload"] ["name"] [$key];
$dir = ATTACHS_DIR;
$uploadfilename = strtolower($tmp_name); // #2 =====================================
$isForbidden = false; $deeptest = array(); $extcount = 0; $deeptest = explode('.', $uploadfilename); // #3 ===================================== $extcount = count($deeptest);
if ($extcount == 1) { // #4 проверка пройдена ===================================== $isForbidden = false; } elseif ($extcount == 2) { $check_ext1 = ""; $check_ext1 = trim($deeptest [1], "\x00..\x1F"); if (in_array($check_ext1, $blacklist_extensions)) { $isForbidden = true; } else { $isForbidden = false; } } elseif ($extcount > 2) { $check_ext1 = ""; $check_ext2 = ""; $check_ext1 = trim($deeptest [$extcount - 1], "\x00..\x1F"); if (in_array($check_ext1, $blacklist_extensions)) { $isForbidden = true; } else { $isForbidden = false; } if (!$isForbidden) { $check_ext2 = trim($deeptest [$extcount - 2], "\x00..\x1F"); if (in_array($check_ext2, $blacklist_extensions)) { $isForbidden = true; } else { $isForbidden = false; } } } if ($isForbidden) { $this->smarty->assign('success', $success ? 1 : -1); sess_add('admin_uploader_files', $uploaded_files); return -1; }
if (version_compare(PHP_VERSION, '5.3.0') [/COLOR] ===================================== $this->smarty->assign('success', $success ? 1 : -1); sess_add('admin_uploader_files', $uploaded_files); return -1; }
$ext = strtolower(strrchr($name, '.'));
if (in_array($ext, $imgs)) { $dir = IMAGES_DIR; }
$name = sanitize_title(substr($name, 0, -strlen($ext))) . $ext;
$target = "$dir/$name"; @umask(022); $success = move_uploaded_file($tmp_name, $target); @chmod($target, 0766);
$uploaded_files [] = $name;
$success &= $success; } }
if ($uploaded_files) { $this->smarty->assign('success', $success ? 1 : -1); sess_add('admin_uploader_files', $uploaded_files); }
return 1; }
[/COLOR]
|
|
|