Maybe try getting the user agent. Perhaps you can filter them by that
Best way to handle tons of "hacking attempts" that generates 404
Hi:
I have tons and tons of requests as hacking attempts ... for example, taking the last block today I have requests to:
/filemanager/dialog.php
/asset/filemanager/dialog.php
/assets/filemanager/dialog.php
/server/php/
/fileupload/server/php/
/admin/server/php/
/upload/server/php/
/wp-includes/wlwmanifest.xml
/feed/
/wp-content/plugins/wpdiscuz/themes/default/style-rtl.css
/wp-content/plugins/fancy-product-designer/inc/custom-image-handler.php
/vendor/phpunit/phpunit/src/Util/PHP/eval-stdin.php
/wp-content/langar.php
/wp-includes/small.php
/wp-includes/lfx.php
/wp-content/mu-plugins/db-safe-mode.php
/wp-content/wp-old-index.php?action=login&pass=-1&submit=
/wp-content/plugins/wpconfig.bak.php?act=sf
/wp-includes/wpconfig.bak.php?act=sf
/wp-content/plugins/ubh/up.php
/wp-content/plugins/config.bak.php
/wp-content/themes/config.bak.php
/wp-includes/config.bak.php
/wp-content/config.bak.php
/wp-admin/config.bak.php
/wp-includes/css/css.php
/wp-includes/fonts/css.php
/wp-content/wp-1ogin_bak.php
/wp-content/plugins/ioptimization/IOptimize.php?rchk=
/wp-content/db_cache.php
/wp-content/plugins/backup_index.php
The problem is that I have a component to get notifies each 404 appears, so I can be aware of these issues to handle and solve them (in case a broken link, a mistake coding, etc ...)
But I want to get rid of these notifications since they are false positives.
What is the best method to handle this ?
-
create Routes to null pages ?
-
redirect all of them in .htaccess to Wikipedia page :-D ?
-
any module (with updates) that handle these kind of annoying requests ?
-
other ?
@skater So the only ones you really want to actually know about are ones where someone clicks on a page on your site that takes them to a 404 page?
Say if a content manager in a published post writes <a href="/kontact-us">Contact us</a> with a typo, and some user then clicks on the link in that post, then you want to be notified – but if someone opens their browser and types in www.yoursite.com/rbadudosbds, you don’t want to be notified?
If so, you can take advantage of the fact that most normal user agents set the HTTP_REFERER header when you click on a link, sending the URL of the page the user came from along with the request. You can then set a fallback route and only return a 404 if the HTTP referer is your own app:
Route::fallback(function(Request $request) {
$referrer = parse_url($request->headers->get('referer'));
$referrer = $referrer['scheme'] . '://' . $referrer['host'];
if ($referrer == config('app.url')) {
abort(404);
} else {
return 'piss off hacker';
}
}
Even better, if you can manually trigger your notification plugin directly, you could disable automatic notification on all 404s and instead do this:
Route::fallback(function(Request $request) {
$referrer = parse_url($request->headers->get('referer'));
$referrer = $referrer['scheme'] . '://' . $referrer['host'];
if ($referrer == config('app.url')) {
notify404($request->path());
}
abort(404);
}
That way, everyone gets the correct 404 page, but you only get notified if the request has a referrer that matches your app URL.
Please or to participate in this conversation.