diff --git a/salt/filebeat/init.sls b/salt/filebeat/init.sls index 251274606..8b0ec3f4c 100644 --- a/salt/filebeat/init.sls +++ b/salt/filebeat/init.sls @@ -61,6 +61,7 @@ so-filebeat: - /opt/so/conf/filebeat/etc/filebeat.yml:/usr/share/filebeat/filebeat.yml:ro - /nsm/bro:/nsm/bro:ro - /opt/so/log/suricata:/suricata:ro + - /opt/so/wazuh/logs/alerts/:/wazuh/alerts:ro - /opt/so/conf/filebeat/etc/pki/filebeat.crt:/usr/share/filebeat/filebeat.crt:ro - /opt/so/conf/filebeat/etc/pki/filebeat.key:/usr/share/filebeat/filebeat.key:ro - /etc/ssl/certs/intca.crt:/usr/share/filebeat/intraca.crt:ro diff --git a/salt/firewall/init.sls b/salt/firewall/init.sls index 71575e3d6..ef2acd81f 100644 --- a/salt/firewall/init.sls +++ b/salt/firewall/init.sls @@ -1,5 +1,19 @@ # Firewall Magic for the grid +{% if grains['role'] == 'so-master' or grains['role'] == 'so-eval' %} + +{%- set ip = salt['pillar.get']('static:masterip', '') %} + +{% elif grains['role'] == 'so-node'%} + +{%- set ip = salt['pillar.get']('node:mainip', '') %} + +{% elif grains['role'] == 'so-sensor'%} + +{%- set ip = salt['pillar.get']('node:mainip', '') %} + +{% endif %} + # Keep localhost in the game iptables_allow_localhost: iptables.append: @@ -86,6 +100,29 @@ enable_docker_user_established: - match: conntrack - ctstate: 'RELATED,ESTABLISHED' +# Add rule(s) for Wazuh manager +enable_wazuh_manager_1514_tcp_{{ip}}: + iptables.insert: + - table: filter + - chain: DOCKER-USER + - jump: ACCEPT + - proto: tcp + - source: {{ ip }} + - dport: 1514 + - position: 1 + - save: True + +enable_wazuh_manager_1514_udp_{{ip}}: + iptables.insert: + - table: filter + - chain: DOCKER-USER + - jump: ACCEPT + - proto: udp + - source: {{ ip }} + - dport: 1514 + - position: 1 + - save: True + # Rules if you are a Master {% if grains['role'] == 'so-master' or grains['role'] == 'so-eval' %} #This should be more granular diff --git a/salt/top.sls b/salt/top.sls index 413a120f6..03c220047 100644 --- a/salt/top.sls +++ b/salt/top.sls @@ -29,11 +29,11 @@ base: - bro - curator - elastalert + - fleet + - wazuh - filebeat - utility - schedule - - fleet - - wazuh 'G@role:so-master': diff --git a/salt/wazuh/files/agent/ossec.conf b/salt/wazuh/files/agent/ossec.conf new file mode 100644 index 000000000..c89b9ce06 --- /dev/null +++ b/salt/wazuh/files/agent/ossec.conf @@ -0,0 +1,195 @@ +{%- if grains['role'] == 'so-master' or grains['role'] == 'so-eval' %} +{%- set ip = salt['pillar.get']('static:masterip', '') %} +{%- endif %} + + + + + +
{{ip}}
+ 1514 + udp +
+ ubuntu, ubuntu16, ubuntu16.04 + 10 + 60 + yes + aes +
+ + + + no + 5000 + 500 + + + + + no + yes + yes + yes + yes + yes + yes + yes + yes + + + 43200 + + /var/ossec/etc/shared/rootkit_files.txt + /var/ossec/etc/shared/rootkit_trojans.txt + + /var/ossec/etc/shared/system_audit_rcl.txt + /var/ossec/etc/shared/system_audit_ssh.txt + + yes + + + + yes + 1800 + 1d + yes + + + + yes + 1800 + 1d + yes + + wodles/java + wodles/ciscat + + + + + yes + yes + /var/log/osquery/osqueryd.results.log + /etc/osquery/osquery.conf + yes + + + + + no + 1h + yes + yes + yes + yes + yes + yes + yes + + + + + no + + + 43200 + + yes + + + /etc,/usr/bin,/usr/sbin + /bin,/sbin,/boot + + + /etc/mtab + /etc/hosts.deny + /etc/mail/statistics + /etc/random-seed + /etc/random.seed + /etc/adjtime + /etc/httpd/logs + /etc/utmpx + /etc/wtmpx + /etc/cups/certs + /etc/dumpdates + /etc/svc/volatile + /sys/kernel/security + /sys/kernel/debug + + + /etc/ssl/private.key + + yes + + + yes + + + yes + + + + + command + df -P + 360 + + + + full_command + netstat -tulpn | sed 's/\([[:alnum:]]\+\)\ \+[[:digit:]]\+\ \+[[:digit:]]\+\ \+\(.*\):\([[:digit:]]*\)\ \+\([0-9\.\:\*]\+\).\+\ \([[:digit:]]*\/[[:alnum:]\-]*\).*/\1 \2 == \3 == \4 \5/' | sort -k 4 -g | sed 's/ == \(.*\) ==/:\1/' | sed 1,2d + netstat listening ports + 360 + + + + full_command + last -n 20 + 360 + + + + + no + /var/ossec/etc/wpk_root.pem + yes + + + + + plain + + +
+ + + + syslog + /var/ossec/logs/active-responses.log + + + + syslog + /var/log/auth.log + + + + syslog + /var/log/syslog + + + + syslog + /var/log/dpkg.log + + + + syslog + /var/log/kern.log + + + diff --git a/salt/wazuh/files/agent/wazuh-register-agent b/salt/wazuh/files/agent/wazuh-register-agent new file mode 100755 index 000000000..b6199cf9a --- /dev/null +++ b/salt/wazuh/files/agent/wazuh-register-agent @@ -0,0 +1,133 @@ +{%- set ip = salt['pillar.get']('static:masterip', '') %} +#!/bin/bash + +### +# Shell script for registering agents automatically with the API +# Copyright (C) 2017 Wazuh, Inc. All rights reserved. +# Wazuh.com +# +# This program is a free software; you can redistribute it +# and/or modify it under the terms of the GNU General Public +# License (version 2) as published by the FSF - Free Software +# Foundation. +### +# +# 12/11/2018 +# This script has been modified by Security Onion Solutions +# - Added Agent IP variable and option +### + +# Connection variables +API_IP="localhost" +API_PORT="55000" +PROTOCOL="https" +USER="foo" +PASSWORD="bar" +AGENT_NAME=$(hostname) +AGENT_IP="{{ip}}" + +display_help() { +cat < agent is not registered +# if ! [ "$AGENT_ID" -eq "$AGENT_ID" ] 2> /dev/null ; then +# echo "Starting registration process ..." +# : +# elif [[ "$FORCE" = true && "$SILENT" = "true" ]] ; then +# remove_agent > /dev/null 2>&1 +# else +# if [[ "$FORCE" = true ]] ; then +# remove_agent +# fi +# fi + +# Default action -> try to register the agent +sleep 10s +register_agent +#remove_agent diff --git a/salt/wazuh/init.sls b/salt/wazuh/init.sls index a7f06ab33..ac05f1984 100644 --- a/salt/wazuh/init.sls +++ b/salt/wazuh/init.sls @@ -1,10 +1,6 @@ {%- set HOSTNAME = salt['grains.get']('host', '') %} -#vm.max_map_count: -# sysctl.present: -# - value: 262144 - -# Add ossec Group +# Add ossec group ossecgroup: group.present: - name: ossec @@ -41,6 +37,25 @@ wazuhpkgs: - pkgs: - wazuh-agent +# Add Wazuh agent conf +wazuhagentconf: + file.managed: + - name: /var/ossec/etc/ossec.conf + - source: salt://wazuh/files/agent/ossec.conf + - user: 0 + - group: 945 + - template: jinja + +# Add Wazuh agent conf +wazuhagentregister: + file.managed: + - name: /usr/sbin/wazuh-register-agent + - source: salt://wazuh/files/agent/wazuh-register-agent + - user: 0 + - group: 0 + - mode: 755 + - template: jinja + so-wazuh: docker_container.running: - image: soshybridhunter/so-wazuh:HH1.0.5 @@ -48,8 +63,15 @@ so-wazuh: - name: so-wazuh - detach: True - port_bindings: - - 0.0.0.0:1514:1514 + - 0.0.0.0:1514:1514/udp + - 0.0.0.0:1514:1514/tcp - 0.0.0.0:55000:55000 - binds: - /opt/so/wazuh/:/var/ossec/data/:rw +# Register the agent +registertheagent: + cmd.run: + - name: /usr/sbin/wazuh-register-agent + - cwd: / + #- stateful: True diff --git a/so-setup-network.sh b/so-setup-network.sh index 0f563a4b3..72496657d 100644 --- a/so-setup-network.sh +++ b/so-setup-network.sh @@ -220,6 +220,14 @@ configure_minion() { } +configure_wazuh_agent(){ + + # Configure Wazuh agent to talk to manager + echo "Configuring Wazuh agent to talk to manager..." + /usr/sbin/wazuh-register-agent -i $MAINIP + +} + copy_master_config() { # Copy the master config template to the proper directory @@ -1625,6 +1633,7 @@ if (whiptail_you_sure); then CURCLOSEDAYS=30 whiptail_make_changes generate_passwords + auth_pillar clear_master mkdir -p /nsm get_filesystem_root @@ -1660,6 +1669,7 @@ if (whiptail_you_sure); then salt_checkin_message salt_checkin checkin_at_boot + #configure_wazuh_agent whiptail_setup_complete fi