uploadhandler.php,多个WordPress主题’upload-handler.php’任意文件上传漏洞

发布日期:2013-11-17

更新日期:2013-11-19

受影响系统:

WordPress WordPress

描述:

--------------------------------------------------------------------------------

BUGTRAQ  ID: 63768

WordPress是一种使用PHP语言开发的博客平台,用户可以在支持PHP和MySQL 数据库的服务器上架设属于自己的网站。

WordPress的多个主题在upload-handler.php的实现上存在远程文件上传漏洞,攻击者可利用此漏洞上传任意文件到受影响计算机,导致任意代码执行。

*>

测试方法:

--------------------------------------------------------------------------------

警 告

以下程序(方法)可能带有攻击性,仅供安全研究与教学之用。使用者风险自负!

http://www.example.com/wp-content/themes/amplus/functions/upload-handler.php

http://www.example.com/wp-content/themes/dimension/library/includes/upload-handler.php

http://www.example.com/wp-content/themes/euclid/functions/upload-handler.php

http://www.example.com/wp-content/themes/euclid_v1.x.x/functions/upload-handler.php

建议:

--------------------------------------------------------------------------------

厂商补丁:

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
在 Django 中,有多种方式可以实现文件上传以及多个文件上传的功能。下面介绍三种常用的方式。 ### 1. 使用 Django 自带的文件上传模块 Django 自带了文件上传模块 `django.core.files.uploadhandler`,可以使用它来处理文件上传。使用该模块的步骤如下: 1. 在 `settings.py` 中配置文件上传路径: ```python MEDIA_ROOT = '/path/to/media/' MEDIA_URL = '/media/' ``` 2. 在需要上传文件的视图函数中,使用 `request.FILES` 获取上传的文件,然后保存文件: ```python def upload_file(request): if request.method == 'POST' and request.FILES: file = request.FILES['file'] with open(os.path.join(settings.MEDIA_ROOT, file.name), 'wb+') as destination: for chunk in file.chunks(): destination.write(chunk) ``` 3. 在模板中添加文件上传表单: ```html <form method="post" enctype="multipart/form-data"> {% csrf_token %} <input type="file" name="file"> <button type="submit">上传</button> </form> ``` ### 2. 使用第三方插件 django-formtools django-formtools 是一个 Django 第三方插件,提供了一些常用的表单处理工具,其中包括文件上传。使用该插件的步骤如下: 1. 安装 django-formtools: ``` pip install django-formtools ``` 2. 在视图函数中使用 `FileUploadView` 处理文件上传: ```python from formtools.wizard.views import SessionWizardView from django.core.files.storage import FileSystemStorage class FileUploadView(SessionWizardView): file_storage = FileSystemStorage(location=os.path.join(settings.MEDIA_ROOT, 'uploads')) def done(self, form_list, **kwargs): file_data = [form.cleaned_data.get('file') for form in form_list] for file in file_data: with open(os.path.join(settings.MEDIA_ROOT, file.name), 'wb+') as destination: for chunk in file.chunks(): destination.write(chunk) return HttpResponse('文件上传成功') ``` 3. 在模板中设置表单: ```html <form method="post" enctype="multipart/form-data"> {% csrf_token %} {{ wizard.management_form }} {% for form in wizard.forms %} {{ form.as_p }} {% endfor %} <button type="submit">上传</button> </form> ``` ### 3. 使用第三方插件 django-storages django-storages 是一个 Django 第三方插件,提供了多种文件存储后端支持,包括本地文件系统、Amazon S3、Google Cloud Storage 等。使用该插件的步骤如下: 1. 安装 django-storages: ``` pip install django-storages ``` 2. 在 `settings.py` 中配置文件存储后端: ```python DEFAULT_FILE_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage' AWS_ACCESS_KEY_ID = 'your-access-key-id' AWS_SECRET_ACCESS_KEY = 'your-secret-access-key' AWS_STORAGE_BUCKET_NAME = 'your-bucket-name' AWS_S3_REGION_NAME = 'your-region-name' ``` 3. 在视图函数中使用 `request.FILES` 获取上传的文件,然后保存文件: ```python from django.core.files.storage import default_storage def upload_file(request): if request.method == 'POST' and request.FILES: file = request.FILES['file'] default_storage.save(file.name, file) ``` 4. 在模板中添加文件上传表单: ```html <form method="post" enctype="multipart/form-data"> {% csrf_token %} <input type="file" name="file"> <button type="submit">上传</button> </form> ```

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值