<!-- OSSEC example config -->

<ossec_config>
  <global>
<!--
    <email_notification>no</email_notification>
    <email_to>daniel.cid@xxx.com</email_to>
    <smtp_server>smtp.xxx.com.</smtp_server>
    <email_from>ossecm@ossec.xxx.com.</email_from>
    <email_maxperhour>1</email_maxperhour>
-->

    <!-- to specify GeoIP database file location -->
<!--
    <geoip_db_path>/etc/GeoLiteCity.dat</geoip_db_path>
    <geoip6_db_path>/etc/GeoLiteCityv6.dat</geoip6_db_path>
-->
    <!-- enable picviz link: http://ossec-docs.readthedocs.org/en/latest/manual/output/picviz-output.html?highlight=picviz -->
    <picviz_output>yes</picviz_output>
    <picviz_socket>/var/ossec/picviz.socket</picviz_socket>

  </global>

  <rules>
    <include>rules_config.xml</include>
    <include>pam_rules.xml</include>
    <include>sshd_rules.xml</include>
    <include>telnetd_rules.xml</include>
    <include>syslog_rules.xml</include>
    <include>arpwatch_rules.xml</include>
    <include>symantec-av_rules.xml</include>
    <include>symantec-ws_rules.xml</include>
    <include>pix_rules.xml</include>
    <include>named_rules.xml</include>
    <include>smbd_rules.xml</include>
    <include>vsftpd_rules.xml</include>
    <include>pure-ftpd_rules.xml</include>
    <include>proftpd_rules.xml</include>
    <include>ms_ftpd_rules.xml</include>
    <include>ftpd_rules.xml</include>
    <include>hordeimp_rules.xml</include>
    <include>roundcube_rules.xml</include>
    <include>wordpress_rules.xml</include>
    <include>cimserver_rules.xml</include>
    <include>vpopmail_rules.xml</include>
    <include>vmpop3d_rules.xml</include>
    <include>courier_rules.xml</include>
    <include>web_rules.xml</include>
    <include>web_appsec_rules.xml</include>
    <include>apache_rules.xml</include>
    <include>nginx_rules.xml</include>
    <include>php_rules.xml</include>
    <include>mysql_rules.xml</include>
    <include>postgresql_rules.xml</include>
    <include>ids_rules.xml</include>
    <include>squid_rules.xml</include>
    <include>firewall_rules.xml</include>
    <include>cisco-ios_rules.xml</include>
    <include>netscreenfw_rules.xml</include>
    <include>sonicwall_rules.xml</include>
    <include>postfix_rules.xml</include>
    <include>sendmail_rules.xml</include>
    <include>imapd_rules.xml</include>
    <include>mailscanner_rules.xml</include>
    <include>dovecot_rules.xml</include>
    <include>ms-exchange_rules.xml</include>
    <include>racoon_rules.xml</include>
    <include>vpn_concentrator_rules.xml</include>
    <include>spamd_rules.xml</include>
    <include>msauth_rules.xml</include>
    <include>mcafee_av_rules.xml</include>
    <include>trend-osce_rules.xml</include>
    <include>ms-se_rules.xml</include>
    <!-- <include>policy_rules.xml</include> -->
    <include>zeus_rules.xml</include>
    <include>solaris_bsm_rules.xml</include>
    <include>vmware_rules.xml</include>
    <include>ms_dhcp_rules.xml</include>
    <include>asterisk_rules.xml</include>
    <include>ossec_rules.xml</include>
    <include>attack_rules.xml</include>
    <include>local_rules.xml</include>
    <include>local_rules_mac.xml</include>
    <decoder>/opt/local/var/ossec/etc/decoder.xml</decoder>
    <decoder>/opt/local/var/ossec/etc/decoder_local_mac.xml</decoder>
<!--
    <decoder>/opt/local/var/ossec/etc/local_decoder.xml</decoder>
-->
  </rules>


  <syscheck>
    <disabled>yes</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>

  <global>
    <white_list>127.0.0.1</white_list>
  </global>

<!-- For Server install: remoted daemon listening for agent -->
  <remote>
    <connection>secure</connection>
  </remote>

  <alerts>
    <log_alert_level>1</log_alert_level>
    <email_alert_level>7</email_alert_level>

    <!-- to add GeoIP info in alerts -->
<!--
    <use_geoip>yes</use_geoip>
-->
  </alerts>

  <command>
    <name>host-deny</name>
    <executable>host-deny.sh</executable>
    <expect>srcip</expect>
    <timeout_allowed>yes</timeout_allowed>
  </command>  

  <command>
    <name>firewall-drop</name>
    <executable>firewall-drop.sh</executable>
    <expect>srcip</expect>
    <timeout_allowed>yes</timeout_allowed>
  </command>  

  <command>
    <name>disable-account</name>
    <executable>disable-account.sh</executable>
    <expect>user</expect>
    <timeout_allowed>yes</timeout_allowed>
  </command>  


  <!-- Active Response Config -->
  <active-response>
    <!-- This response is going to execute the host-deny
       - command for every event that fires a rule with
       - level (severity) >= 6.
       - The IP is going to be blocked for  600 seconds.
      -->
    <command>host-deny</command>
    <location>local</location>
    <level>6</level>
    <timeout>600</timeout>
  </active-response>

  <active-response>
    <!-- Firewall Drop response. Block the IP for
       - 600 seconds on the firewall (iptables,
       - ipfilter, etc).
      -->
    <command>firewall-drop</command>
    <location>local</location>
    <level>6</level>
    <timeout>600</timeout>    
  </active-response>  

  <!-- 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>
