简体   繁体   English

Urls / lpt1和/ com1导致IIS呈现其自己的死亡屏幕

[英]Urls /lpt1 and /com1 cause IIS to render its own screen of death

When running a recent SkipFish scan - we found that IIS (7.5) returns the following if you call /lptX or /comX (where X is a number 1-9). 在运行最近的SkipFish扫描时-我们发现,如果您调用/lptX/comX (其中X是1-9的数字),则IIS(7.5)将返回以下内容。

Server Error in '/' Application.

The resource cannot be found.

Description: HTTP 404. The resource you ...[and so on]...

This is dispite the fact that we have custom [pretty] errors at the site-level and at the web server config level. 这与我们在站点级别和Web服务器配置级别存在自定义[pretty]错误无关。

Try it on your IIS box now if you have one - http://localhost/lpt1 should do it. 如果您有一个,请立即在IIS框中尝试使用-http:// localhost / lpt1应该可以。

I'm guessing this is a legacy thing from 'the good ol days' of LPT printers and mice connecting via COM ports. 我猜这是LPT打印机和鼠标通过COM端口连接的“美好时光”的遗留事物。 But it is slightly unsettling to see and area of IIS that I can't config. 但是看到我无法配置的IIS区域有些令人不安。

Is it possible to force IIS to serve a custom 404 page even for these 'special' URLs? 是否可以强制IIS为这些“特殊” URL提供自定义404页面?

Until ASP.NET 4.0 it wasn't possible to use certain reserved filenames such as con , lpt , aux and so in on your urls: 在ASP.NET 4.0之前,无法在URL中使用某些保留的文件名,例如conlptaux等:

Zombie Operating Systems and ASP.NET MVC 僵尸操作系统和ASP.NET MVC

This was a limitation of ASP.NET, not MVC. 这是ASP.NET的限制,而不是MVC。

However the good news is that it's now possible: 不过,好消息是现在有可能:

Putting the Con (COM1, LPT1, NUL, etc.) Back in your URLs 将骗局(COM1,LPT1,NUL等)放回您的URL中

If you're not using ASP.NET 4.0, you should be able to catch these 404's using IIS7's own <httpErrors> configuration settings. 如果您不使用ASP.NET 4.0,则应该能够使用IIS7自己的<httpErrors>配置设置来捕获这404个。

With ASP .NET 3.5 you can use an url rewrite rule of the url rewrite module in order to change the url to a valid one. 使用ASP .NET 3.5,可以使用url重写模块的url重写规则,以将url更改为有效的URL。

The url rewite module is: url rewite模块是:

The Microsoft URL Rewrite Module 2.0 for IIS 7 and above enables IIS administrators to create powerful customized rules to map request URLs to friendly URLs that are easier for users to remember and easier for search engines to find 用于IIS 7及更高版本的Microsoft URL重写模块2.0使IIS管理员可以创建功能强大的自定义规则,以将请求URL映射到友好的URL,这些URL易于用户记住并且更易于搜索引擎查找。

Something like: 就像是:

<rewrite>
  <rules>
    <rule name="CON rewrite" stopProcessing="true">
      <match url="(.*)/(con\.)(.*)" />
      <action type="Redirect" url="{R:1}/con-{R:3}" redirectType="SeeOther" />
    </rule>     
  </rules>
</rewrite>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM