我正在使用mod_security 2.6.3,我希望能够基于规则严重性级别执行shell脚本.我正在使用核心规则集(CRS),它在检测到攻击时将严重性级别设置为2(对于"严重").
我想在严重程度足够高时执行我的脚本.
我尝试使用该SecDefaultAction设置,例如:
SecDefaultAction "phase:2,log,deny,status:403,exec:/path/to/my/script"
Run Code Online (Sandbox Code Playgroud)
但是,由于'exec'动作是一种"非破坏性"动作,它总是会被执行,无论是关键规则还是非关键规则都是如此.
我可以通过每个批评SecRule并在它旁边添加"exec",但这将是乏味的(并且重复,丑陋).
我以为我可以这样做:
SecRule ENV:SEVERITY "@lt 4" "exec:/path/to/my/script"
Run Code Online (Sandbox Code Playgroud)
但不知怎的,它永远不会被执行,可能是因为关键规则有一个阻止或拒绝语句,它会停止规则处理(因为被认为具有破坏性).
我也尝试过使用CRS异常评分功能,如下所示:
SecRule TX:ANOMALY_SCORE "@ge 4" "exec:/path/to/my/script"
Run Code Online (Sandbox Code Playgroud)
但它仍然没有得到处理.有关如何做到这一点的任何想法?
今天,我为nginx安装了mod_security.我将以下块添加到/etc/nginx/nginx:
server {
listen 80;
server_name localhost;
location / {
ModSecurityEnabled on;
ModSecurityConfig modsecurity.conf;
}
}
Run Code Online (Sandbox Code Playgroud)
重新启动Nginx后,我收到以下错误:
nginx: [emerg] unknown directive "ModSecurityEnabled" in /etc/nginx/conf.d/nginx.conf:6
nginx: configuration file /etc/nginx/nginx.conf test failed
Run Code Online (Sandbox Code Playgroud)
产量nginx -V:
nginx version: nginx/1.4.7
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-4) (GCC)
TLS SNI support enabled
configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用yum install mod_security安装mod_security,但出现此错误
Loaded plugins: priorities, update-motd, upgrade-helper
amzn-main/latest | 2.1 kB 00:00
amzn-updates/latest | 2.3 kB 00:00
Resolving Dependencies
--> Running transaction check
---> Package mod_security.x86_64 0:2.7.3-3.23.amzn1 will be installed
--> Processing Dependency: httpd-mmn = 20051115 for package: mod_security-2.7.3-3.23.amzn1.x86_64
--> Running transaction check
---> Package httpd.x86_64 0:2.2.27-1.2.amzn1 will be installed
--> Processing Dependency: httpd-tools = 2.2.27-1.2.amzn1 for package: httpd-2.2.27-1.2.amzn1.x86_64
--> Running transaction check
---> Package httpd-tools.x86_64 0:2.2.27-1.2.amzn1 will be installed
--> Processing Conflict: httpd24-2.4.9-1.55.amzn1.x86_64 conflicts httpd < 2.4.9
--> …Run Code Online (Sandbox Code Playgroud) 我无法访问我的磁盘管理面板.我在.htaccess中添加了以下代码.syntax代码对我不起作用.请告诉我如何禁用我的IP地址的mod_security.
语法代码:
SetEnvIfNoCase Remote_Addr ^208.xxx.xxx.103$ MODSEC_ENABLE=Off
Run Code Online (Sandbox Code Playgroud)
**错误:**
被禁止
您无权访问/管理此服务器.
我做了很多研究,我发现了很多东西,但是还没能找到能做我需要做的事.首先,我在运行ModSecurity 2.7.3的CentOS 7服务器上.
我希望能够扫描除某些参数之外的所有参数,并通过已经设置的所有标准核心规则运行它们.例如,如果我有一个文件path/to/myfile.php,它有2个参数发送给它param1和param2.当用户点击时,myfile.php我希望它能够运行它可以反对的所有可爱的检查param1,param2除非param2我不需要它进行检查,WEB_ATTACK/XSS因为它应该期望该字段的某些HTML(或其他).
我不认为我可以通过ID删除规则(除非我的理解有缺陷).我们目前正在登台服务器上进行设置,然后我们将安装ModSecurity以及我们在登台服务器上设置的排除项,并将它们复制到实时服务器.我不认为规则ID会与登台日志相匹配(除非我误解了某些内容)并且在我们的实时服务器上抛出ModSecurity并等待规则开始跳闸并不"有趣".
这是我试过的......
<LocationMatch /path/to/myfile.php>
<IfModule mod_security2.c>
SecRuleEngine Off # This is super bad I know
</IfModule>
</LocationMatch>
Run Code Online (Sandbox Code Playgroud)
这是一个坏主意,所以我可以这样做......
<LocationMatch /path/to/myfile.php>
<IfModule mod_security2.c>
SecRuleRemoveByTag "WEB_ATTACK/XSS" # better but.....still not close enough
</IfModule>
</LocationMatch>
Run Code Online (Sandbox Code Playgroud)
所以我尝试过没有成功的东西,如下所示:
SecRule ARGS|!ARGS:param2 "@detectXSS" # only 2.8.0 and above :(
# or
SecRule ARGS|!ARGS:param2 "ctl:ruleRemoveByTag=WEB_ATTACK/XSS"
# or
SecRule REQUEST_FILENAME "@streq /path/to/myfile.php" "pass,ctl:ruleRemoveByTag=WEB_ATTACK/XSS;ARGS:param2"
Run Code Online (Sandbox Code Playgroud)
ModSecurity的文档很好,但我需要更深入的理解,特别是ctl的东西.我也看了一些其他的问题, …
我在 Apache 2.4 中使用mod_security。在这个平台上,我们有一个电子商务系统,其管理工具使用以下 URL:
我想达到的目标:
不,“后端”不是物理存在的目录,它是一个 MVC 映射 :) 所以我正在寻找mod_rewrite 和 mod_security 之间的某种组合。
有人有什么想法吗?:)
提前致谢,迈克尔
我正在使用 Google Cloud Platform 来测试 ModSecurity,我正在使用教程来启动它。但是,我需要每隔一段时间重新启动 Apache。我正在使用 Ubuntu 18.04。我写了sudo systemctl restart apache2,但错误又回来了,上面写着Failed to restart apache2.service: Unit apache2.service not found。我该怎么办?
我们之前已将htmlpurifier集成到我们基于LAMP的产品中,但它有点慢.最近,我们开启了mod_security.这两个都是OWASP项目的一部分(owasp在内部使用htmlpurifer,我检查过),所以我认为安全性是多余的.
你会建议什么?关闭htmpurifier是一个可行的选择吗?谢谢你的回答.
我刚刚在Centos5服务器上使用了Mod Security,我们现在在error_log中获得以下内容:
[Thu Nov 12 16:20:19 2015] [error] [client 88.15.76.8] ModSecurity: Access denied with code 403 (phase 2). Pattern match "([\\\\~\\\\!\\\\@\\\\#\\\\$\\\\%\\\\^\\\\&\\\\*\\\\(\\\\)\\\\-\\\\+\\\\=\\\\{\\\\}\\\\[\\\\]\\\\|\\\\:\\\\;\\"\\\\'\\\\\\xc2\\xb4\\\\\\xe2\\x80\\x99\\\\\\xe2\\x80\\x98\\\\`\\\\<\\\\>].*){8,}" at REQUEST_COOKIES:_eventqueue. [file "/etc/httpd/modsecurity.d/activated_rules/modsecurity_crs_41_sql_injection_attacks.conf"] [line "169"] [id "981172"] [rev "2.2.5"] [msg "Restricted SQL Character Anomaly Detection Alert - Total # of special characters exceeded"] [data "}"] [hostname "www.mydomain.com"] [uri "/company/geodis-uk-limited/general-maintenance-assistant-1485.html"] [unique_id "UbGaGB-esj8AAAa98bEAAAAn"]
Run Code Online (Sandbox Code Playgroud)
阻止这种情况发生的最佳方法是什么?
我已使用以下说明安装了 Mod Security:https : //www.digitalocean.com/community/tutorials/how-to-set-up-modsecurity-with-apache-on-ubuntu-14-04-and-debian- 8
它似乎工作正常,但我似乎无法为 WordPress 登录创建例外。我已将以下内容添加到我的虚拟主机文件中:
<Directory "/var/www/domain.com/public_html/wp-admin">
<IfModule security2_module>
SecRuleEngine Off
</IfModule>
</Directory>
Run Code Online (Sandbox Code Playgroud)
我还尝试了以下方法:
<LocationMatch "/wp-admin">
<IfModule security2_module>
SecRuleEngine Off
</IfModule>
</LocationMatch>
Run Code Online (Sandbox Code Playgroud)
以及两者的不同组合。
我正在运行 Ubuntu 16.04.2,但我想它与 14.04 相同,对吧?
mod-security ×10
apache ×5
security ×3
php ×2
amazon-ec2 ×1
apache2 ×1
htmlpurifier ×1
magento ×1
mod-rewrite ×1
nginx ×1
owasp ×1
ubuntu-16.04 ×1
ubuntu-18.04 ×1