<!-- OSSEC Agent example config for Mac -->

<ossec_config>
  <client>
    <server-ip>x.x.x.x</server-ip>
  </client>

  <syscheck>
    <disabled>no</disabled>
    <!-- Frequency that syscheck is executed -- default every 20 hours -->
    <frequency>72000</frequency>
    
    <!-- Directories to check  (perform all possible verifications) -->
    <directories check_all="yes">/usr/bin,/usr/sbin</directories>
    <directories check_all="yes">/bin,/sbin</directories>
    <directories check_all="yes">/private/etc</directories>
    <directories check_all="yes">/Applications</directories>
    <directories check_all="yes">/System,/Network,/Library</directories>
    <directories check_all="yes">/Developer</directories>
    <directories check_all="yes">/opt/local/etc,/opt/local/bin,/opt/local/sbin</directories>
    <directories check_all="yes">/home</directories>
    <directories check_all="yes">/Library/Preferences</directories>
    <directories check_all="yes">/Users/Shared</directories>

    <!-- Startup items + user-defined one? -->
    <directories check_all="yes">/System/Library/LaunchDaemons,/System/Library/LaunchAgents,/Library/LaunchDaemons,/Library/LaunchAgents,/Library/Preferences/com.apple.loginwindow.plist,/System/Library/XPCServices</directories>

    <!-- User files -->
    <directories check_all="yes">/Users/*/Library/Preferences</directories>
    <directories check_all="yes">/Users/*/Library/Logs</directories>
    <directories check_all="yes">/Users/*/Library/Preferences/com.apple.loginitems.plist</directories>
    <directories check_all="yes">/Users/*/Library/Mail/V2/MailData/Accounts.plist</directories>
    <directories check_all="yes">/Users/*/Library/Preferences/com.apple.LaunchServices.QuarantineEventsV2</directories>

    <!-- coredump directory (disabled by default on macos) -->
    <directories check_all="yes">/cores</directories>

    <!-- Apple web server -->
    <directories check_all="yes">/Library/WebServer/Documents</directories>

    <!-- macports web server -->
<!--
    <directories check_all="yes">/opt/local/www</directories>
-->
    <!-- Doing realtime monitoring for sensitive scripts on webserver -->
    <!-- Note: NOT REPORTING ON NEW FILE: see http://tonyonsecurity.com/2013/07/27/ossec-detecting-new-files-understanding-how-it-works/ -->
    <directories realtime="yes" report_changes="yes" restrict=".php|.js|.asp|.pl|.exe|.ht*">/opt/local/www</directories>
<!--
    <alert_new_files>yes</alert_new_files>
    <scan_on_start>no</scan_on_start>
    <auto_ignore>no</auto_ignore>
-->

    <!-- Files/directories to ignore -->
<!--
    <ignore>/etc/mtab</ignore>
    <ignore>/etc/hosts.deny</ignore>
    <ignore>/etc/mail/statistics</ignore>
    <ignore>/etc/random-seed</ignore>
    <ignore>/etc/adjtime</ignore>
    <ignore>/etc/httpd/logs</ignore>
-->
    <ignore>/Library/Caches</ignore>
    <ignore>/System/Library/Caches</ignore>
    <ignore>/Volumes</ignore>
    <ignore>/private/tmp</ignore>
    <ignore>/private/var/tmp</ignore>
    <ignore>/opt/tmp</ignore>
<!-- Apple Malware definitions file (auto-updated) -->
    <ignore>/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/XProtect.plist</ignore>
    <ignore>/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/XProtect.meta.plist</ignore>
    <ignore>/Library/Managed Preferences/Guest/com.apple.familycontrols.contentfilter.plist</ignore>
<!-- Google Chrome just auto update too much ... just keeping main executable: 'Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary' -->
    <ignore>/Applications/Google Chrome Canary.app/Contents/Resources/</ignore>
    <ignore>/Applications/Google Chrome Canary.app/Contents/Info.plist</ignore>
    <ignore>/Applications/Google Chrome Canary.app/Contents/_CodeSignature/CodeResources</ignore>
  </syscheck>

  <rootcheck>
    <rootkit_files>/opt/local/var/ossec/etc/shared/rootkit_files.txt</rootkit_files>
    <rootkit_trojans>/opt/local/var/ossec/etc/shared/rootkit_trojans.txt</rootkit_trojans>
  </rootcheck>

  <!-- Files to monitor (localfiles) -->

<!-- can be multiline -->
  <localfile>
    <log_format>syslog</log_format>
    <location>/private/var/log/system.log</location>
  </localfile>

  <localfile>
    <log_format>syslog</log_format>
    <location>/private/var/log/authd.log</location>
  </localfile>

  <localfile>
    <log_format>syslog</log_format>
    <location>/private/var/log/appfirewall.log</location>
  </localfile>

  <localfile>
    <log_format>syslog</log_format>
    <location>/private/var/log/alf.log</location>
  </localfile>

<!-- can be multiline -->
  <localfile>
    <log_format>syslog</log_format>
    <location>/private/var/log/appstore.log</location>
  </localfile>

<!-- can be multiline -->
  <localfile>
    <log_format>syslog</log_format>
    <location>/private/var/log/install.log</location>
  </localfile>

  <localfile>
    <log_format>syslog</log_format>
    <location>/private/var/log/mail.log</location>
  </localfile>

  <localfile>
    <log_format>syslog</log_format>
    <location>/private/var/log/notifyd.log</location>
  </localfile>

  <localfile>
    <log_format>syslog</log_format>
    <location>/private/var/log/opendirectoryd.log</location>
  </localfile>

  <localfile>
    <log_format>syslog</log_format>
    <location>/private/var/log/shutdown_monitor.log</location>
  </localfile>

  <localfile>
    <log_format>syslog</log_format>
    <location>/private/var/log/wifi.log</location>
  </localfile>

<!-- Apache2 from Apple -->
<!--
  <localfile>
    <log_format>apache</log_format>
    <location>/private/var/log/apache2/access_log</location>
  </localfile>

  <localfile>
    <log_format>apache</log_format>
    <location>/private/var/log/apache2/error_log</location>
  </localfile>
-->

<!-- Macports log -->

  <localfile>
    <log_format>syslog</log_format>
    <location>/opt/local/var/log/php55/php-fpm.log</location>
  </localfile>

  <localfile>
    <log_format>apache</log_format>
    <location>/opt/local/var/log/nginx/access.log</location>
  </localfile>

<!-- Custom commands -->

<!-- monitor network listen access -->
<localfile>
    <log_format>full_command</log_format>
    <command>netstat -tan |awk '/LISTEN/ && !/(127.0.0.1|::1)/'</command>
</localfile>

<!-- monitor disk occupation -->
<localfile>
    <log_format>command</log_format>
    <command>df -h</command>
</localfile>

<!-- monitor last logged users -->
<localfile>
    <log_format>command</log_format>
    <command>last -5</command>
</localfile>

<!-- monitor ipfw rules -->
<localfile>
    <log_format>command</log_format>
    <command>ipfw -t list</command>
</localfile>

<!-- monitor user list -->
<localfile>
    <log_format>command</log_format>
    <command>dscl . list /users</command>
</localfile>

<!-- monitor active launchd sons -->
<localfile>
    <log_format>command</log_format>
    <command>launchctl list</command>
</localfile>

<!-- monitor shared memory -->
<localfile>
    <log_format>command</log_format>
    <command>ipcs -m</command>
</localfile>

</ossec_config>
