学习ModSecrity Handbook之摘录
1.ModSecurity四大原則:靈活性、被動性、可預測性、功能質量而不是數量。
2.Audit log directives
Directive | Description |
| SecAuditEngine | 控制審計日志引擎;可能的值:打開、關閉或僅關聯 |
| SecAuditLog | 審計日志文件的路徑 |
| SecAuditLog2 | 另一個審計日志文件的路徑(副本) |
| SecAuditLogParts | 指定將記錄事務的哪個部分。 |
| SecAuditLogRelevantStatus | 指定哪些響應狀態將被認為是相關的。 |
| SecAuditLogStorageDir | 將存儲并發審計日志文件的路徑。 |
| SecAuditLogType | 指定要使用的審計日志的類型:串行或并發。 |
| ? | ? |
3.Audit log parts
| Part letter | Description |
| A | 審計日志頭(強制) |
| B | 請求頭 |
| C | 請求體 |
| D | 預訂的 |
| E | 響應體 |
| F | 響應頭 |
| G | 預訂的 |
| H | 審計日志拖車,其中包含其他數據 |
| I | 緊湊的請求體替代(對C部分),不包括文件 |
| J | 預訂的 |
| K | 包含與事務匹配的所有規則的列表。 |
| Z | 最后邊界(強制性) |
4.common mlogc problems
| Error message | Description |
| couldn't connect to host | 無法到達服務器。這可能意味著服務器本身已經故障,但是它還可能表明存在網絡問題。您可以研究curl返回代碼,以確定問題的確切原因。 |
| Possible SSL negotiation error | 最常見的情況是,此消息將意味著您將mlogc配置為提交明文,但是遠程服務器使用SSL。確保ConsoleURI參數開始于"https://". |
| Unauthorized | 憑據不正確。檢查SensorUsername和SensorPassword參數。 |
| For input string:"0,0"? ? ?? | 遠程服務器可以使用任何響應狀態代碼指示內部錯誤。除了200和409,但這些錯誤被視為瞬態錯誤 。ModSecurity社區控制臺存在一個長期存在的問題,它用500代碼響應一個無效的審計日志條目。? 500響應代碼的使用會使mlogc暫停并嘗試再次傳遞,結果卻再次看到控制臺失敗。 這一過程無限期地繼續下去,目前唯一的解決辦法是追查違規行為。 審核傳感器上的日志條目并手動刪除它。 |
5.File upload directives
| Directive | Description |
| SecUploadDir | 指定存儲被截獲文件的位置。 |
| SecUploadFileMode | 指定將用于存儲文件的權限。 |
| SecUploadKeepFiles | 指定是否存儲上傳的文件(On,Off,RelevantOnly) |
6.Rule language directives
| Directive | Description |
| SecAction | 執行無條件的動作。這個指令本質上是一個始終匹配的規則。 |
| SecDefaultAction | 指定默認動作列表,該列表將在隨后的規則中使用 |
| SecMarker | 創建一個標記,該標記可與skipAfter 操作一起使用。標記創建了一個規則,該規則不執行任何操作,但是為其分配了一個ID。 |
| SecRule | 創建規則 |
| SecRuleInheritance | 控制規則是否在子配置上下文中繼承。 |
| SecRuleRemoveById | 使用給定的ID移除規則。 |
| SecRuleScript | 創建使用Lua實現的規則。 |
| SecRuleRemoveByMsg | 移除其消息與給定正則表達式匹配的規則。 |
| SecRuleUpdataActionById | 將規則的操作列表替換為給定的ID,并將提供的動作替換為list |
7.SecRule VARIABLES OPERATOR [TRANSFORMATION_FUNCTION, ACTIONS]
8.Request variables
| Variable | Description |
| ARGS | 請求參數(只讀集合) |
| ARGS_COMBINED_SIZE | 所有請求參數的合計大小 |
| ARGS_NAMES | 請求參數的名稱(集合) |
| ARGS_GET | 查詢字符串參數(只讀集合) |
| ARGS_GET_NAMES | 查詢字符串參數名稱(只讀集合) |
| ARGS_POST | 請求體參數(只讀集合) |
| ARGS_POST_NAMES | 請求體參數的名稱(只讀集合) |
| FILES | 文件名(只讀集合) |
| FILES_COMBINED_SIZE | 所有上傳文件的組合大小 |
| FILE_NAMES | 文件參數名稱(只讀集合) |
| FILES_SIZES | 文件大小列表(只讀集合) |
| FILES_TMPNAMES | 臨時文件名列表(只讀集合) |
| PATH_INFO | 額外路徑信息 |
| QUERY_STRING | 請求的查詢字符串 |
| REMOTE_USER | 遠程用戶 |
| REQUEST_BASENAME | 請求URI basename |
| REQUEST_BODY | 請求體 |
| REQUEST_COOKIES | 請求cookie(只讀集合) |
| REQUEST_COOKIES_NAMES | 請求cookie的名稱(只讀集合) |
| REQUEST_FILENAME | 請求URI文件名/路徑 |
| REQUEST_HEADERS | 請求頭(集合,只讀) |
| REQUEST_HEADERS_NAMES | 請求頭的名稱(只讀集合) |
| REQUEST_LINE | 請求行 |
| REQUEST_METHOD | 請求方法 |
| REQUEST_PROTOCOL | 請求協議 |
| REQUEST_URI | 請求URI,轉換為排除主機名 |
| REQUEST_URI_RAW | 請求URI,正如它在請求中顯示的那樣 |
9.Server variables
Variable? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Description
AUTH_TYPE? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Authentication?type
REMOTE_ADDR? ? ? ? ? ? ? ? ? ? ? ? ? ?Remote?address
REMOTE_HOST? ? ? ? ? ? ? ? ? ? ? ? ? ? Remote?host
REMOTE_PORT? ? ? ? ? ? ? ? ? ? ? ? ? ? Remote?port
SCRIPT_BASENAME? ? ? ? ? ? ? ? ? ? ?Script?basename
SCRIPT_FILENAME? ? ? ? ? ? ? ? ? ? ? ?Script?filename/path
SCRIPT_GID? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Script group?ID
SCRIPT_GROUPNAME? ? ? ? ? ? ? ? ? Script group?name
SCRIPT_MODE? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Script? permissions
SCRIPT_UID? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Script user?ID
SCRIPT_USERNAME? ? ? ? ? ? ? ? ? ? ? ?Script user?name
SERVER_ADDR? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Server?address
SERVER_NAME? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Server?name
SERVER_PORT? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Server?port
10.Response variables
Variable? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Description
RESPONSE_BODY? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Response body?
RESPONSE_CONTENT_LENGTH? ? ? ? ? ? ?Response?content?length?
RESPONSE_CONTENT_TYPE? ? ? ? ? ? ? ? ? ?Response?content?type
RESPONSE_HEADERS? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Response headers (read-only collection)?
RESPONSE_HEADERS_NAMES? ? ? ? ? ? ? ? Response?headers’?names?(read-only?collection)?
RESPONSE_PROTOCOL? ? ? ? ? ? ? ? ? ? ? ? ? ?Response?protocol
RESPONSE_STATUS? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Response status?code
11.Miscellaneous variables
Variable? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Description
HIGHEST_SEVERITY? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Highest severity?encountered
MATCHED_VAR? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Contents?of?the?last?variable?that?matched
MATCHED_VAR_NAME? ? ? ? ? ? ? ? ? ? ? ? Name?of?the?last?variable?that?match
MODSEC_BUILD? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?ModSecurity?build?version?(e.g.,?02050102)
SESSIONID? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Session?ID?associated?with?current?transaction
USERID? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? User?ID?associated?with?current?transaction
WEBAPPID? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Web?application?ID?associated?with?current?transaction
WEBSERVER_ERROR_LOG? ? ? ? ? ? ? ? ? ? ? Error?messages?generated?by?Apache?during?current?transaction
12.Request body parsing variables
Variable? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Description
MULTIPART_BOUNDARY_QUOTED? ? ? ? ? ? ? ? ? ? ? Multipart parsing error: quoted boundary encountered
MULTIPART_BOUNDARY_WHITESPACE? ? ? ? ? ? ? ?Multipart parsing error: whitespace in boundary
MULTIPART_CRLF_LF_LINES? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Multipart parsing error: mixed line endings used?
MULTIPART_DATA_BEFORE? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Multipart?parsing?error:?seen?data?before?first?boundary?
MULTIPART_DATA_AFTER? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Multipart parsing error: seen data after last boundary?
MULTIPART_HEADER_FOLDING? ? ? ? ? ? ? ? ? ? ? ? ? ? Multipart parsing error: header folding used?
MULTIPART_LF_LINE? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Multipart parsing error: LF line ending detected?
MULTIPART_SEMICOLON_MISSING? ? ? ? ? ? ? ? ? ? ? Multipart?parsing?error:?missing?semicolon?before?boundary
MULTIPART_STRICT_ERROR? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?At least one multipart error except?
MULTIPART_UNMATCHED_BOUNDARY? ? ? ? ? ? ? ? occurred
MULTIPART_UNMATCHED_BOUNDARY? ? ? ? ? ? ? ? Multipart parsing error: unmatched boundary detected (prone to?
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? false positives)
REQBODY_PROCESSOR? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Request?processor?that?handled?request?body
REQBODY_PROCESSOR_ERROR? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Request?processor?error?flag?(0?or?1)?
REQBODY_PROCESSOR_ERROR_MSG? ? ? ? ? ? ? ? ? ? Request?processor
13.Special collections
Variable? ? ? ? ? ? ? ? ? ? ? Description
ENV? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Environment?variables?(read-only?collection,?although?it’s?possible?to?use?set- var?to?change?it)
GEO? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Geo lookup information from the last @geoLookup?invocation (read-only collec- tion)
GLOBAL? ? ? ? ? ? ? ? ? ? ? ?Global?information,?shared?by?all?processes?(read/write?collection)
IP? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? IP?address?data?storage?(read/write?collection)
TX? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Transient?transaction?data?(read/write?collection)
RULE? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Current rule metadata (read-only ?collection)
SESSION? ? ? ? ? ? ? ? ? ? ? ? Session?data?storage?(read/write?collection)
USER? ? ? ? ? ? ? ? ? ? ? ? ? ? ? User?data?storage?(read/write?collection)
XML? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? XML?DOM?tree?(read-only?collection)
14.Time variables
Variable? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Description
TIME? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Time?(HH:MM:SS)
TIME_DAY? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Day?of?the?month?(1-31)
TIME_EPOCH? ? ? ? ? ? ? ? ? ? ? ? ?Seconds?since?January?1,?1970?(e.g.,?1251029017)
TIME_HOUR? ? ? ? ? ? ? ? ? ? ? ? ? ?Hour?of?the?day?(0-23)
TIME_MIN? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Minute?of?the?hour?(0-59)
TIME_MON? ? ? ? ? ? ? ? ? ? ? ? ? ? Month?of?the?year?(0-11)
TIME_SEC? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Second?of?the?minute?(0-59)
TIME_WDAY? ? ? ? ? ? ? ? ? ? ? ? ? ?Week day?(0-6)
TIME_YEAR? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Year
15.String matching operators
| Operator | Description |
| @beginsWith | Begins with |
| @contains | Contains |
| @endsWith | Ends with |
| @rx | Regular pattern match |
| @pm | Parallel matching |
| @pmFromFile(@pmf in v2.6) | Parallel matching,with arguments from a file |
| @streq | String equal to |
| @Within | Within |
16.Numerical operators
| Operator | Description |
| @eq | Equal |
| @ge | Greater or equal |
| @gt | Greater than |
| @le | Less or equal |
| @lt | Less than |
17.Validation operators驗證運算符
Operator? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Description
@validateByteRange? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Validates?that?parameter?consists?only?of?allowed?byte?values
@validateDTD? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Validates?XML?payload?against?a?DTD
@validateSchema? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Validates?XML?payload?against?a?Schema
@validateUrlEncoding? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Validates?an?URL-encoded?string
@validateUtf8Encoding? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Validates?an?UTF-8?encoded?string
18.miscellaneous operators
Operator? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Description
@geoLookup? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Determines?the?physical?location?of?an?IP?address
@inspectFile? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Invokes?an?external?script?to?inspect?a?file
@rbl? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Looks?parameter?against?a?RBL?(real-time?block?list)
@verifyCC? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Checks?if?the?parameter?is?a?valid?credit?card?number
19.Disruptive actions
Action? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Description
allow? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Stop?processing?of?one?or?more?remaining?phases
block? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Indicates?that?a?rule?wants?to?block
deny? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Block?transaction?with?an?error?page
drop? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Close network?connection
pass? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Do?not?block,?go?to?the?next?rule
proxy? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Proxy?request?to?a?backend?web?server
redirect? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Redirect?request?to?some?other?web?server
20.Flow actions
Action? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Description
chain? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 將兩個或多個規則連接到單個邏輯規則中。
skip? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 跳過下面的一個或多個規則
skipAfter? ? ? ? ? ? ? ? ? ? ? ? ? ? 跳到具有提供ID的規則或標記
21.Metadata actions
| Action | Description |
| id | 為規則分配唯一ID |
| phase | 運行規則的階段 |
| msg | 消息串 |
| rev | 版次 |
| severity | 嚴重 |
| tag | 標簽 |
22.Variable actions
| Action | Description |
| capture | 將結果捕獲到一個或多個變量中 |
| deprecatevar | 隨著時間的推移減少數值變量值 |
| expirevar | 在一個時間段后刪除變量 |
| initcol | 創建一個新的持久集合 |
| setenv | 設置或刪除環境變量 |
| setvar | 設置、刪除、增加或減少變量 |
| setuid | 將當前事務與應用程序用戶ID(用戶名)關聯 |
| setsid | 將當前事務與應用程序會話ID關聯 |
23.Logging actions
| Action | Description |
| auditlog | 將當前事務記錄到審計日志 |
| log | Log?error?message;?implies?auditlog |
| logdata | 日志提供的數據作為錯誤消息的一部分 |
| noauditlog | 不要將當前事務記錄到審核日志 |
| nolog | Do?not?log?error?message;?implies?noauditlog |
| sanitiseArg | 從審計日志中刪除請求參數 |
| sanitiseMatched | 刪除審計日志中發生匹配的參數 |
| sanitiseRequestHeader | 從審計日志中刪除請求標頭 |
| sanifiseResponseHeader | 從審計日志中刪除響應頭 |
24.Special actions
| Action | Description |
| ctl | 更改當前事務的配置 |
| multiMatch | 激活多匹配,其中操作符在每次轉換后運行 |
| t | 指定轉換函數,以便在匹配前應用于變量。 |
25.Miscellaneous actions
| Action | Description |
| append | 將內容追加到響應正文 |
| exec | 執行外部腳本 |
| pause | 暫停事務 |
| prepend | 對響應體的準備內容 |
| status | 指定響應狀態碼使用deny和redirect |
| xmlns | 指定用于XPath表達式的名稱空間 |
總結
以上是生活随笔為你收集整理的学习ModSecrity Handbook之摘录的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 学习《apache源代码全景分析》之摘录
- 下一篇: 学习quot;平衡二叉树quot;之摘录