10.31. SIP 关键词¶
SIP 关键词以粘性缓冲区(sticky buffers)形式实现,可用于匹配 SIP 消息中的字段。
如 RFC3261 所述,通用头部字段名称可能以缩写形式表示。此类情况下,头部名称会被标准化为常规形式以便通过对应的粘性缓冲区进行匹配。
10.31.1. sip.method¶
该关键词匹配 SIP 请求中的方法字段。
10.31.1.1. 语法¶
sip.method; content:<method>;
典型方法示例:
INVITE
BYE
REGISTER
CANCEL
ACK
OPTIONS
10.31.1.2. 示例¶
sip.method; content:"INVITE";
10.31.2. sip.uri¶
该关键词匹配 SIP 请求中的 URI 字段。
10.31.2.1. 语法¶
sip.uri; content:<uri>;
其中 <uri> 为符合 SIP URI 架构的地址。
10.31.2.2. 示例¶
sip.uri; content:"sip:sip.url.org";
10.31.3. sip.request_line¶
该关键词强制检查完整的 SIP 请求行。
10.31.3.1. 语法¶
sip.request_line; content:<request_line>;
其中 <request_line> 可为部分或完整请求行。
10.31.3.2. 示例¶
sip.request_line; content:"REGISTER sip:sip.url.org SIP/2.0"
10.31.4. sip.stat_code¶
该关键词匹配 SIP 响应中的状态码。
10.31.4.1. 语法¶
sip.stat_code; content:<stat_code>
其中 <status_code> 属于以下任一类状态码组:
1xx - 临时响应
2xx - 成功响应
3xx - 重定向响应
4xx - 客户端错误响应
5xx - 服务器错误响应
6xx - 全局错误响应
10.31.4.2. 示例¶
sip.stat_code; content:"100";
10.31.5. sip.stat_msg¶
该关键词匹配 SIP 响应中的状态消息。
10.31.5.1. 语法¶
sip.stat_msg; content:<stat_msg>
其中 <stat_msg> 为状态码关联的原因短语。
10.31.5.2. 示例¶
sip.stat_msg; content:"Trying";
10.31.6. sip.response_line¶
该关键词强制检查完整的 SIP 响应行。
10.31.6.1. 语法¶
sip.response_line; content:<response_line>;
其中 <response_line> 可为部分或完整响应行。
10.31.6.2. 示例¶
sip.response_line; content:"SIP/2.0 100 OK"
10.31.7. sip.protocol¶
该关键词匹配 SIP 请求或响应行中的协议字段。
若响应行为 'SIP/2.0 100 OK',则该缓冲区将包含 'SIP/2.0'
10.31.7.1. 语法¶
sip.protocol; content:<protocol>
其中 <protocol> 为 SIP 协议版本。
10.31.7.2. 示例¶
sip.protocol; content:"SIP/2.0"
10.31.8. sip.from¶
该关键词匹配 SIP 头部中可能存在的 From 字段。 同时匹配常规形式和缩写形式,但无法区分二者。
10.31.8.1. 语法¶
sip.from; content:<from>
其中 <from> 为 From 头部的值。
10.31.8.2. 示例¶
sip.from; content:"user"
10.31.9. sip.to¶
该关键词匹配 SIP 头部中可能存在的 To 字段。 同时匹配常规形式和缩写形式,但无法区分二者。
10.31.9.1. 语法¶
sip.to; content:<to>
其中 <to> 为 To 头部的值。
10.31.9.2. 示例¶
sip.to; content:"user"
10.31.10. sip.via¶
该关键词匹配 SIP 头部中可能存在的 Via 字段。 同时匹配常规形式和缩写形式,但无法区分二者。
10.31.10.1. 语法¶
sip.via; content:<via>
其中 <via> 为 Via 头部的值。
10.31.10.2. 示例¶
sip.via; content:"SIP/2.0/UDP"
10.31.11. sip.user_agent¶
该关键词匹配 SIP 头部中可能存在的 User-Agent 字段。
10.31.11.1. 语法¶
sip.user_agent; content:<user_agent>
其中 <user_agent> 为 User-Agent 头部的值。
10.31.11.2. 示例¶
sip.user_agent; content:"Asterisk"
10.31.12. sip.content_type¶
该关键词匹配 SIP 头部中可能存在的 Content-Type 字段。 同时匹配常规形式和缩写形式,但无法区分二者。
10.31.12.1. 语法¶
sip.content_type; content:<content_type>
其中 <content_type> 为 Content-Type 头部的值。
10.31.12.2. 示例¶
sip.content_type; content:"application/sdp"
10.31.13. sip.content_length¶
该关键词匹配 SIP 头部中可能存在的 Content-Length 字段。 同时匹配常规形式和缩写形式,但无法区分二者。
10.31.13.1. 语法¶
sip.content_length; content:<content_length>
其中 <content_length> 为 Content-Length 头部的值。
10.31.13.2. 示例¶
sip.content_length; content:"200"