[Snort-users] How to match the nth packet of a connection?

JJ Cummings cummingsj at ...11827...
Mon Jun 23 14:34:51 EDT 2008

please read README.flowbits ... as noted below in snort.foo/doc grepz

$ wget http://snort.org/dl/current/snort-   
        --2008-06-23 14:27:58--  

$ tar xvfz snort-
    x snort-
$ cd snort-
$ grep flowbits *
README.flowbits:The flowbits detection plugin uses the flow preprocessor 
to track rule state
README.flowbits:The general configuration of the flowbits rule option is:
README.flowbits:    flowbits:<keyword>[,<STATE_NAME>];
README.flowbits:There are seven keywords associated with flowbits, most 
of the options need a
README.flowbits:Usage:  flowbits:set,FOO;
README.flowbits:Usage:  flowbits:unset,FOO;
README.flowbits:Usage:  flowbits:toggle,FOO;
README.flowbits:Usage:  flowbits:isset,FOO;
README.flowbits:Usage:  flowbits:isnotset,FOO;
README.flowbits:Usage:  flowbits:noalert;
README.flowbits:Usage:  flowbits:reset;
README.flowbits:alert tcp any 143 -> any any (msg:"IMAP login"; 
content:"OK LOGIN"; flowbits:set,logged_in;)
README.flowbits:alert tcp any any -> any 143 (msg:"IMAP lsub"; 
content:"LSUB"; flowbits:isset,logged_in;)
README.flowbits:alert tcp any any -> any 143 (msg:"IMAP LIST WITHOUT 
LOGIN"; content:"LIST"; flowbits:isnotset,logged_in;)
README.stream5:TCP and UDP.  With Stream5, the rule 'flow' and 
'flowbits' keywords
README.stream5:                              port.  Rules that have flow 
or flowbits will
README.stream5:ports includes either flow or flowbits, the 
ignore_any_rules option is
README.stream5:effectively pointless.  Because of the potential impact 
of disabling a flowbits
Binary file snort_manual.pdf matches
snort_manual.tex:\texttt{flowbits\_size} & \texttt{config 
flowbits\_size: 128} & Specifies the maximum number of flowbit tags that 
can be used within a rule set.\\
snort_manual.tex:TCP and UDP.  With Stream5, the rule 'flow' and 
'flowbits' keywords
snort_manual.tex:\texttt{ignore\_any\_rules} & Don't process any 
\texttt{->} any (ports) rules for UDP that attempt to match payload if 
there are no port specific rules for the src or destination port.  Rules 
that have flow or flowbits will never be ignored.  This is a performance 
improvement and may result in missed attacks.  Using this does not 
affect rules that look at protocol headers, only those with content, 
PCRE, or byte test options.  The default is "off".\\
snort_manual.tex:ports includes either flow or flowbits, the 
ignore\_any\_rules option is
snort_manual.tex:effectively pointless.  Because of the potential impact 
of disabling a flowbits
snort_manual.tex:of tagging (\ref{tag section}) and flowbits 
snort_manual.tex:The \texttt{flowbits} keyword is used in conjunction 
with conversation
snort_manual.tex:rules to track states across transport protocol 
sessions.  The flowbits option
snort_manual.tex:There are seven keywords associated with flowbits. Most 
of the options need a
snort_manual.tex:  content:"OK LOGIN"; flowbits:set,logged_in;
snort_manual.tex:  flowbits:noalert;)
snort_manual.tex:  flowbits:isset,logged_in;)
snort_manual.tex:\caption{Flowbits Usage Examples\label{flowbits usage 
snort_manual.tex:\texttt{flowbits} & The flowbits keyword allows rules 
to track states across
snort_manual.tex:However, since the rule will fire on every packet 
involving, no packets will get tagged.  The \emph{flowbits} 
option would be useful here.
snort_manual.tex:alert tcp any any <> any 
snort_manual.tex:    flowbits:set,tagged; tag:host,600,seconds,src;)
snort_manual.tex:a means to register and check flowbits.  It also 
includes a location
snort_manual.tex:The {\em FlowBitsInfo} structure defines a flowbits 
option.  It
snort_manual.tex:and register flowbits.
snort_manual.tex:\item {\em int processFlowbits(void *p, FlowBitsInfo 
snort_manual.tex:This function evaluates the flowbits for a given 
packet, as specified
snort_manual.tex:by FlowBitsInfo.  It will interact with flowbits used 
by text-based
snort_manual.tex:set up fast pattern-matcher content, register flowbits, 
snort_manual.tex:    0,                      /* Holder, no alert, used 
internally for flowbits */
snort_manual.tex:each Rule in the list and initializes the content, 
flowbits, pcre, etc.

Konstantinos Agouros wrote:
> Hi,
> is there a simple way to match a pattern in say the 3rd packet of a
> connection. seq and ack can not be used since they are absolute, and I
> didn't get it from the documentation of stream5. Any hints welcome.
> Regards,
> Konstantin

More information about the Snort-users mailing list