| Les deux révisions précédentes Révision précédente Prochaine révision | Révision précédente |
| resume-technique:reaction [11/10/2025 13:15] – Daneel Olivaw | resume-technique:reaction [11/11/2026 22:20] (Version actuelle) – Daneel Olivaw |
|---|
| Nous utilisons [[https://blog.ppom.me/fr-reaction/|reaction]], une alternative efficiente à fail2ban, pour bannir temporairement les adresses à l'origine d'un comportement abusif. | Nous utilisons [[https://blog.ppom.me/fr-reaction/|reaction]], une alternative efficiente à fail2ban, pour bannir temporairement les adresses à l'origine d'un comportement abusif. |
| |
| On considère comme abusif, notamment : les requêtes envoyées à nos systèmes à un rythme trop élevé, les activités de reconnaissance de nos systèmes, les tentatives d'exploitation de vulnérabilités réelles ou supposées de nos systèmes, .... | On considère comme abusif, notamment : les requêtes envoyées à nos systèmes à un rythme trop élevé, les activités de reconnaissance de nos systèmes, les tentatives d'exploitation de vulnérabilités réelles ou supposées de nos systèmes, les requêtes malformées.... |
| |
| ==== Filtres pour nginx ==== | ==== Filtres pour nginx ==== |
| <file json reaction.jsonnet> | <file json reaction.jsonnet> |
| filters: { | filters: { |
| // nginx's default combined log format: | // ... |
| // $remote_addr - $remote_user [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent" | |
| | |
| // Ban suspect HTTP requests | |
| // Those are frequent malicious requests I got from bots | |
| // Make sure you don't have honnest use cases for those requests, or your clients may be banned for 2 weeks! | |
| suspectRequests: { | |
| regex: import 'reaction/nginx_regex.jsonnet', | |
| retry: 2, | |
| retryperiod: '6h', | |
| actions: banFor('48h'), | |
| }, | |
| bruteForce: { | bruteForce: { |
| regex: [ | regex: [ |
| @'^<ip> - [^\[]+\[[^\]]+\] "[^"]*" 429', | @'^<ip> - [^\[]+\[[^\]]+\] "[^"]*" 429', |
| ], | ], |
| retry: 4, | // ... |
| retryperiod: '6h', | |
| actions: banFor('6h'), | |
| }, | }, |
| }, | }, |
| <file json reaction/nginx_regex.jsonnet> | <file json reaction/nginx_regex.jsonnet> |
| [ | [ |
| // Response "400 Bad request" if query type not GET nor POST | // Response "400 Bad request" or "405 Method Not Allowed" |
| @'^<ip> - [^\[]+\[[^\]]+\] "[^PG][^"]*" 400', | // if query type not GET nor POST nor PRI |
| @'^<ip> - [^\[]+\[[^\]]+\] "[^"][^OE][^"]*" 400', | @'^<ip>.*"[^PG][^"]*" 40[05]', |
| @'^<ip> - [^\[]+\[[^\]]+\] "[^"]{2}[^ST][^"]*" 400', | @'^<ip>.*"[^"][^OER][^"]*" 40[05]', |
| | @'^<ip>.*"[^"]{2}[^STI][^"]*" 40[05]', |
| // (?:[^/" ]*/)* is a "non-capturing group" regex that allow for subpath(s) | // (?:[^/" ]*/)* is a "non-capturing group" regex that allow for subpath(s) |
| // example: /code/.env should be matched as well as /.env | // example: /code/.env should be matched as well as /.env |
| @'^<ip>.*"GET /(?:[^/" ]*/)*config\.json [^"]*" 4[0-9][0-9]', | @'^<ip>.*"GET /(?:[^/" ]*/)*config\.json [^"]*" 4[0-9][0-9]', |
| // Likely scanning or recon | // Likely scanning or recon |
| | @'^<ip>.*"GET /[^" ]*(~|\.swp)[^"]*" 4[0-9][0-9]', // Temporary files, backups |
| | @'^<ip>.*"GET /\+CSCO[ELU]\+/[^"]*" 4[0-9][0-9]', // Cisco Adaptive Security Appliances (ASA) |
| @'^<ip>.*"GET /(?:[^/" ]*/)*\.DS_Store [^"]*" 4[0-9][0-9]', // macOS | @'^<ip>.*"GET /(?:[^/" ]*/)*\.DS_Store [^"]*" 4[0-9][0-9]', // macOS |
| @'^<ip>.*"GET /(?:[^/" ]*/)*api/v2/hoverfly/version [^"]*" 4[0-9][0-9]', // Hoverfly | @'^<ip>.*"GET /(?:[^/" ]*/)*api/v2/hoverfly/version [^"]*" 4[0-9][0-9]', // Hoverfly |
| @'^<ip>.*"GET /(?:[^/" ]*/)*ecp/Current/exporttool/microsoft.exchange.ediscovery.exporttool.application[^"]*" 4[0-9][0-9]', // Microsoft Exchange eDiscovery | @'^<ip>.*"GET /(?:[^/" ]*/)*ecp/Current/exporttool/microsoft.exchange.ediscovery.exporttool.application[^"]*" 4[0-9][0-9]', // Microsoft Exchange eDiscovery |
| @'^<ip>.*"GET /json/login_session [^"]*" 4[0-9][0-9]', // HP iLO remote console | @'^<ip>.*"GET /cgi/common.cgi[^"]*" 4[0-9][0-9]', // D-Link IP camera |
| @'^<ip>.*"GET /owa/auth/logon.aspx [^"]*" 4[0-9][0-9]', // Microsoft Exchange | @'^<ip>.*"GET /json/login_session[ ?][^"]*" 4[0-9][0-9]', // HP iLO remote console |
| | @'^<ip>.*"GET /manager/html[ ?][^"]*" 4[0-9][0-9]', // Apache Tomcat |
| | @'^<ip>.*"GET /owa/auth/logon.aspx[ ?][^"]*" 4[0-9][0-9]', // Microsoft Exchange |
| @'^<ip>.*"GET /photo/webapi/query\.[^"]*" 4[0-9][0-9]', // Synology PhotoStation API | @'^<ip>.*"GET /photo/webapi/query\.[^"]*" 4[0-9][0-9]', // Synology PhotoStation API |
| | @'^<ip>.*"GET /stssys.htm[^"]*" 4[0-9][0-9]', // TRENDnet IP camera |
| | @'^<ip>.*"GET /server-info[ ?][^"]*" 4[0-9][0-9]', // Apache mod_info |
| // Likely exploit attempts | // Likely exploit attempts |
| @'^<ip>.*"GET /(?:[^/" ]*/)*phpunit/(?:[^/" ]*/)*Util/PHP/eval-stdin.php', // CVE-2017-9841 | @'^<ip>.*"(GET|POST) (?:[^/" ]*/)*(myadmin|MyAdmin|phpmyadmin|phpMyAdmin|pma)[^/]*/scripts/setup.php[^"]*" 4[0-9][0-9]', // CVE-2009-1151 |
| @'^<ip>.*"GET /(?:[^/" ]*/)*autodiscover\.json[^"]*@[^"]*[Pp]ower[Ss]hell', // CVE-2022-41082 | @'^<ip>.*"(GET|POST) [^" ]*(\.|%2e|%2E){2}(/|%2f|%2F|%5c|%5C)[^"]*" 4[0-9][0-9]', // CWE-22, https://owasp.org/www-community/attacks/Path_Traversal |
| @'^<ip>.*"GET /owa/auth/x.js [^"]*" 4[0-9][0-9]', // CVE-2021-26855 | @'^<ip>.*"(GET|POST) /cgi-bin/php([0-9]|)([.-]cgi|)[ ?][^"]*" 4[0-9][0-9]', // CA-96.11 https://www.php.net/manual/fr/security.cgi-bin.attacks.php |
| @'^<ip>.*"GET /(?:[^/" ]*/)*(\.|%2e){2}(/|%2f)[^"]*" 4[0-9][0-9]', // CWE-22, https://owasp.org/www-community/attacks/Path_Traversal | @'^<ip>.*"(GET|POST) /cgi-bin/(nobody|user)/(Config.cgi|Machine.cgi|Search.cgi)[^"]*"',// CVE-2013-4981, CVE-2025-34054, CVE-2025-57198 (Avtech device) |
| @'^<ip>.*"POST /(?:[^/" ]*/)*(\.|%2e){2}(/|%2f)[^"]*" 4[0-9][0-9]', // CWE-22, https://owasp.org/www-community/attacks/Path_Traversal | @'^<ip>.*"(GET|POST) /HNAP1/ [^"]*" 4[0-9][0-9]', // CVE-2025-2360 |
| | @'^<ip>.*"(GET|POST) /index.action[ ?][^"]*" 4[0-9][0-9]', // CVE-2017-5638, CVE-2020-17530 |
| | @'^<ip>.*"GET (?:[^/" ]*/)*phpunit/(?:[^/" ]*/)*Util/PHP/eval-stdin.php', // CVE-2017-9841 |
| | @'^<ip>.*"GET (?:[^/" ]*/)*autodiscover\.json[^"]*@[^"]*[Pp]ower[Ss]hell', // CVE-2022-41082 |
| | @'^<ip>.*"GET (?:[^/" ]*/)*@fs/[^" ]*?[^" ]*raw', // CVE-2025-30208 |
| | @'^<ip>.*"(GET|POST) /(hnd|tm)Unblock.cgi[ ?][^"]*" 4[0-9][0-9]', // CVE-2025-34037 |
| | @'^<ip>.*"POST /(?:[^/" ]*/)*batch/v1[^"]*" 4[0-9][0-9]', // CVE-2026-63030 |
| // Unusual QUERY type (WebDav, ...) with an error response | // Unusual QUERY type (WebDav, ...) with an error response |
| @'^<ip> - [^\[]+\[[^\]]+\] "PROPFIND [^"]*" 40[0345]', | @'^<ip> - [^\[]+\[[^\]]+\] "PROPFIND [^"]*" 40[0345]', |