[Snort-sigs] Snort Config: PCRE Matching across TCP Packets

Joel Esler (jesler) jesler at cisco.com
Wed Jul 25 19:13:16 EDT 2018


If you are doing a static content match, like you are, just use content.  In this case make two contents that are relative to each other by using “distance:0;” on your second content match.

Sent from my iPhone

On Jul 25, 2018, at 18:31, Michael Hensel via Snort-sigs <snort-sigs at lists.snort.org<mailto:snort-sigs at lists.snort.org>> wrote:

Hello everyone!

I am working at the moment with my Security Onion and have some problems with rules, especially with my PRCE triggering across more than one tcp packet.

In my opinion all necessery precprocessors are running in my 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

Now I got a node.js server up with a simple XML file (I made it a little bit shorter):


<?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>

A rule matching only the content:"saml2p:response" or a small regex like pcre:"/saml2p:Response/smi" is working without problem, but a rule with a longer regex is not matching the pattern.

I made my rule as generic as possible:

alert tcp any any -> any any (msg:"ET WEB_SERVER SAML XSW3 Attack, Possible Signature Wrapping Attack v15"; pcre:"/saml2p:Response.*?/saml2p:Response/smi"; reference:url,https://www.usenix.org/system/files/conference/usenixsecurity12/sec12-final91.pdf; classtype:web-application-attack; sid:200000120; rev:1;)

edit: I have also tried this rule with all versions of flow:from_server,established; (to_server, from_client, to_client). None of them is working for me, but when I cut down the xml to a size which fits in one packet, all rules are firing!

The Regex pcre:"/saml2p:Response.*?/saml2p:Response/smi" should match everything from the first response tag to the closing response tag, but whenever it is splitted into different TCP Packets the regex is not matching.

Do i miss anything?

My post from Stackoverflow:

https://stackoverflow.com/questions/51526061/snort-config-pcre-matching-across-tcp-packets

Thanks for your help!

_______________________________________________
Snort-sigs mailing list
Snort-sigs at lists.snort.org<mailto:Snort-sigs at lists.snort.org>
https://lists.snort.org/mailman/listinfo/snort-sigs

Please visit http://blog.snort.org for the latest news about Snort!

Please follow these rules: https://snort.org/faq/what-is-the-mailing-list-etiquette

Visit the Snort.org<http://Snort.org> to subscribe to the official Snort ruleset, make sure to stay up to date to catch the most <a href=" https://snort.org/downloads/#rule-downloads">emerging threats</a>!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.snort.org/pipermail/snort-sigs/attachments/20180725/02a6a31e/attachment-0001.html>


More information about the Snort-sigs mailing list