如何在上传时阻止恶意文件(.exe,.msi和.bat) [英] How to block malicious files while uploading(.exe, .msi, and .bat)

查看:90
本文介绍了如何在上传时阻止恶意文件(.exe,.msi和.bat)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我遇到了一个场景,即当我们的扩展名更改为可接受的扩展名时,我们必须阻止上传.exe或.bat或.msi文件(.txt,.html,.htm,.odt,.rtf,.doc,.docx)。



寻找阻止所有类型上传的通用解决方案可执行文件。



谢谢,

Tarun



什么我试过了:



我使用过Mime / Extension类型但它没有用。

我找到了一个解决方案只阻止.exe文件,但仍然寻找阻止所有类型的可执行文件的常用方法。

c# - 即使在重命名其扩展后也阻止exe上传 - Stack Overflow [ ^ ]

推荐答案

你不能阻止所有可执行文件,或者至少不容易:它们只是包含二进制文件的文件一开始的特定字节序列,通常不会出现在其他数据中 - 但它们可能存在于某些数据中。



见这里:文件签名列表 - 维基百科 [ ^ ]然后查看下载文件的开头以检查它。
YOu can't block all executable files, or at least not easily: they are just binary files which will contain a particular sequence of bytes at the start, which will not normally be present in other data - but it's possible that they might in some data.

See here: List of file signatures - Wikipedia[^] And then look at the start of the download file to check it.


为什么?



除非你的服务器或其他客户将来要执行它们,有什么意义呢?



除非在最明显的情况下,否则无法阻止上传所有可执行格式。总是有办法欺骗你的系统接受一个。
Why?

Unless your server or some other client is going to execute them in the future, what's the point?

You can't prevent the upload of all executable formats except in the most obvious cases. There is always going to be a way to fool your system into accepting one.


这篇关于如何在上传时阻止恶意文件(.exe,.msi和.bat)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