[Snort-users] Regarding pattern matching

Paul Schmehl pauls at ...6838...
Mon Nov 5 12:40:17 EST 2007

--On Monday, November 05, 2007 18:30:23 +0100 Govind <govind at ...14232...> 

> Greetings all,
> I am a newbie to snort and to this forum so apologies in advance if this
> strikes as a basic question.
> I am currently studying the caching behaviour of the snort pattern
> matcher as part of my thesis, in particular iam studying the caching
> behaviour of the Aho-Corasick search Automaton. In the snort code i can
> see that in case of a partial match, say case when there are multiple
> "contents" the entire rules that partially match the given content are
> printed out. But for commonly occuring patterns , like "|00|", there are
> about 5000 partial matches. Does the snort system traverse the entire
> linked list.  Is there a need to traverse through this entire list or a
> "union" of the different sub-pattern matches would suffice?.  This is of
> interest to me as it does impact the caching behaviour of the system.
> Further, I also notice that some pcre rules contain "content" in
> addition to the same content in the pcre regexp.
> For example the following rule from backdoor.rules contains "NetBus" in
> Content and in the pcre as well.
> alert tcp $HOME_NET 1024: -> $EXTERNAL_NET any (msg:"BACKDOOR netbus
> active"; flow:from_server,established; content:"NetBus"; depth:6;
> nocase; pcre:"/^NetBus\s+\d+\x2E\d+/smi";
> reference:url,www.2-spyware.com/file-backdoor-netbus-12-exe.html;
> classtype:trojan-activity; sid:109; rev:6;)
> So does this mean that both the regexp pattern matching and Aho Corasick
> matching would be done with these rules.
No, what it means is that, unless the regex rule matches, the Aho Corasick 
matching will never be done.  Since the latter is more "expensive", you 
only want to do it when you have a potential match, as confirmed by the 
former having affirmatively matched content in the packet.

Paul Schmehl (pauls at ...6838...)
Senior Information Security Analyst
The University of Texas at Dallas

More information about the Snort-users mailing list