Hi Dan,
The comparative tests are this rule in Snort 2.9.16:
alert tcp any any -> $HOME_NET $HTTP_PORTS (msg:"/etc/passwd test
detected"; flow:to_server,established; content:"/etc/passwd";
fast_pattern:only; http_uri; gid:1; sid:1001;)
Which produces this log:
10/20-20:43:32.334621 [**] [1:1001:0] /etc/passwd test detected [**]
[Priority: 0] {TCP} 10.1.4.2:59240 -> 10.1.7.2:80
Versus this rule:
drop tcp any any -> $HOME_NET $HTTP_PORTS (msg:"cmd.exe test detected";
flow:to_server,established; content:"cmd.exe"; fast_pattern:only; http_uri;
gid:1; sid:1002;)
Which produces this log:
10/20-20:43:39.741995 [Drop] [**] [1:1002:0] cmd.exe test detected [**]
[Priority: 0] {TCP} 10.1.4.2:59244 -> 10.1.7.2:80
Note: There are 2 spaces between the end of the timestamp and the first [
that will be consolidated to one in this email message, but both are needed
to test.
After thinking about it a bit, removing the child relationship between
snort and snort2 could cause all sorts of unanticipated problems for people
who rely on this parent / child logic (perhaps even doing workarounds for
this very issue), so I think adding a test to the the prematch_pcre2 logic
in the second “snort” decoder (the one that’s not program_name_pcre2 based)
will allow the Drop events to be picked up and funneled down the same path
as the Alert events are now, catching those erroneously missed log lines,
but not messing up anything else.
So, I’m proposing changing this decoder:
ids
^\[\*\*\] \[\d+:\d+:\d+\]
To this:
ids
^\[\*\*\] \[\d+:\d+:\d+\] |^\[Drop\] \[\*\*\]
\[\d+:\d+:\d+\]
Doing this now makes both drop and alert events appear under the same
decoder.
I’ll post an issue in github hoping someone picks it up to make the change
as I’m not familiar with the use of git itself and I presently don’t know
how to do a pull request. :)
Thanks,
Scott
P.S. Of course, all of this will change with Snort 3, but one thing at a
time, I suppose. :)
On Tuesday, October 20, 2020 at 2:24:03 PM UTC-4 dan (ddpbsd) wrote:
> Hi Scott,
>
> On Sat, Oct 17, 2020 at 6:47 PM saw...@gmail.com wrote:
> >
> > In testing snort 2.9 inline operation logs against OSSEC (3.6.0), I have
> found something weird.
> >
> >
> > This “alert” event gets caught by the decoder:
> >
> >
> > 10/17-21:23:32.374062 [**] [1:1002:0] /etc/passwd test detected [**]
> [Priority: 0] {TCP} 10.1.4.2:59240 -> 10.1.7.2:80
> >
> >
> > **Phase 1: Completed pre-decoding.
> >
> > full event: '10/17-21:23:32.374062 [**] [1:1002:0] /etc/passwd test
> detected [**] [Priority: 0] {TCP} 10.1.4.2:59240 -> 10.1.7.2:80'
> >
> > hostname: 'ossec'
> >
> > program_name: '(null)'
> >
> > log: '[**] [1:1002:0] /etc/passwd test detected [**] [Priority: 0]
> {TCP} 10.1.4.2:59240 -> 10.1.7.2:80'
> >
> >
> > **Phase 2: Completed decoding.
> >
> > decoder: 'snort'
> >
> > id: '1:1002:0'
> >
> > srcip: '10.1.4.2'
> >
> > dstip: '10.1.7.2'
> >
> >
> > **Phase 3: Completed filtering (rules).
> >
> > Rule id: '20101'
> >
> > Level: '6'
> >
> > Description: 'IDS event.'
> >
> > **Alert to be generated.
> >
> >
> >
> > This “drop” event, however, does not.
> >
> >
> > 10/17-21:24:32.944406 [Drop] [**] [1:1002:0] cmd.exe test detected
> [**] [Priority: 0] {TCP} 10.1.4.2:59244 -> 10.1.7.2:80
> >
> >
> >
> > **Phase 1: Completed pre-decoding.
> >
> > full event: '10/17-21:24:32.944406 [Drop] [**] [1:1002:0] cmd.exe
> test detected [**] [Priority: 0] {TCP} 10.1.4.2:59244 -> 10.1.7.2:80'
> >
> > hostname: 'ossec'
> >
> > program_name: '(null)'
> >
> > log: '[Drop] [**] [1:1002:0] cmd.exe test detected [**] [Priority:
> 0] {TCP} 10.1.4.2:59244 -> 10.1.7.2:80'
> >
> >
> > **Phase 2: Completed decoding.
> >
> > No decoder matched.
> >
> >
> > For your reference here are the Snort decoder lines from
> /var/ossec/etc/decoder.xml:
> >
> >
> >
> >
> > ^snort
> >
> >
> >
> >
> >
> >
> > ids
> >
> > ^\[\*\*\] \[\d+:\d+:\d+\]
> >
> >
> >
> >
> >
> >
> > snort
> >
> > ids
> >
> > ^\[\*\*\] \[|^\[Drop\] \[\*\*\] \[|^\[
> >
> > (\d+:\d+:\d+)\] .+ (\S+?):?\d* ->
> ([^:]+)
> >
> > id,srcip,dstip
> >
> > name,id,srcip,dstip
> >
> >
> >
> >
> > So what’s happening is that the alert event that starts with the
> timestamp then [**] [#::#] matches the second “snort” decoder and
> then gets further tested against the “snort2” decoder.
> >
> >
> > However, the drop event that starts with the timestamp then [Drop] [**]
> [#:###:#] only matches the “snort2” decoder. This decoder catches
> strings that start with [**] OR [Drop] [**] OR [ and then sorts out the ID
> and IP info after the prematch. The problem is that since “snort2” declares
> “snort” as it’s parent, and the “snort” decoder only catches events which
> starts with [**] [#::#] only alert events make it to “snort2” for
> further decoding.
> >
> >
> > I have 3 proposed solutions:
> >
> >
> > 1) Remove the “snort” parent requirement