[prev in list] [next in list] [prev in thread] [next in thread] 

List:       ossec-list
Subject:    Re: [ossec-list] custom decoder & rules for nas device
From:       mjwoods69 via ossec-list <ossec-list () googlegroups ! com>
Date:       2018-07-27 19:57:53
Message-ID: a6e251a0-e061-4b67-b630-bf5a37b346af () googlegroups ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


Hi Dan

Thanks for the info, been working on this for the last few days and 
unfortunately I tried this approach and could not get it to work. In the 
end installed syslog-ng & picked up the info locally from a file/imported 
into ossec just like any other log file . This worked like a dream and 
getting all the alerts/emails now :) Once again thanks for replying and for 
anyone else trying this syslog-ng might be your friend ... 

On Friday, July 27, 2018 at 3:39:01 PM UTC+1, dan (ddpbsd) wrote:
> 
> On Wed, Jul 25, 2018 at 2:42 PM, mjwoods69 via ossec-list 
> <ossec...@googlegroups.com <javascript:>> wrote: 
> > Hi 
> > 
> > Trying to get alerting implemented on my nas. Unfortunately my work to 
> date 
> > has failed, in summary I have: 
> > 
> > 1. Identified the log message in /var/ossec/logs/archives/archives.log, 
> this 
> > is sent from nas to ossec via syslog -> 
> > 
> > 2018 Jul 25 17:55:58 nas->10.0.0.3 Jul 25 18:48:23 nas qlogd[8736]: conn 
> > log: Users: admin, Source IP: 10.0.0.54, Computer name: ---, Connection 
> > type: , Accessed resources: Administration, Action: Login OK 
> > 
> 
> archives.log has a meta data header attached: `2018 Jul 25 17:55:58 
> nas->10.0.0.3 ` 
> Remove this header for the actual log: `Jul 25 14:37:23 nas 
> qlogd[8736]: conn log: Users: admin, Source IP: 10.0.0.54, Computer 
> name: ---, Connection type: , Accessed resources: Administration, 
> Action: Login OK` 
> 
> Using the non-meta-data-encumbered log message with a modified decoder 
> gives the following output: 
> 
> ossec-testrule: Type one log per line. 
> 
> Jul 25 14:37:23 nas qlogd[8736]: conn log: Users: admin, Source IP: 
> 10.0.0.54, Computer name: ---, Connection type: , Accessed resources: 
> Administration, Action: Login OK 
> 
> 
> **Phase 1: Completed pre-decoding. 
> full event: 'Jul 25 14:37:23 nas qlogd[8736]: conn log: Users: 
> admin, Source IP: 10.0.0.54, Computer name: ---, Connection type: , 
> Accessed resources: Administration, Action: Login OK' 
> hostname: 'nas' 
> program_name: 'qlogd' 
> log: 'conn log: Users: admin, Source IP: 10.0.0.54, Computer 
> name: ---, Connection type: , Accessed resources: Administration, 
> Action: Login OK' 
> 
> **Phase 2: Completed decoding. 
> decoder: 'qlogd' 
> dstuser: 'admin' 
> srcip: '10.0.0.54' 
> action: 'Login' 
> 
> **Phase 3: Completed filtering (rules). 
> Rule id: '100004' 
> Level: '12' 
> Description: 'nas user logged in' 
> **Alert to be generated. 
> 
> 
> Modified decoder: 
> 
> <decoder name="qlogd"> 
> <program_name>^qlogd</program_name> 
> <regex>\.+ Users: (\S+), Source IP: (\d+.\d+.\d+.\d+), \.+ Action: 
> (\S+)</regex> 
> <order>user, srcip, action</order> 
> </decoder> 
> 
> Next, I restart the ossec processes on the manager, and use `logger` 
> to test the log: 
> `echo 'conn log: Users: admin, Source IP: 10.0.0.54, Computer name: 
> ---, Connection type: , Accessed resources: Administration, Action: 
> Login OK' | logger -t qlogd` 
> I get the following in `/var/log/messages`: 
> Jul 27 10:36:40 rossak qlogd: conn log: Users: admin, Source IP: 
> 10.0.0.54, Computer name: ---, Connection type: , Accessed resources: 
> Administration, Action: Login OK 
> 
> And the following in `/var/ossec/logs/alerts/alerts.log`: 
> ** Alert 1532702200.100802: mail  - syslog,qlogd, 
> 2018 Jul 27 10:36:40 rossak->/var/log/messages 
> Rule: 100004 (level 12) -> 'nas user logged in' 
> Src IP: 10.0.0.54 
> User: admin 
> Jul 27 10:36:40 rossak qlogd: conn log: Users: admin, Source IP: 
> 10.0.0.54, Computer name: ---, Connection type: , Accessed resources: 
> Administration, Action: Login OK' 
> 
> 
> 
> > 2. Constructed a decoder at /var/ossec/etc/local_decoder.xml -> 
> > 
> > <decoder name="qlogd"> 
> > <prematch>\S+ qlogd</prematch> 
> > <regex offset="after_prematch">\.+ Users: (\S+), Source IP: 
> > (\d+.\d+.\d+.\d+), \.+ Action: (\S+)</regex> 
> > <order>user, srcip, action</order> 
> > </decoder> 
> > 
> > 3. Constructed a number of rules at /var/ossec/rules/local_rules.xml -> 
> > 
> > <group name="syslog,qlogd,"> 
> > <rule id="100002" level="0"> 
> > <decoded_as>qlogd</decoded_as> 
> > <description>qlogd messages to analyze</description> 
> > </rule> 
> > <rule id="100003" level="12"> 
> > <if_sid>100002</if_sid> 
> > <action>Logout</action> 
> > <description>nas user logged out</description> 
> > </rule> 
> > <rule id="100004" level="12"> 
> > <if_sid>100002</if_sid> 
> > <action>Login</action> 
> > <description>nas user logged in</description> 
> > </rule> 
> > </group> 
> > 
> > 4. Confirmed grammer via /var/ossec/bin/ossec-logtest -> 
> > 
> > **Phase 1: Completed pre-decoding. 
> > full event: '2018 Jul 25 13:44:58 nas->10.0.0.3 Jul 25 14:37:23 
> nas 
> > qlogd[8736]: conn log: Users: admin, Source IP: 10.0.0.54, Computer 
> name: 
> > ---, Connection type: , Accessed resources: Administration, Action: 
> Login 
> > OK' 
> > hostname: 'pi' 
> > program_name: '(null)' 
> > log: '2018 Jul 25 13:44:58 nas->10.0.0.3 Jul 25 14:37:23 nas 
> > qlogd[8736]: conn log: Users: admin, Source IP: 10.0.0.54, Computer 
> name: 
> > ---, Connection type: , Accessed resources: Administration, Action: 
> Login 
> > OK' 
> > 
> > **Phase 2: Completed decoding. 
> > decoder: 'qlogd' 
> > dstuser: 'admin' 
> > srcip: '10.0.0.54' 
> > action: 'Login' 
> > 
> > **Phase 3: Completed filtering (rules). 
> > Rule id: '100004' 
> > Level: '12' 
> > Description: 'nas user logged in' 
> > **Alert to be generated. 
> > 
> > Unfortunately this does not result in any alerts/emails. Done the usual 
> > googling & reading of "OSSEC HIDS Host-Based ....." but still cannot 
> figure 
> > out what i'm doing wrong. Will be super grateful if someone could point 
> out 
> > what i have done wrong. 
> > 
> > Regards 
> > 
> > -- 
> > 
> > --- 
> > You received this message because you are subscribed to the Google 
> Groups 
> > "ossec-list" group. 
> > To unsubscribe from this group and stop receiving emails from it, send 
> an 
> > email to ossec-list+...@googlegroups.com <javascript:>. 
> > For more options, visit https://groups.google.com/d/optout. 
> 

