On Thu, Jul 7, 2016 at 9:18 AM, Dominik <[email protected]> wrote:
> Hi there,
> I've been using ossec for about half a year now and I'm very happy about
> it. Thanks for this great tool.
>
> I have a linux client on which I need to monitor all activities
> performed as root. My thought is to watch /root/.bash_history and create
> alerts on changes in the file.
>
> So I created a configuration to watch this file in the clients ossec.conf:
> <localfile>
> <log_format>syslog</log_format>
> <location>/root/.bash_history</location>
> </localfile>
>
>
>
> This works well and creates entries in the log archives of the
> ossec-sever e.g.:
>
> 2016 Jul 07 11:06:28 (TheClient) xx.xx.71.109->/root/.bash_history top
>
Since this is an entry in archives.log, the header has to be stripped
before using the log entry in a decoder/rule.
So you're left with:
top
>
>
> I also want to generate alerts.
>
> If I understand correctly, the next steps will be to create a decoder
> and a rule. I tried with the following decoder in
> etc/decoder_local.xml
>
>
> <decoder name="bash_history">
> <program_name>.bash_history</program_name>
Out of curiosity I ran the archives.log entry (header and all) through
ossec-logtest.
Even if the header is included this doesn't match the output I get:
# /var/ossec/bin/ossec-logtest
2016/07/07 09:45:58 ossec-testrule: INFO: Reading local decoder file.
2016 Jul 07 11:06:28 (TheClient) xx.xx.71.109->/root/.bash_history
top2016/07/07 09:45:58 ossec-testrule: INFO: Started (pid: 22503).
ossec-testrule: Type one log per line.
**Phase 1: Completed pre-decoding.
full event: ' 2016 Jul 07 11:06:28 (TheClient)
xx.xx.71.109->/root/.bash_history top'
hostname: 'ipyr'
program_name: '(null)'
log: ' 2016 Jul 07 11:06:28 (TheClient)
xx.xx.71.109->/root/.bash_history top'
**Phase 2: Completed decoding.
No decoder matched.
I think looking at Jose's solution is your best bet.
> </decoder>
>
>
> and a rule in
> rules/local_rules.xml
>
>
> <rule id="105412" level="8">
> <decoded_as>bash_history</decoded_as>
> <description>Command run as root extracted from
> bash_history</description>
> </rule>
>
>
>
> This does not create allerts. Thus I used ossec-logtest to see if things go
> alright:
>
>
> bin/ossec-logtest -v
> 2016/07/07 14:40:56 ossec-testrule: INFO: Reading local decoder file.
> 2016/07/07 14:40:56 ossec-testrule: INFO: Started (pid: 4092).
> ossec-testrule: Type one log per line.
>
> 2016 Jul 07 11:06:28 (TheClient) xx.xx.71.109->/root/.bash_history top
>
> **Phase 1: Completed pre-decoding.
> full event: '2016 Jul 07 11:06:28 (TheClient)
> xx.xx.71.109->/root/.bash_history top'
> hostname: 'ossec-server'
> program_name: '(null)'
> log: '2016 Jul 07 11:06:28 (TheClient)
> xx.xx.71.109->/root/.bash_history top'
>
> **Phase 2: Completed decoding.
> No decoder matched.
>
> **Rule debugging:
> Trying rule: 1 - Generic template for all syslog rules.
> *Rule 1 matched.
> *Trying child rules.
> Trying rule: 5500 - Grouping of the pam_unix rules.
> <and so on...>
>
>
> Obviously, the decoder I'm using is not working. Also pre-decoding does
> not extract information from this log entry.
>
> How do I advance to get alerts from the root activities extracted from
> bash_history?
>
> According to the log-archive, OSSEC knows the origin of the message
> (/root/.bash_history). Is this available to the decoder or to a rule?
>
> Im also not sure, this is the best approach to observe activities of the
> root user. Hints are welcome.
>
> Greetings
> Dominik
>
> --
>
> ---
> 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 [email protected].
> 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 [email protected].
For more options, visit https://groups.google.com/d/optout.