MVC, Elmah, obvious hacker attempts and the “general” IgnoreRoutes

Can anyone give some advice on filtering my Elmah magazine ( http://code.google.com/p/elmah/ )?

Elmah was a very valuable tool in covering my obvious mistakes and shortcomings in my web application.

However, now ... most of Elmah's recordings are not related to my own stupidity (well, maybe they do - this is my question), but any advice would be greatly appreciated.

My Elmah magazine now has 10,000 entries, similar to:

  • The controller for the path '/ws/login.php' could not be found or it does not implement IController.
  • The controller for the path '/ text / javascript' was not found or it does not implement IController.
  • The controller for the path '/jlkqyvaugdaktp.html' cannot be found or is not implemented by IController. [[Actually 100 with these !! ... Do these random pages mean something in "HackerDom"? ]]
  • The controller for the path '/Scripts/thickbox/macFFBgHack.png' cannot be found or it does not implement IController.

So .. to the Question

Obviously, the vast majority of these exceptions are thrown by IController ... can I tell Elmah to just "forget" about them and keep logging my real exceptions?

Or is it that my very general installation of MVC IgnoreRoute is not good enough? Should I ignore ".htm", "* .php" and all the others so that I can more realistic see Elmah messages about pages / objects / objects, which, apparently, can be more true for my application?

Thank you very much for your time and attention.

Setting up my existing route looks like this:

routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.IgnoreRoute("{*favicon}", new { favicon = @"(.*/)?favicon.ico(/.*)?" }); routes.IgnoreRoute("{*forums}", new { forums = @"cccForums/.*" }); routes.IgnoreRoute("{file}.txt"); /// REAL ROUTES routes.MapRoute( "ItemIndex", // Route name "Item/Index/{page}", // URL with parameters new { controller = "PageItem", action = "Index", page = 1} // Parameter defaults ); ............. ............. /// LAST CASE routes.MapRoute("Error", "{*url}", new { controller = "Site", action = "Map" }); 
+4
source share
2 answers

One solution would be to implement a caught route that redirects all unknown requests to page 404. This will prevent an uncaught exception, and end users will get a beautiful page (non-hacker sort).

 routes.MapRoute("Error", "{*url}", new { controller = "Error", action = "http404" } ); 

Put this at the end of your registration route function in global.asax. You should see all ELMAH errors.

EDIT

Don't go to bed! :) If you are interested in not reporting 404 errors (or any other types of errors in this regard with ELMAH), you should be able to do something similar in your web.config:

 <elmah> ... <errorFilter> <test> <equal binding="HttpStatusCode" value="404" type="Int32" /> </test> </errorFilter> </elmah> 

ELMAH ErrorFiltering Documentation

+3
source

If you ignore them using IgnoreRoute , trying to crack will still make it up to ASP.NET. This loads your server. Why not block them on your firewall?

0
source

All Articles