碳基体

奋斗在产品安全第一线的安全妹子

ModSecurity SecRule cheatsheets

通用格式

SecRule VARIABLES OPERATOR [TRANSFORMATION_FUNCTIONS, ACTIONS]


阶段phase

(1)request headers

(2)request body

(3)response headers

(4)response body

(5) logging


一、变量variable

绿色:请求变量  蓝色:server变量  紫色:响应变量 红色:请求体解析变量 黑色:时间变量 橙色:实体变量


二、操作符 operator

绿色:字符串操作符  蓝色:数字操作符 橙色:验证操作副 


三、 事件函数transform function



四、动作action

绿色:disruptive action (每个rule只能有1个disruptive action,如果有多个disruptive action,那么只有最后一个有效,在rule chain中,disruptive action只能出现在第一个rule中)

蓝色:flow action

紫色:metadata action

红色 :variable  action

黄色:logging action  

灰色:special action

黑色:其他



cloudflare 增加了以下action

disabled  DIS exit_blocked(self, "DIS", rulefile, nolog)

simulate SIM exit_blocked(self, "SIM", rulefile, nolog)


五、指令directory



六、常用操作符

| 或者操作符 e.g.REQUEST_URI|REQUEST_PROTOCOL


: 数组取值操作符 e.g. ARGS:p


! 非操作符  e.g. ARGS|!ARGS:z


@ 操作符函数调用  e.g. @rx


t 事务函数调用 e.g.  t:lowercase


& 取数组个数符 e.g.  &ARGS @ge 1


%{COLNAME.VARNAME}变量扩展符  e.g.    SecRule REQUEST_URI_RAW "!@beginsWith https://%{REQUEST_HEADERS.Host}" "drop,tag:'WEB_ATTACK/ILLEGALHTTPPROTOCOL',msg:'host header        

illegal',id:00001,phase:2"




下载地址 

https://pan.baidu.com/s/1bnxTVWF


p.s. 将近2个月没更新博客了,比较习惯将东东记录在印象笔记中,不好,要坚持分享

来源:碳基体

评论

热度(1)