-- 

--- 
You received this message because you are subscribed to the Google Groups \
"ossec-list" group. To unsubscribe from this group and stop receiving emails from it, \
send an email to ossec-list+unsubscribe@googlegroups.com. For more options, visit \
https://groups.google.com/d/optout.


[Attachment #5 (text/html)]

<div dir="ltr">Hi Dan<div><br></div><div>Thanks for the info, been working on this \
for the last few days and unfortunately I tried this approach and could not get it to \
work. In the end installed syslog-ng &amp; picked up the info locally from a \
file/imported into ossec just like any other log file . This worked like a dream and \
getting all the alerts/emails now :) Once again thanks for replying and for anyone \
else trying this syslog-ng might be your friend ...  <br><br>On Friday, July 27, 2018 \
at 3:39:01 PM UTC+1, dan (ddpbsd) wrote:<blockquote class="gmail_quote" \
style="margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: \
1ex;">On Wed, Jul 25, 2018 at 2:42 PM, mjwoods69 via ossec-list <br>&lt;<a \
href="javascript:" target="_blank" gdf-obfuscated-mailto="YIaQvtMnCQAJ" \
rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" \
onclick="this.href=&#39;javascript:&#39;;return \
true;">ossec...@googlegroups.com</a>&gt; wrote: <br>&gt; Hi
<br>&gt;
<br>&gt; Trying to get alerting implemented on my nas. Unfortunately my work to date
<br>&gt; has failed, in summary I have:
<br>&gt;
<br>&gt; 1. Identified the log message in /var/ossec/logs/archives/<wbr>archives.log, \
this <br>&gt; is sent from nas to ossec via syslog -&gt;
<br>&gt;
<br>&gt; 2018 Jul 25 17:55:58 nas-&gt;10.0.0.3 Jul 25 18:48:23 nas qlogd[8736]: conn
<br>&gt; log: Users: admin, Source IP: 10.0.0.54, Computer name: ---, Connection
<br>&gt; type: , Accessed resources: Administration, Action: Login OK
<br>&gt;
<br>
<br>archives.log has a meta data header attached: `2018 Jul 25 17:55:58
<br>nas-&gt;10.0.0.3 `
<br>Remove this header for the actual log: `Jul 25 14:37:23 nas
<br>qlogd[8736]: conn log: Users: admin, Source IP: 10.0.0.54, Computer
<br>name: ---, Connection type: , Accessed resources: Administration,
<br>Action: Login OK`
<br>
<br>Using the non-meta-data-encumbered log message with a modified decoder
<br>gives the following output:
<br>
<br>ossec-testrule: Type one log per line.
<br>
<br>Jul 25 14:37:23 nas qlogd[8736]: conn log: Users: admin, Source IP:
<br>10.0.0.54, Computer name: ---, Connection type: , Accessed resources:
<br>Administration, Action: Login OK
<br>
<br>
<br>**Phase 1: Completed pre-decoding.
<br>           full event: &#39;Jul 25 14:37:23 nas qlogd[8736]: conn log: Users:
<br>admin, Source IP: 10.0.0.54, Computer name: ---, Connection type: ,
<br>Accessed resources: Administration, Action: Login OK&#39;
<br>           hostname: &#39;nas&#39;
<br>           program_name: &#39;qlogd&#39;
<br>           log: &#39;conn log: Users: admin, Source IP: 10.0.0.54, Computer
<br>name: ---, Connection type: , Accessed resources: Administration,
<br>Action: Login OK&#39;
<br>
<br>**Phase 2: Completed decoding.
<br>           decoder: &#39;qlogd&#39;
<br>           dstuser: &#39;admin&#39;
<br>           srcip: &#39;10.0.0.54&#39;
<br>           action: &#39;Login&#39;
<br>
<br>**Phase 3: Completed filtering (rules).
<br>           Rule id: &#39;100004&#39;
<br>           Level: &#39;12&#39;
<br>           Description: &#39;nas user logged in&#39;
<br>**Alert to be generated.
<br>
<br>
<br>Modified decoder:
<br>
<br>&lt;decoder name=&quot;qlogd&quot;&gt;
<br>      &lt;program_name&gt;^qlogd&lt;/program_<wbr>name&gt;
<br>      &lt;regex&gt;\.+ Users: (\S+), Source IP: (\d+.\d+.\d+.\d+), \.+ Action:
<br>(\S+)&lt;/regex&gt;
<br>      &lt;order&gt;user, srcip, action&lt;/order&gt;
<br>&lt;/decoder&gt;
<br>
<br>Next, I restart the ossec processes on the manager, and use `logger`
<br>to test the log:
<br>`echo &#39;conn log: Users: admin, Source IP: 10.0.0.54, Computer name:
<br>---, Connection type: , Accessed resources: Administration, Action:
<br>Login OK&#39; | logger -t qlogd`
<br>I get the following in `/var/log/messages`:
<br>Jul 27 10:36:40 rossak qlogd: conn log: Users: admin, Source IP:
<br>10.0.0.54, Computer name: ---, Connection type: , Accessed resources:
<br>Administration, Action: Login OK
<br>
<br>And the following in `/var/ossec/logs/alerts/<wbr>alerts.log`:
<br>** Alert 1532702200.100802: mail   - syslog,qlogd,
<br>2018 Jul 27 10:36:40 rossak-&gt;/var/log/messages
<br>Rule: 100004 (level 12) -&gt; &#39;nas user logged in&#39;
<br>Src IP: 10.0.0.54
<br>User: admin
<br>Jul 27 10:36:40 rossak qlogd: conn log: Users: admin, Source IP:
<br>10.0.0.54, Computer name: ---, Connection type: , Accessed resources:
<br>Administration, Action: Login OK&#39;
<br>
<br>
<br>
<br>&gt; 2. Constructed a decoder at /var/ossec/etc/local_decoder.<wbr>xml -&gt;
<br>&gt;
<br>&gt; &lt;decoder name=&quot;qlogd&quot;&gt;
<br>&gt;       &lt;prematch&gt;\S+ qlogd&lt;/prematch&gt;
<br>&gt;       &lt;regex offset=&quot;after_prematch&quot;&gt;\.+ Users: (\S+), \
Source IP: <br>&gt; (\d+.\d+.\d+.\d+), \.+ Action: (\S+)&lt;/regex&gt;
<br>&gt;       &lt;order&gt;user, srcip, action&lt;/order&gt;
<br>&gt; &lt;/decoder&gt;
<br>&gt;
<br>&gt; 3. Constructed a number of rules at /var/ossec/rules/local_rules.<wbr>xml \
-&gt; <br>&gt;
<br>&gt; &lt;group name=&quot;syslog,qlogd,&quot;&gt;
<br>&gt;       &lt;rule id=&quot;100002&quot; level=&quot;0&quot;&gt;
<br>&gt;             &lt;decoded_as&gt;qlogd&lt;/decoded_as&gt;
<br>&gt;             &lt;description&gt;qlogd messages to analyze&lt;/description&gt;
<br>&gt;      &lt;/rule&gt;
<br>&gt;      &lt;rule id=&quot;100003&quot; level=&quot;12&quot;&gt;
<br>&gt;       &lt;if_sid&gt;100002&lt;/if_sid&gt;
<br>&gt;             &lt;action&gt;Logout&lt;/action&gt;
<br>&gt;       &lt;description&gt;nas user logged out&lt;/description&gt;
<br>&gt;      &lt;/rule&gt;
<br>&gt;      &lt;rule id=&quot;100004&quot; level=&quot;12&quot;&gt;
<br>&gt;             &lt;if_sid&gt;100002&lt;/if_sid&gt;
<br>&gt;             &lt;action&gt;Login&lt;/action&gt;
<br>&gt;             &lt;description&gt;nas user logged in&lt;/description&gt;
<br>&gt;      &lt;/rule&gt;
<br>&gt; &lt;/group&gt;
<br>&gt;
<br>&gt; 4. Confirmed grammer via /var/ossec/bin/ossec-logtest -&gt;
<br>&gt;
<br>&gt; **Phase 1: Completed pre-decoding.
<br>&gt;            full event: &#39;2018 Jul 25 13:44:58 nas-&gt;10.0.0.3 Jul 25 \
14:37:23 nas <br>&gt; qlogd[8736]: conn log: Users: admin, Source IP: 10.0.0.54, \
Computer name: <br>&gt; ---, Connection type: , Accessed resources: Administration, \
Action: Login <br>&gt; OK&#39;
<br>&gt;            hostname: &#39;pi&#39;
<br>&gt;            program_name: &#39;(null)&#39;
<br>&gt;            log: &#39;2018 Jul 25 13:44:58 nas-&gt;10.0.0.3 Jul 25 14:37:23 \
nas <br>&gt; qlogd[8736]: conn log: Users: admin, Source IP: 10.0.0.54, Computer \
name: <br>&gt; ---, Connection type: , Accessed resources: Administration, Action: \
Login <br>&gt; OK&#39;
<br>&gt;
<br>&gt; **Phase 2: Completed decoding.
<br>&gt;            decoder: &#39;qlogd&#39;
<br>&gt;            dstuser: &#39;admin&#39;
<br>&gt;            srcip: &#39;10.0.0.54&#39;
<br>&gt;            action: &#39;Login&#39;
<br>&gt;
<br>&gt; **Phase 3: Completed filtering (rules).
<br>&gt;            Rule id: &#39;100004&#39;
<br>&gt;            Level: &#39;12&#39;
<br>&gt;            Description: &#39;nas user logged in&#39;
<br>&gt; **Alert to be generated.
<br>&gt;
<br>&gt; Unfortunately this does not result in any alerts/emails. Done the usual
<br>&gt; googling &amp; reading of &quot;OSSEC HIDS Host-Based .....&quot; but still \
cannot figure <br>&gt; out what i&#39;m doing wrong. Will be super grateful if \
someone could point out <br>&gt; what i have done wrong.
<br>&gt;
<br>&gt; Regards
<br>&gt;
<br>&gt; --
<br>&gt;
<br>&gt; ---
<br>&gt; You received this message because you are subscribed to the Google Groups
<br>&gt; &quot;ossec-list&quot; group.
<br>&gt; To unsubscribe from this group and stop receiving emails from it, send an
<br>&gt; email to <a href="javascript:" target="_blank" \
gdf-obfuscated-mailto="YIaQvtMnCQAJ" rel="nofollow" \
onmousedown="this.href=&#39;javascript:&#39;;return true;" \
onclick="this.href=&#39;javascript:&#39;;return \
true;">ossec-list+...@<wbr>googlegroups.com</a>. <br>&gt; For more options, visit <a \
href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" \
onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" \
onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return \
true;">https://groups.google.com/d/<wbr>optout</a>. <br></blockquote></div></div>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups \
&quot;ossec-list&quot; group.<br /> To unsubscribe from this group and stop receiving \
emails from it, send an email to <a \
href="mailto:ossec-list+unsubscribe@googlegroups.com">ossec-list+unsubscribe@googlegroups.com</a>.<br \
/> For more options, visit <a \
href="https://groups.google.com/d/optout">https://groups.google.com/d/optout</a>.<br \
/>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic