modsecurity:writing_your_own_mod_security_rules
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | |||
modsecurity:writing_your_own_mod_security_rules [2016/10/14 14:11] – [ModSecurity - Writing Your Own mod_security Rules] peter | modsecurity:writing_your_own_mod_security_rules [2019/11/30 14:21] (current) – removed peter | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== ModSecurity - Writing Your Own mod_security Rules ====== | ||
- | |||
- | In this section, we'll create a rule chain which blocks the request if certain " | ||
- | |||
- | |||
- | <file bash / | ||
- | < | ||
- | < | ||
- | <?php | ||
- | if(isset($_POST[' | ||
- | echo $_POST[' | ||
- | else | ||
- | { | ||
- | ?> | ||
- | <form method=" | ||
- | Enter something here:< | ||
- | <input type=" | ||
- | </ | ||
- | <?php | ||
- | } | ||
- | ?> | ||
- | /body> | ||
- | </ | ||
- | </ | ||
- | |||
- | Custom rules can be added to any of the configuration files or placed in modsecurity directories. | ||
- | |||
- | <code bash> | ||
- | vi / | ||
- | </ | ||
- | |||
- | Add the following to this file: | ||
- | |||
- | <file bash / | ||
- | SecRule REQUEST_FILENAME " | ||
- | SecRule REQUEST_METHOD " | ||
- | SecRule REQUEST_BODY "@rx (? | ||
- | </ | ||
- | |||
- | Save the file and reload Apache. Open http:// | ||
- | |||
- | You'll either see a 403 page and a log entry or only a log entry based on **SecRuleEngine** setting. | ||
- | |||
- | <code bash> | ||
- | SecRule VARIABLES OPERATOR [ACTIONS] | ||
- | </ | ||
- | |||
- | Here we used the chain action to match variables **REQUEST_FILENAME** with **form.php**, | ||
- | |||
- | |||
- | ===== References ===== | ||
- | |||
- | https:// | ||
modsecurity/writing_your_own_mod_security_rules.1476454318.txt.gz · Last modified: 2020/07/15 09:30 (external edit)