Logo Questions Linux Laravel Mysql Ubuntu Git Menu

Detect if Mod_Security Is Installed With PHP?

Is there any simple way to detect if mod_security is installed & enabled using just PHP? Ideally without any exec() terminal type commands to be executed.

Some people have recommended using apache_get_modules() but this specific web-host does not allow it to show. This is also mentioned by other users here: http://www.devcomments.com/apache_get_modules-solution-to130703.htm

like image 852
user384030 Avatar asked Jul 05 '10 22:07


People also ask

How check mod<UNK>Security is enabled or not in PHP?

phpinfo(); ?> Step 4 – You can view the file by typing http://yourdomain/phpinfo.php in your browser's address bar. Once loaded, search for mod_security2 and if you can't find such a section, the module is not installed.

What is Mod_security in Apache?

Mod_security is an apache module that helps to protect your website from various attacks. It is used to block commonly known exploits by use of regular expressions and rule sets and is enabled on all InMotion web hosting plans.

What is Mod_security in Cpanel?

ModSecurity is a rule-based firewall; it compares requests to a list of rules, looking for patterns that match attacks such as SQL injection, session hijacking, cross-site scripting, and more. Rules are typically provided as a rule set created by a third party, although users can add their own.

1 Answers

Try the apache_get_modulesfunction to get an array of the loaded modules. If that module is loaded but not listed there, you might want to try phpinfo with phpinfo(INFO_MODULES) instead:

$contents = ob_get_clean();
$moduleAvailable = strpos($contents, 'mod_security') !== false;
like image 94
Gumbo Avatar answered Sep 21 '22 02:09