Snort配置:跨TCP数据包的PCRE匹配

时间:2018-07-25 19:08:28

标签: regex tcp stream snort intrusion-detection

我正在使用我的Security Onion,现在所有较长的PCRE都无法正常工作,因为规则和正则表达式不适用于TCP流,而仅适用于单个数据包。

我的Snort.conf应该启用了所有功能:

    # Target-based IP defragmentation.  For more inforation, see README.frag3
preprocessor frag3_global: max_frags 65536
preprocessor frag3_engine: policy windows detect_anomalies overlap_limit 10 min_fragment_length 100 timeout 180

# Target-Based stateful inspection/stream reassembly.  For more inforation, see README.stream5
preprocessor stream5_global: track_tcp yes, \
   track_udp yes, \
   track_icmp no, \
   max_tcp 262144, \
   max_udp 131072, \
   max_active_responses 2, \
   min_response_seconds 5
preprocessor stream5_tcp: log_asymmetric_traffic no, policy windows, \
   detect_anomalies, require_3whs 180, \
   overlap_limit 10, small_segments 3 bytes 150, timeout 180, \
    ports client 21 22 23 25 42 53 79 109 110 111 113 119 135 136 137 139 143 \
        161 445 513 514 587 593 691 1433 1521 1741 2100 3306 6070 6665 6666 6667 6668 6669 \
        7000 8181 32770 32771 32772 32773 32774 32775 32776 32777 32778 32779, \
    ports both 80 81 311 383 443 465 563 591 593 636 901 989 992 993 994 995 1220 1414 1830 2301 2381 2809 3037 3128 3702 4343 4848 5250 6988 7907 7000 7001 7144 7145 7510 7802 7777 7779 \
        7801 7900 7901 7902 7903 7904 7905 7906 7908 7909 7910 7911 7912 7913 7914 7915 7916 \
        7917 7918 7919 7920 8000 8008 8014 8028 8080 8085 8088 8090 8118 8123 8180 8243 8280 8300 8800 8888 8899 9000 9060 9080 9090 9091 9443 9999 11371 34443 34444 41080 50002 55555
preprocessor stream5_udp: timeout 180

现在,我用一个简单的XML文件建立了一个node.js服务器(我将它缩短了一点):

<?xml version="1.0" encoding="UTF-8"?>
<saml2p:Response Destination="http://localhost:8080/sp/saml/index.html"
  ID="_28940080d39ea1191d9910414147f372"
  InResponseTo="_15b217492a05e534df8539c7a84014cd"
  IssueInstant="2018-07-24T16:04:13.830Z" Version="2.0"
  xmlns:saml2p="urn:oasis:names:tc:SAML:2.0:protocol"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:oasis:names:tc:SAML:2.0:protocol">
  <saml2:Issuer xmlns:saml2="urn:oasis:names:tc:SAML:2.0:assertion">eLearning SAML SSO IdP</saml2:Issuer>
  <saml2p:Status>
    <saml2p:StatusCode Value="urn:oasis:names:tc:SAML:2.0:status:Success"/>
  </saml2p:Status>
  <saml2:Assertion ID="_evil_assertion_ID"
    IssueInstant="2018-07-24T16:04:13.831Z" Version="2.0"
    xmlns:saml2="urn:oasis:names:tc:SAML:2.0:assertion"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:oasis:names:tc:SAML:2.0:protocol">
    <saml2:Issuer>eLearning SAML SSO IdP</saml2:Issuer>
    <saml2:Subject>
      <saml2:NameID Format="urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress">xmluser</saml2:NameID>
    [..........................]
      </saml2:AuthnContext>
    </saml2:AuthnStatement>
  </saml2:Assertion>
</saml2p:Response>

仅匹配内容:“ saml2p:response”或诸如pcre:“ / saml2p:Response / smi”之类的小型正则表达式的规则没有问题,但是具有较长正则表达式的规则与模式不匹配。

我使规则尽可能通用:

警告tcp any any-> any any(msg:“ ET WEB_SERVER SAML XSW3攻击,可能的签名包装攻击v15”; pcre:“ / saml2p:Response。*?/ saml2p:Response / smi”;引用:url, https://www.usenix.org/system/files/conference/usenixsecurity12/sec12-final91.pdf; classtype:web-application-attack; sid:200000120; rev:1;)

edit:我还在所有版本的flow:from_server中建立了这个规则。 (to_server,from_client,to_client)。他们都没有为我工作。但是,当我将xml缩小到适合一个数据包的大小时,所有规则都将触发!

Regex pcre:“ / saml2p:Response。*?/ saml2p:Response / smi”应该匹配从第一个响应标签到结束响应标签的所有内容,但是无论何时将其拆分为不同的TCP数据包,regex都不匹配。

我想念什么吗?

感谢您的帮助!

0 个答案:

没有答案