diff --git a/docker/README.md b/docker/README.md new file mode 100644 index 00000000..b4965257 --- /dev/null +++ b/docker/README.md @@ -0,0 +1,77 @@ +# Wazuh development with Wazuh Stack + +## Requirements + +- vm.max_map_count=262144 + + To modify the vm.max_map_count, you can run this command: + `sudo sysctl -w vm.max_map_count=262144` + +- jq + + To install jq, you can run this command: + + - In Debian/Ubuntu os: + `sudo apt-get install jq` + - In RedHat/CentOS: + `sudo yum install jq` + - In Arch: + `sudo pacman -Sy --noconfirm jq` + - In MAC: + `brew install jq` + +## Usage + +Use always the provided script to bring up or down the development +environment. For example: + +```bash +./dev.sh [-o 1.2.4] [-d 1.2.0] $WZ_HOME up [saml] +``` + +The script will ask you all the required parameters to bring up the +environment, including the version of the elastic stack you want to +develop for, and the source code folder where the wazuh-dashboard-plugins is +located. + +Use the `saml` flag to bring up KeyCloak IDP. **Add idp to your hosts and start +the server using the `--no-base-path`**. + +```apacheconf +# Linux systems: /etc/hosts +# Windows systems: C:\Windows\System32\drivers\etc\hosts +127.0.0.1 idp +``` + +**The script will not select the appropriate version of the +wazuh-dashboard-plugins to use, so be sure to check out the appropriate version +before bringing up the environment!** + +### UI Credentials + +The default user and password to access the UI at https://0.0.0.0:5601/ are: + +``` +admin:admin +``` + +## Notes + +`Wazuh Indexer` and `Wazuh Dashboard` are both a redistribution of a +version of the OpenSearch Stack. We will only create environments for +the versions of OpenSearch which will be included into a Wazuh +version. + +We must use official `Wazuh Indexer` and `Wazuh Dashboard` images for +testing! + +This environment will start a working deployment with: + +- Imposter - a mock server. +- Elasticsearch-exporter - Elasticsearch metrics to Prometheus adapter. +- OpenSearch single-node cluster. +- OpenSearch Dashboards development environment. + +The OpenSearch Dashboards development environment includes an already +bootstrapped Kibana, with all the node modules precompiled and ready to +use in a development session. diff --git a/docker/config/1.x/certs/ca.json b/docker/config/1.x/certs/ca.json new file mode 100644 index 00000000..8a96a70a --- /dev/null +++ b/docker/config/1.x/certs/ca.json @@ -0,0 +1,15 @@ +{ + "CN": "Wazuh", + "key": { + "algo": "rsa", + "size": 2048 + }, + "names": [ + { + "C": "US", + "L": "San Francisco", + "O": "Wazuh", + "OU": "Wazuh Root CA" + } + ] +} diff --git a/docker/config/1.x/certs/cfssl.json b/docker/config/1.x/certs/cfssl.json new file mode 100644 index 00000000..d23daf76 --- /dev/null +++ b/docker/config/1.x/certs/cfssl.json @@ -0,0 +1,58 @@ +{ + "signing": { + "default": { + "expiry": "8760h" + }, + "profiles": { + "intermediate_ca": { + "usages": [ + "signing", + "digital signature", + "key encipherment", + "cert sign", + "crl sign", + "server auth", + "client auth" + ], + "expiry": "8760h", + "ca_constraint": { + "is_ca": true, + "max_path_len": 0, + "max_path_len_zero": true + } + }, + "peer": { + "usages": [ + "signing", + "digital signature", + "key encipherment", + "data encipherment", + "client auth", + "server auth" + ], + "expiry": "8760h" + }, + "server": { + "usages": [ + "signing", + "digital signing", + "key encipherment", + "data encipherment", + "server auth" + ], + "expiry": "8760h" + }, + "client": { + "usages": [ + "signing", + "digital signature", + "key encipherment", + "data encipherment", + "client auth" + ], + "expiry": "8760h" + } + } + } +} + diff --git a/docker/config/1.x/certs/host.json b/docker/config/1.x/certs/host.json new file mode 100644 index 00000000..27805da5 --- /dev/null +++ b/docker/config/1.x/certs/host.json @@ -0,0 +1,19 @@ +{ + "CN": "HOST", + "key": { + "algo": "rsa", + "size": 2048 + }, + "names": [ + { + "C": "US", + "L": "California", + "O": "Wazuh", + "OU": "Wazuh" + } + ], + "hosts": [ + "HOST", + "localhost" + ] +} diff --git a/docker/config/1.x/filebeat/filebeat.yml b/docker/config/1.x/filebeat/filebeat.yml new file mode 100644 index 00000000..92f55312 --- /dev/null +++ b/docker/config/1.x/filebeat/filebeat.yml @@ -0,0 +1,21 @@ +# Wazuh - Filebeat configuration file +filebeat.modules: + - module: wazuh + alerts: + enabled: true + archives: + enabled: false + +setup.template.json.enabled: true +setup.template.json.path: "/etc/filebeat/wazuh-template.json" +setup.template.json.name: "wazuh" +setup.template.overwrite: true +setup.ilm.enabled: false +output.elasticsearch: + hosts: ["https://os1:9200"] + username: "admin" + password: "admin" + ssl.verification_mode: full + ssl.certificate_authorities: ["/etc/ssl/elastic/ca.pem"] + ssl.certificate: "/etc/ssl/elastic/filebeat.pem" + ssl.key: "/etc/ssl/elastic/filebeat-key.pem" diff --git a/docker/config/1.x/os/config-saml.yml b/docker/config/1.x/os/config-saml.yml new file mode 100644 index 00000000..74fc91c8 --- /dev/null +++ b/docker/config/1.x/os/config-saml.yml @@ -0,0 +1,40 @@ +--- +_meta: + type: "config" + config_version: 2 + +config: + dynamic: + http: + anonymous_auth_enabled: false + authc: + internal_auth: + order: 0 + description: "HTTP basic authentication using the internal user database" + http_enabled: true + transport_enabled: true + http_authenticator: + type: basic + challenge: false + authentication_backend: + type: internal + saml_auth: + order: 1 + description: "Keycloack SAML provider" + http_enabled: true + transport_enabled: false + http_authenticator: + type: saml + challenge: true + config: + idp: + metadata_url: http://idp:8080/realms/wazuh/protocol/saml/descriptor + entity_id: http://idp:8080/realms/wazuh + sp: + entity_id: wazuh + signature_private_key_filepath: "certs/admin-key.pem" + kibana_url: https://localhost:5601 + roles_key: Role + exchange_key: 1a2a3a4a5a6a7a8a9a0a1b2b3b4b5b6b + authentication_backend: + type: noop diff --git a/docker/config/1.x/os/config.yml b/docker/config/1.x/os/config.yml new file mode 100644 index 00000000..c1385bfb --- /dev/null +++ b/docker/config/1.x/os/config.yml @@ -0,0 +1,20 @@ +--- +_meta: + type: "config" + config_version: 2 + +config: + dynamic: + http: + anonymous_auth_enabled: false + authc: + internal_auth: + order: 0 + description: "HTTP basic authentication using the internal user database" + http_enabled: true + transport_enabled: true + http_authenticator: + type: basic + challenge: false + authentication_backend: + type: internal diff --git a/docker/config/1.x/os/internal_users.yml b/docker/config/1.x/os/internal_users.yml new file mode 100755 index 00000000..21036aaa --- /dev/null +++ b/docker/config/1.x/os/internal_users.yml @@ -0,0 +1,74 @@ +--- +# This is the internal user database +# The hash value is a bcrypt hash and can be generated with plugin/tools/hash.sh + +_meta: + type: "internalusers" + config_version: 2 + +# Define your internal users here + +wazuh_admin: + hash: "$2y$12$d2awHiOYvZjI88VfsDON.u6buoBol0gYPJEgdG1ArKVE0OMxViFfu" + reserved: true + hidden: false + backend_roles: [] + attributes: {} + opendistro_security_roles: ["wazuh_ui_admin"] + static: false + +wazuh_user: + hash: "$2y$12$BQixeoQdRubZdVf/7sq1suHwiVRnSst1.lPI2M0.GPZms4bq2D9vO" + reserved: true + hidden: false + backend_roles: [] + attributes: {} + opendistro_security_roles: ["wazuh_ui_user"] + static: false + +## Demo users + +admin: + hash: "$2a$12$VcCDgh2NDk07JGN0rjGbM.Ad41qVR/YFJcgHp0UGns5JDymv..TOG" + reserved: true + backend_roles: + - "admin" + description: "Demo admin user" + +kibanaserver: + hash: "$2a$12$4AcgAt3xwOWadA5s5blL6ev39OXDNhmOesEoo33eZtrq2N0YrU3H." + reserved: true + description: "Demo kibanaserver user" + +kibanaro: + hash: "$2a$12$JJSXNfTowz7Uu5ttXfeYpeYE0arACvcwlPBStB1F.MI7f0U9Z4DGC" + reserved: false + backend_roles: + - "kibanauser" + - "readall" + attributes: + attribute1: "value1" + attribute2: "value2" + attribute3: "value3" + description: "Demo kibanaro user" + +logstash: + hash: "$2a$12$u1ShR4l4uBS3Uv59Pa2y5.1uQuZBrZtmNfqB3iM/.jL0XoV9sghS2" + reserved: false + backend_roles: + - "logstash" + description: "Demo logstash user" + +readall: + hash: "$2a$12$ae4ycwzwvLtZxwZ82RmiEunBbIPiAmGZduBAjKN0TXdwQFtCwARz2" + reserved: false + backend_roles: + - "readall" + description: "Demo readall user" + +snapshotrestore: + hash: "$2y$12$DpwmetHKwgYnorbgdvORCenv4NAK8cPUg8AI6pxLCuWf/ALc0.v7W" + reserved: false + backend_roles: + - "snapshotrestore" + description: "Demo snapshotrestore user" diff --git a/docker/config/1.x/os/opensearch.yml b/docker/config/1.x/os/opensearch.yml new file mode 100644 index 00000000..ee1dbf59 --- /dev/null +++ b/docker/config/1.x/os/opensearch.yml @@ -0,0 +1,42 @@ +network.host: "0.0.0.0" +node.name: "os1" +path.data: /var/lib/os1 +path.logs: /var/log/os1 +# comment compatibility.override_main_response_version for 2.0.0 +compatibility.override_main_response_version: true +plugins.security.ssl.http.pemcert_filepath: ${OPENSEARCH_PATH_CONF}/certs/os1.pem +plugins.security.ssl.http.pemkey_filepath: ${OPENSEARCH_PATH_CONF}/certs/os1.key +plugins.security.ssl.http.pemtrustedcas_filepath: ${OPENSEARCH_PATH_CONF}/certs/ca.pem +plugins.security.ssl.transport.pemcert_filepath: ${OPENSEARCH_PATH_CONF}/certs/os1.pem +plugins.security.ssl.transport.pemkey_filepath: ${OPENSEARCH_PATH_CONF}/certs/os1.key +plugins.security.ssl.transport.pemtrustedcas_filepath: ${OPENSEARCH_PATH_CONF}/certs/ca.pem +plugins.security.ssl.http.enabled: true +plugins.security.ssl.transport.enforce_hostname_verification: false +plugins.security.ssl.transport.resolve_hostname: false +plugins.security.authcz.admin_dn: + - "CN=admin,OU=Wazuh,O=Wazuh,L=California,C=US" +plugins.security.check_snapshot_restore_write_privileges: true +plugins.security.enable_snapshot_restore_privilege: true +plugins.security.nodes_dn: + - "CN=os1,OU=Wazuh,O=Wazuh,L=California,C=US" +plugins.security.restapi.roles_enabled: + - "all_access" + - "security_rest_api_access" +plugins.security.system_indices.enabled: true +plugins.security.system_indices.indices: + [ + ".opendistro-alerting-config", + ".opendistro-alerting-alert*", + ".opendistro-anomaly-results*", + ".opendistro-anomaly-detector*", + ".opendistro-anomaly-checkpoints", + ".opendistro-anomaly-detection-state", + ".opendistro-reports-*", + ".opendistro-notifications-*", + ".opendistro-notebooks", + ".opensearch-observability", + ".opendistro-asynchronous-search-response*", + ".replication-metadata-store", + ] +plugins.security.allow_default_init_securityindex: true +cluster.routing.allocation.disk.threshold_enabled: false diff --git a/docker/config/1.x/os/roles.yml b/docker/config/1.x/os/roles.yml new file mode 100644 index 00000000..16894a9f --- /dev/null +++ b/docker/config/1.x/os/roles.yml @@ -0,0 +1,163 @@ +_meta: + type: "roles" + config_version: 2 + +# Restrict users so they can only view visualization and dashboards on kibana +kibana_read_only: + reserved: true + +# The security REST API access role is used to assign specific users access to change the security settings through the REST API. +security_rest_api_access: + reserved: true + +# Allows users to view monitors, destinations and alerts +alerting_read_access: + reserved: true + cluster_permissions: + - "cluster:admin/opendistro/alerting/alerts/get" + - "cluster:admin/opendistro/alerting/destination/get" + - "cluster:admin/opendistro/alerting/monitor/get" + - "cluster:admin/opendistro/alerting/monitor/search" + +# Allows users to view and acknowledge alerts +alerting_ack_alerts: + reserved: true + cluster_permissions: + - "cluster:admin/opendistro/alerting/alerts/*" + +# Allows users to use all alerting functionality +alerting_full_access: + reserved: true + cluster_permissions: + - "cluster_monitor" + - "cluster:admin/opendistro/alerting/*" + index_permissions: + - index_patterns: + - "*" + allowed_actions: + - "indices_monitor" + - "indices:admin/aliases/get" + - "indices:admin/mappings/get" + +# Allow users to read Anomaly Detection detectors and results +anomaly_read_access: + reserved: true + cluster_permissions: + - "cluster:admin/opendistro/ad/detector/info" + - "cluster:admin/opendistro/ad/detector/search" + - "cluster:admin/opendistro/ad/detectors/get" + - "cluster:admin/opendistro/ad/result/search" + - "cluster:admin/opendistro/ad/tasks/search" + +# Allows users to use all Anomaly Detection functionality +anomaly_full_access: + reserved: true + cluster_permissions: + - "cluster_monitor" + - "cluster:admin/opendistro/ad/*" + index_permissions: + - index_patterns: + - "*" + allowed_actions: + - "indices_monitor" + - "indices:admin/aliases/get" + - "indices:admin/mappings/get" + +# Allows users to read Notebooks +notebooks_read_access: + reserved: true + cluster_permissions: + - "cluster:admin/opendistro/notebooks/list" + - "cluster:admin/opendistro/notebooks/get" + +# Allows users to all Notebooks functionality +notebooks_full_access: + reserved: true + cluster_permissions: + - "cluster:admin/opendistro/notebooks/create" + - "cluster:admin/opendistro/notebooks/update" + - "cluster:admin/opendistro/notebooks/delete" + - "cluster:admin/opendistro/notebooks/get" + - "cluster:admin/opendistro/notebooks/list" + +# Allows users to read and download Reports +reports_instances_read_access: + reserved: true + cluster_permissions: + - "cluster:admin/opendistro/reports/instance/list" + - "cluster:admin/opendistro/reports/instance/get" + - "cluster:admin/opendistro/reports/menu/download" + +# Allows users to read and download Reports and Report-definitions +reports_read_access: + reserved: true + cluster_permissions: + - "cluster:admin/opendistro/reports/definition/get" + - "cluster:admin/opendistro/reports/definition/list" + - "cluster:admin/opendistro/reports/instance/list" + - "cluster:admin/opendistro/reports/instance/get" + - "cluster:admin/opendistro/reports/menu/download" + +# Allows users to all Reports functionality +reports_full_access: + reserved: true + cluster_permissions: + - "cluster:admin/opendistro/reports/definition/create" + - "cluster:admin/opendistro/reports/definition/update" + - "cluster:admin/opendistro/reports/definition/on_demand" + - "cluster:admin/opendistro/reports/definition/delete" + - "cluster:admin/opendistro/reports/definition/get" + - "cluster:admin/opendistro/reports/definition/list" + - "cluster:admin/opendistro/reports/instance/list" + - "cluster:admin/opendistro/reports/instance/get" + - "cluster:admin/opendistro/reports/menu/download" + +# Allows users to use all asynchronous-search functionality +asynchronous_search_full_access: + reserved: true + cluster_permissions: + - "cluster:admin/opendistro/asynchronous_search/*" + index_permissions: + - index_patterns: + - "*" + allowed_actions: + - "indices:data/read/search*" + +# Allows users to read stored asynchronous-search results +asynchronous_search_read_access: + reserved: true + cluster_permissions: + - "cluster:admin/opendistro/asynchronous_search/get" + +wazuh_ui_user: + reserved: true + hidden: false + cluster_permissions: [] + index_permissions: + - index_patterns: + - "wazuh-*" + dls: "" + fls: [] + masked_fields: [] + allowed_actions: + - "read" + tenant_permissions: [] + static: false + +wazuh_ui_admin: + reserved: true + hidden: false + cluster_permissions: [] + index_permissions: + - index_patterns: + - "wazuh-*" + dls: "" + fls: [] + masked_fields: [] + allowed_actions: + - "read" + - "delete" + - "manage" + - "index" + tenant_permissions: [] + static: false diff --git a/docker/config/1.x/os/roles_mapping.yml b/docker/config/1.x/os/roles_mapping.yml new file mode 100644 index 00000000..4eca848c --- /dev/null +++ b/docker/config/1.x/os/roles_mapping.yml @@ -0,0 +1,71 @@ +--- +# In this file users, backendroles and hosts can be mapped to Wazuh indexer Security roles. +# Permissions for Wazuh indexer roles are configured in roles.yml + +_meta: + type: "rolesmapping" + config_version: 2 + +# Define your roles mapping here + +## Demo roles mapping + +all_access: + reserved: false + backend_roles: + - "admin" + description: "Maps admin to all_access" + +own_index: + reserved: false + users: + - "*" + description: "Allow full access to an index named like the username" + +logstash: + reserved: false + backend_roles: + - "logstash" + +kibana_user: + reserved: false + backend_roles: + - "kibanauser" + users: + - "wazuh_user" + - "wazuh_admin" + description: "Maps kibanauser to kibana_user" + +readall: + reserved: false + backend_roles: + - "readall" + +manage_snapshots: + reserved: false + backend_roles: + - "snapshotrestore" + +kibana_server: + reserved: true + users: + - "kibanaserver" + +wazuh_ui_admin: + reserved: true + hidden: false + backend_roles: [] + hosts: [] + users: + - "wazuh_admin" + - "kibanaserver" + and_backend_roles: [] + +wazuh_ui_user: + reserved: true + hidden: false + backend_roles: [] + hosts: [] + users: + - "wazuh_user" + and_backend_roles: [] diff --git a/docker/config/1.x/osd/opensearch_dashboards.yml b/docker/config/1.x/osd/opensearch_dashboards.yml new file mode 100755 index 00000000..a7804f54 --- /dev/null +++ b/docker/config/1.x/osd/opensearch_dashboards.yml @@ -0,0 +1,14 @@ +server.host: 0.0.0.0 +server.port: 5601 +opensearch.hosts: https://os1:9200 +opensearch.ssl.verificationMode: certificate +opensearch.requestHeadersWhitelist: ["securitytenant", "Authorization"] +opensearch_security.multitenancy.enabled: false +opensearch_security.readonly_mode.roles: ["kibana_read_only"] +server.ssl.enabled: true +server.ssl.key: "/home/node/kbn/certs/osd.key" +server.ssl.certificate: "/home/node/kbn/certs/osd.pem" +opensearch.ssl.certificateAuthorities: ["/home/node/kbn/certs/ca.pem"] +uiSettings.overrides.defaultRoute: /app/wazuh +opensearch.username: "kibanaserver" +opensearch.password: "kibanaserver" diff --git a/docker/config/1.x/osd/opensearch_dashboards_saml.yml b/docker/config/1.x/osd/opensearch_dashboards_saml.yml new file mode 100755 index 00000000..f5b38f37 --- /dev/null +++ b/docker/config/1.x/osd/opensearch_dashboards_saml.yml @@ -0,0 +1,25 @@ +server.host: 0.0.0.0 +server.port: 5601 +opensearch.hosts: https://os1:9200 +opensearch.ssl.verificationMode: certificate +opensearch.requestHeadersWhitelist: ["securitytenant", "Authorization"] +opensearch_security.multitenancy.enabled: false +opensearch_security.readonly_mode.roles: ["kibana_read_only"] +server.ssl.enabled: true +server.ssl.key: "/home/node/kbn/certs/osd.key" +server.ssl.certificate: "/home/node/kbn/certs/osd.pem" +opensearch.ssl.certificateAuthorities: ["/home/node/kbn/certs/ca.pem"] +uiSettings.overrides.defaultRoute: /app/wazuh +opensearch.username: "kibanaserver" +opensearch.password: "kibanaserver" + +opensearch_security.auth.type: "saml" +server.xsrf.whitelist: + [ + /_plugins/_security/saml/acs, + /_opendistro/_security/saml/acs, + /_plugins/_security/saml/acs/idpinitiated, + /_opendistro/_security/saml/acs/idpinitiated, + /_plugins/_security/saml/logout, + /_opendistro/_security/saml/logout, + ] diff --git a/docker/config/1.x/osd/wazuh.yml b/docker/config/1.x/osd/wazuh.yml new file mode 100755 index 00000000..3f3bc90b --- /dev/null +++ b/docker/config/1.x/osd/wazuh.yml @@ -0,0 +1,19 @@ +hosts: + - manager: + url: 'https://wazuh.manager' + port: 55000 + username: wazuh-wui + password: MyS3cr37P450r.*- + run_as: false + - imposter: + url: 'http://imposter' + port: 8080 + username: wazuh-wui + password: MyS3cr37P450r.*- + run_as: false + - imposter-cli: + url: 'http://' + port: 8080 + username: wazuh-wui + password: MyS3cr37P450r.*- + run_as: false diff --git a/docker/config/1.x/wm/wazuh_manager.conf b/docker/config/1.x/wm/wazuh_manager.conf new file mode 100755 index 00000000..aff1af9d --- /dev/null +++ b/docker/config/1.x/wm/wazuh_manager.conf @@ -0,0 +1,353 @@ + + + yes + yes + no + no + no + smtp.example.wazuh.com + wazuh@example.wazuh.com + recipient@example.wazuh.com + 12 + alerts.log + 10m + 0 + + + + 3 + 12 + + + + + plain + + + + secure + 1514 + tcp + 131072 + + + + + no + yes + yes + yes + yes + yes + yes + yes + + + 43200 + + etc/rootcheck/rootkit_files.txt + etc/rootcheck/rootkit_trojans.txt + + 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 + + + + 10 + + + + + yes + yes + 12h + yes + + + + no + 5m + 6h + yes + + + + no + trusty + xenial + bionic + focal + 1h + + + + + no + stretch + buster + bullseye + 1h + + + + + no + 5 + 6 + 7 + 8 + 1h + + + + + no + amazon-linux + amazon-linux-2 + 1h + + + + + no + 1h + + + + + yes + 1h + + + + + yes + 2010 + 1h + + + + + + + no + + + 43200 + + yes + + + yes + + + no + + + /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 + + + .log$|.swp$ + + + /etc/ssl/private.key + + yes + yes + yes + yes + + + 10 + + + 100 + + + + yes + 5m + 1h + 10 + + + + + + 127.0.0.1 + ^localhost.localdomain$ + 10.0.0.106 + + + + disable-account + disable-account + yes + + + + restart-wazuh + restart-wazuh + + + + firewall-drop + firewall-drop + yes + + + + host-deny + host-deny + yes + + + + route-null + route-null + yes + + + + win_route-null + route-null.exe + yes + + + + netsh + netsh.exe + 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 + + + + + ruleset/decoders + ruleset/rules + 0215-policy_rules.xml + etc/lists/audit-keys + etc/lists/amazon/aws-eventnames + etc/lists/security-eventchannel + + + etc/decoders + etc/rules + + + + yes + 1 + 64 + 15m + + + + + no + 1515 + no + yes + no + HIGH:!ADH:!EXP:!MD5:!RC4:!3DES:!CAMELLIA:@STRENGTH + + no + etc/sslmanager.cert + etc/sslmanager.key + no + + + + wazuh + node01 + master + + 1516 + 0.0.0.0 + + NODE_IP + + no + yes + + + + + + + syslog + /var/ossec/logs/active-responses.log + + + diff --git a/docker/config/2.x/certs/ca.json b/docker/config/2.x/certs/ca.json new file mode 100644 index 00000000..8a96a70a --- /dev/null +++ b/docker/config/2.x/certs/ca.json @@ -0,0 +1,15 @@ +{ + "CN": "Wazuh", + "key": { + "algo": "rsa", + "size": 2048 + }, + "names": [ + { + "C": "US", + "L": "San Francisco", + "O": "Wazuh", + "OU": "Wazuh Root CA" + } + ] +} diff --git a/docker/config/2.x/certs/cfssl.json b/docker/config/2.x/certs/cfssl.json new file mode 100644 index 00000000..d23daf76 --- /dev/null +++ b/docker/config/2.x/certs/cfssl.json @@ -0,0 +1,58 @@ +{ + "signing": { + "default": { + "expiry": "8760h" + }, + "profiles": { + "intermediate_ca": { + "usages": [ + "signing", + "digital signature", + "key encipherment", + "cert sign", + "crl sign", + "server auth", + "client auth" + ], + "expiry": "8760h", + "ca_constraint": { + "is_ca": true, + "max_path_len": 0, + "max_path_len_zero": true + } + }, + "peer": { + "usages": [ + "signing", + "digital signature", + "key encipherment", + "data encipherment", + "client auth", + "server auth" + ], + "expiry": "8760h" + }, + "server": { + "usages": [ + "signing", + "digital signing", + "key encipherment", + "data encipherment", + "server auth" + ], + "expiry": "8760h" + }, + "client": { + "usages": [ + "signing", + "digital signature", + "key encipherment", + "data encipherment", + "client auth" + ], + "expiry": "8760h" + } + } + } +} + diff --git a/docker/config/2.x/certs/host.json b/docker/config/2.x/certs/host.json new file mode 100644 index 00000000..27805da5 --- /dev/null +++ b/docker/config/2.x/certs/host.json @@ -0,0 +1,19 @@ +{ + "CN": "HOST", + "key": { + "algo": "rsa", + "size": 2048 + }, + "names": [ + { + "C": "US", + "L": "California", + "O": "Wazuh", + "OU": "Wazuh" + } + ], + "hosts": [ + "HOST", + "localhost" + ] +} diff --git a/docker/config/2.x/filebeat/filebeat.yml b/docker/config/2.x/filebeat/filebeat.yml new file mode 100644 index 00000000..92f55312 --- /dev/null +++ b/docker/config/2.x/filebeat/filebeat.yml @@ -0,0 +1,21 @@ +# Wazuh - Filebeat configuration file +filebeat.modules: + - module: wazuh + alerts: + enabled: true + archives: + enabled: false + +setup.template.json.enabled: true +setup.template.json.path: "/etc/filebeat/wazuh-template.json" +setup.template.json.name: "wazuh" +setup.template.overwrite: true +setup.ilm.enabled: false +output.elasticsearch: + hosts: ["https://os1:9200"] + username: "admin" + password: "admin" + ssl.verification_mode: full + ssl.certificate_authorities: ["/etc/ssl/elastic/ca.pem"] + ssl.certificate: "/etc/ssl/elastic/filebeat.pem" + ssl.key: "/etc/ssl/elastic/filebeat-key.pem" diff --git a/docker/config/2.x/os/config-saml.yml b/docker/config/2.x/os/config-saml.yml new file mode 100644 index 00000000..74fc91c8 --- /dev/null +++ b/docker/config/2.x/os/config-saml.yml @@ -0,0 +1,40 @@ +--- +_meta: + type: "config" + config_version: 2 + +config: + dynamic: + http: + anonymous_auth_enabled: false + authc: + internal_auth: + order: 0 + description: "HTTP basic authentication using the internal user database" + http_enabled: true + transport_enabled: true + http_authenticator: + type: basic + challenge: false + authentication_backend: + type: internal + saml_auth: + order: 1 + description: "Keycloack SAML provider" + http_enabled: true + transport_enabled: false + http_authenticator: + type: saml + challenge: true + config: + idp: + metadata_url: http://idp:8080/realms/wazuh/protocol/saml/descriptor + entity_id: http://idp:8080/realms/wazuh + sp: + entity_id: wazuh + signature_private_key_filepath: "certs/admin-key.pem" + kibana_url: https://localhost:5601 + roles_key: Role + exchange_key: 1a2a3a4a5a6a7a8a9a0a1b2b3b4b5b6b + authentication_backend: + type: noop diff --git a/docker/config/2.x/os/config.yml b/docker/config/2.x/os/config.yml new file mode 100644 index 00000000..c1385bfb --- /dev/null +++ b/docker/config/2.x/os/config.yml @@ -0,0 +1,20 @@ +--- +_meta: + type: "config" + config_version: 2 + +config: + dynamic: + http: + anonymous_auth_enabled: false + authc: + internal_auth: + order: 0 + description: "HTTP basic authentication using the internal user database" + http_enabled: true + transport_enabled: true + http_authenticator: + type: basic + challenge: false + authentication_backend: + type: internal diff --git a/docker/config/2.x/os/internal_users.yml b/docker/config/2.x/os/internal_users.yml new file mode 100755 index 00000000..bf0becfc --- /dev/null +++ b/docker/config/2.x/os/internal_users.yml @@ -0,0 +1,56 @@ +--- +# This is the internal user database +# The hash value is a bcrypt hash and can be generated with plugin/tools/hash.sh + +_meta: + type: "internalusers" + config_version: 2 + +# Define your internal users here + +## Demo users + +admin: + hash: "$2a$12$VcCDgh2NDk07JGN0rjGbM.Ad41qVR/YFJcgHp0UGns5JDymv..TOG" + reserved: true + backend_roles: + - "admin" + description: "Demo admin user" + +kibanaserver: + hash: "$2a$12$4AcgAt3xwOWadA5s5blL6ev39OXDNhmOesEoo33eZtrq2N0YrU3H." + reserved: true + description: "Demo kibanaserver user" + +kibanaro: + hash: "$2a$12$JJSXNfTowz7Uu5ttXfeYpeYE0arACvcwlPBStB1F.MI7f0U9Z4DGC" + reserved: false + backend_roles: + - "kibanauser" + - "readall" + attributes: + attribute1: "value1" + attribute2: "value2" + attribute3: "value3" + description: "Demo kibanaro user" + +logstash: + hash: "$2a$12$u1ShR4l4uBS3Uv59Pa2y5.1uQuZBrZtmNfqB3iM/.jL0XoV9sghS2" + reserved: false + backend_roles: + - "logstash" + description: "Demo logstash user" + +readall: + hash: "$2a$12$ae4ycwzwvLtZxwZ82RmiEunBbIPiAmGZduBAjKN0TXdwQFtCwARz2" + reserved: false + backend_roles: + - "readall" + description: "Demo readall user" + +snapshotrestore: + hash: "$2y$12$DpwmetHKwgYnorbgdvORCenv4NAK8cPUg8AI6pxLCuWf/ALc0.v7W" + reserved: false + backend_roles: + - "snapshotrestore" + description: "Demo snapshotrestore user" diff --git a/docker/config/2.x/os/opensearch.yml b/docker/config/2.x/os/opensearch.yml new file mode 100644 index 00000000..ee1dbf59 --- /dev/null +++ b/docker/config/2.x/os/opensearch.yml @@ -0,0 +1,42 @@ +network.host: "0.0.0.0" +node.name: "os1" +path.data: /var/lib/os1 +path.logs: /var/log/os1 +# comment compatibility.override_main_response_version for 2.0.0 +compatibility.override_main_response_version: true +plugins.security.ssl.http.pemcert_filepath: ${OPENSEARCH_PATH_CONF}/certs/os1.pem +plugins.security.ssl.http.pemkey_filepath: ${OPENSEARCH_PATH_CONF}/certs/os1.key +plugins.security.ssl.http.pemtrustedcas_filepath: ${OPENSEARCH_PATH_CONF}/certs/ca.pem +plugins.security.ssl.transport.pemcert_filepath: ${OPENSEARCH_PATH_CONF}/certs/os1.pem +plugins.security.ssl.transport.pemkey_filepath: ${OPENSEARCH_PATH_CONF}/certs/os1.key +plugins.security.ssl.transport.pemtrustedcas_filepath: ${OPENSEARCH_PATH_CONF}/certs/ca.pem +plugins.security.ssl.http.enabled: true +plugins.security.ssl.transport.enforce_hostname_verification: false +plugins.security.ssl.transport.resolve_hostname: false +plugins.security.authcz.admin_dn: + - "CN=admin,OU=Wazuh,O=Wazuh,L=California,C=US" +plugins.security.check_snapshot_restore_write_privileges: true +plugins.security.enable_snapshot_restore_privilege: true +plugins.security.nodes_dn: + - "CN=os1,OU=Wazuh,O=Wazuh,L=California,C=US" +plugins.security.restapi.roles_enabled: + - "all_access" + - "security_rest_api_access" +plugins.security.system_indices.enabled: true +plugins.security.system_indices.indices: + [ + ".opendistro-alerting-config", + ".opendistro-alerting-alert*", + ".opendistro-anomaly-results*", + ".opendistro-anomaly-detector*", + ".opendistro-anomaly-checkpoints", + ".opendistro-anomaly-detection-state", + ".opendistro-reports-*", + ".opendistro-notifications-*", + ".opendistro-notebooks", + ".opensearch-observability", + ".opendistro-asynchronous-search-response*", + ".replication-metadata-store", + ] +plugins.security.allow_default_init_securityindex: true +cluster.routing.allocation.disk.threshold_enabled: false diff --git a/docker/config/2.x/os/roles.yml b/docker/config/2.x/os/roles.yml new file mode 100644 index 00000000..5b35df44 --- /dev/null +++ b/docker/config/2.x/os/roles.yml @@ -0,0 +1,149 @@ +_meta: + type: "roles" + config_version: 2 + +# Restrict users so they can only view visualization and dashboard on kibana +kibana_read_only: + reserved: true + +# The security REST API access role is used to assign specific users access to change the security settings through the REST API. +security_rest_api_access: + reserved: true + +# Allows users to view monitors, destinations and alerts +alerting_read_access: + reserved: true + cluster_permissions: + - "cluster:admin/opendistro/alerting/alerts/get" + - "cluster:admin/opendistro/alerting/destination/get" + - "cluster:admin/opendistro/alerting/monitor/get" + - "cluster:admin/opendistro/alerting/monitor/search" + +# Allows users to view and acknowledge alerts +alerting_ack_alerts: + reserved: true + cluster_permissions: + - "cluster:admin/opendistro/alerting/alerts/*" + +# Allows users to use all alerting functionality +alerting_full_access: + reserved: true + cluster_permissions: + - "cluster_monitor" + - "cluster:admin/opendistro/alerting/*" + index_permissions: + - index_patterns: + - "*" + allowed_actions: + - "indices_monitor" + - "indices:admin/aliases/get" + - "indices:admin/mappings/get" + +# Allow users to read Anomaly Detection detectors and results +anomaly_read_access: + reserved: true + cluster_permissions: + - "cluster:admin/opendistro/ad/detector/info" + - "cluster:admin/opendistro/ad/detector/search" + - "cluster:admin/opendistro/ad/detectors/get" + - "cluster:admin/opendistro/ad/result/search" + - "cluster:admin/opendistro/ad/tasks/search" + +# Allows users to use all Anomaly Detection functionality +anomaly_full_access: + reserved: true + cluster_permissions: + - "cluster_monitor" + - "cluster:admin/opendistro/ad/*" + index_permissions: + - index_patterns: + - "*" + allowed_actions: + - "indices_monitor" + - "indices:admin/aliases/get" + - "indices:admin/mappings/get" + +# Allows users to read Notebooks +notebooks_read_access: + reserved: true + cluster_permissions: + - "cluster:admin/opendistro/notebooks/list" + - "cluster:admin/opendistro/notebooks/get" + +# Allows users to all Notebooks functionality +notebooks_full_access: + reserved: true + cluster_permissions: + - "cluster:admin/opendistro/notebooks/create" + - "cluster:admin/opendistro/notebooks/update" + - "cluster:admin/opendistro/notebooks/delete" + - "cluster:admin/opendistro/notebooks/get" + - "cluster:admin/opendistro/notebooks/list" + +# Allows users to read and download Reports +reports_instances_read_access: + reserved: true + cluster_permissions: + - "cluster:admin/opendistro/reports/instance/list" + - "cluster:admin/opendistro/reports/instance/get" + - "cluster:admin/opendistro/reports/menu/download" + +# Allows users to read and download Reports and Report-definitions +reports_read_access: + reserved: true + cluster_permissions: + - "cluster:admin/opendistro/reports/definition/get" + - "cluster:admin/opendistro/reports/definition/list" + - "cluster:admin/opendistro/reports/instance/list" + - "cluster:admin/opendistro/reports/instance/get" + - "cluster:admin/opendistro/reports/menu/download" + +# Allows users to all Reports functionality +reports_full_access: + reserved: true + cluster_permissions: + - "cluster:admin/opendistro/reports/definition/create" + - "cluster:admin/opendistro/reports/definition/update" + - "cluster:admin/opendistro/reports/definition/on_demand" + - "cluster:admin/opendistro/reports/definition/delete" + - "cluster:admin/opendistro/reports/definition/get" + - "cluster:admin/opendistro/reports/definition/list" + - "cluster:admin/opendistro/reports/instance/list" + - "cluster:admin/opendistro/reports/instance/get" + - "cluster:admin/opendistro/reports/menu/download" + +# Allows users to use all asynchronous-search functionality +asynchronous_search_full_access: + reserved: true + cluster_permissions: + - "cluster:admin/opendistro/asynchronous_search/*" + index_permissions: + - index_patterns: + - "*" + allowed_actions: + - "indices:data/read/search*" + +# Allows users to read stored asynchronous-search results +asynchronous_search_read_access: + reserved: true + cluster_permissions: + - "cluster:admin/opendistro/asynchronous_search/get" + +# Wazuh monitoring and statistics index permissions +manage_wazuh_index: + reserved: true + hidden: false + cluster_permissions: [] + index_permissions: + - index_patterns: + - "wazuh-*" + dls: "" + fls: [] + masked_fields: [] + allowed_actions: + - "read" + - "delete" + - "manage" + - "index" + tenant_permissions: [] + static: false diff --git a/docker/config/2.x/os/roles_mapping.yml b/docker/config/2.x/os/roles_mapping.yml new file mode 100644 index 00000000..94c2b466 --- /dev/null +++ b/docker/config/2.x/os/roles_mapping.yml @@ -0,0 +1,88 @@ +--- +# In this file users, backendroles and hosts can be mapped to Open Distro Security roles. +# Permissions for Opendistro roles are configured in roles.yml + +_meta: + type: "rolesmapping" + config_version: 2 + +# Define your roles mapping here + +## Default roles mapping + +all_access: + reserved: true + hidden: false + backend_roles: + - "admin" + hosts: [] + users: [] + and_backend_roles: [] + description: "Maps admin to all_access" + +own_index: + reserved: false + hidden: false + backend_roles: [] + hosts: [] + users: + - "*" + and_backend_roles: [] + description: "Allow full access to an index named like the username" + +logstash: + reserved: false + hidden: false + backend_roles: + - "logstash" + hosts: [] + users: [] + and_backend_roles: [] + +readall: + reserved: true + hidden: false + backend_roles: + - "readall" + hosts: [] + users: [] + and_backend_roles: [] + +manage_snapshots: + reserved: true + hidden: false + backend_roles: + - "snapshotrestore" + hosts: [] + users: [] + and_backend_roles: [] + +kibana_server: + reserved: true + hidden: false + backend_roles: [] + hosts: [] + users: + - "kibanaserver" + and_backend_roles: [] + +kibana_user: + reserved: false + hidden: false + backend_roles: + - "kibanauser" + hosts: [] + users: [] + and_backend_roles: [] + description: "Maps kibanauser to kibana_user" + + # Wazuh monitoring and statistics index permissions +manage_wazuh_index: + reserved: true + hidden: false + backend_roles: [] + hosts: [] + users: + - "kibanaserver" + - "admin" + and_backend_roles: [] diff --git a/docker/config/2.x/osd/opensearch_dashboards.yml b/docker/config/2.x/osd/opensearch_dashboards.yml new file mode 100755 index 00000000..ecf0203e --- /dev/null +++ b/docker/config/2.x/osd/opensearch_dashboards.yml @@ -0,0 +1,22 @@ +server.host: 0.0.0.0 +server.port: 5601 +opensearch.hosts: https://os1:9200 +opensearch.ssl.verificationMode: certificate +#osd 1.2.4 +# opensearch.requestHeadersWhitelist: ["securitytenant","Authorization"] +# +# osd 2.0 +opensearch.requestHeadersAllowlist: ["securitytenant", "Authorization"] +# +opensearch_security.multitenancy.enabled: false +opensearch_security.readonly_mode.roles: ["kibana_read_only"] +server.ssl.enabled: true +server.ssl.key: "/home/node/kbn/certs/osd.key" +server.ssl.certificate: "/home/node/kbn/certs/osd.pem" +opensearch.ssl.certificateAuthorities: ["/home/node/kbn/certs/ca.pem"] +uiSettings.overrides.defaultRoute: /app/reports-dashboards +opensearch.username: "kibanaserver" +opensearch.password: "kibanaserver" +opensearchDashboards.branding: + useExpandedHeader: false + diff --git a/docker/config/2.x/osd/opensearch_dashboards_saml.yml b/docker/config/2.x/osd/opensearch_dashboards_saml.yml new file mode 100755 index 00000000..10c10f03 --- /dev/null +++ b/docker/config/2.x/osd/opensearch_dashboards_saml.yml @@ -0,0 +1,30 @@ +server.host: 0.0.0.0 +server.port: 5601 +opensearch.hosts: https://os1:9200 +opensearch.ssl.verificationMode: certificate +#osd 1.2.4 +# opensearch.requestHeadersWhitelist: ["securitytenant","Authorization"] +# +# osd 2.0 +opensearch.requestHeadersAllowlist: ["securitytenant", "Authorization"] +# +opensearch_security.multitenancy.enabled: false +opensearch_security.readonly_mode.roles: ["kibana_read_only"] +server.ssl.enabled: true +server.ssl.key: "/home/node/kbn/certs/osd.key" +server.ssl.certificate: "/home/node/kbn/certs/osd.pem" +opensearch.ssl.certificateAuthorities: ["/home/node/kbn/certs/ca.pem"] +uiSettings.overrides.defaultRoute: /app/reports-dashboards +opensearch.username: "kibanaserver" +opensearch.password: "kibanaserver" + +opensearch_security.auth.type: "saml" +server.xsrf.allowlist: + [ + /_plugins/_security/saml/acs, + /_opendistro/_security/saml/acs, + /_plugins/_security/saml/acs/idpinitiated, + /_opendistro/_security/saml/acs/idpinitiated, + /_plugins/_security/saml/logout, + /_opendistro/_security/saml/logout, + ] diff --git a/docker/config/2.x/osd/wazuh.yml b/docker/config/2.x/osd/wazuh.yml new file mode 100755 index 00000000..421c58b1 --- /dev/null +++ b/docker/config/2.x/osd/wazuh.yml @@ -0,0 +1,22 @@ +hosts: + - manager: + url: 'https://wazuh.manager' + port: 55000 + username: wazuh-wui + password: MyS3cr37P450r.*- + run_as: false + - imposter: + url: 'http://imposter' + port: 8080 + username: wazuh-wui + password: MyS3cr37P450r.*- + run_as: false + - imposter-cli: + url: 'http://' + port: 8080 + username: wazuh-wui + password: MyS3cr37P450r.*- + run_as: false + + +wazuh.updates.disabled: true diff --git a/docker/config/2.x/wm/wazuh_manager.conf b/docker/config/2.x/wm/wazuh_manager.conf new file mode 100755 index 00000000..aff1af9d --- /dev/null +++ b/docker/config/2.x/wm/wazuh_manager.conf @@ -0,0 +1,353 @@ + + + yes + yes + no + no + no + smtp.example.wazuh.com + wazuh@example.wazuh.com + recipient@example.wazuh.com + 12 + alerts.log + 10m + 0 + + + + 3 + 12 + + + + + plain + + + + secure + 1514 + tcp + 131072 + + + + + no + yes + yes + yes + yes + yes + yes + yes + + + 43200 + + etc/rootcheck/rootkit_files.txt + etc/rootcheck/rootkit_trojans.txt + + 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 + + + + 10 + + + + + yes + yes + 12h + yes + + + + no + 5m + 6h + yes + + + + no + trusty + xenial + bionic + focal + 1h + + + + + no + stretch + buster + bullseye + 1h + + + + + no + 5 + 6 + 7 + 8 + 1h + + + + + no + amazon-linux + amazon-linux-2 + 1h + + + + + no + 1h + + + + + yes + 1h + + + + + yes + 2010 + 1h + + + + + + + no + + + 43200 + + yes + + + yes + + + no + + + /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 + + + .log$|.swp$ + + + /etc/ssl/private.key + + yes + yes + yes + yes + + + 10 + + + 100 + + + + yes + 5m + 1h + 10 + + + + + + 127.0.0.1 + ^localhost.localdomain$ + 10.0.0.106 + + + + disable-account + disable-account + yes + + + + restart-wazuh + restart-wazuh + + + + firewall-drop + firewall-drop + yes + + + + host-deny + host-deny + yes + + + + route-null + route-null + yes + + + + win_route-null + route-null.exe + yes + + + + netsh + netsh.exe + 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 + + + + + ruleset/decoders + ruleset/rules + 0215-policy_rules.xml + etc/lists/audit-keys + etc/lists/amazon/aws-eventnames + etc/lists/security-eventchannel + + + etc/decoders + etc/rules + + + + yes + 1 + 64 + 15m + + + + + no + 1515 + no + yes + no + HIGH:!ADH:!EXP:!MD5:!RC4:!3DES:!CAMELLIA:@STRENGTH + + no + etc/sslmanager.cert + etc/sslmanager.key + no + + + + wazuh + node01 + master + + 1516 + 0.0.0.0 + + NODE_IP + + no + yes + + + + + + + syslog + /var/ossec/logs/active-responses.log + + + diff --git a/docker/config/enable_saml.sh b/docker/config/enable_saml.sh new file mode 100755 index 00000000..89d77617 --- /dev/null +++ b/docker/config/enable_saml.sh @@ -0,0 +1,160 @@ +#!/bin/bash + +# idp container launches and docker-compose returns too quickly, do not wait +# for container to be healthy as it has no dependencies, so we wait before +# continuing +sleep 7 + +indexer="$1-os1-1" +dashboard="$1-osd-1" + +# Setup keycloack to be used with wazuh-dashboards + +# Connection +U="admin" +P="admin" +B="http://idp:8080" + +# Realm +REALM="master" + +# Get ACCESS_TOKEN from default install +ACCESS_TOKEN=$(curl -sS \ + -d 'client_id=admin-cli' \ + -d 'username=admin' \ + -d 'password=admin' \ + -d 'grant_type=password' \ + "${B}/realms/master/protocol/openid-connect/token" | jq -r '.access_token') + +H=('-H' 'Content-Type: application/json' '-H' "Authorization: Bearer $ACCESS_TOKEN") + +# Create new REALM +REALM="wazuh" +P='{ + "id": "wazuh", + "realm": "wazuh", + "enabled": true +}' + +curl -sS -L -X POST "${B}/admin/realms" "${H[@]}" -d "$P" | grep -v "Conflict detected" + +# Add admin certificates to keycloak as these are used by indexer to sign saml +# messages. These should be uploaded to keycloak if we want it to verify indexer +# messages. +key=$(cat /certs/wi/admin-key.pem | grep -v "PRIVATE KEY" | tr -d "\n") +cert=$(cat /certs/wi/admin.pem | grep -v CERTIFICATE | tr -d "\n") + +# Create client +# By default the client does not verify the client signature on saml messages +# but it could be enabled for testing purposes +PC="{ + \"protocol\": \"saml\", + \"name\": \"wazuh\", + \"clientId\": \"wazuh\", + \"description\": \"wazuh saml integration\", + \"baseUrl\": \"https://localhost:5601\", + \"rootUrl\": \"https://localhost:5601\", + \"redirectUris\": [\"https://localhost:5601/*\"], + \"attributes\" : { + \"saml_single_logout_service_url_redirect\": \"https://localhost:5601/_opendistro/_security/saml/logout\", + \"saml_assertion_consumer_url_post\": \"https://localhost:5601/_opendistro/_security/saml/acs/idpinitiated\", + \"saml_single_logout_service_url_post\": \"https://wazuh.dashboard:5601/_opendistro/_security/saml/logout\", + \"saml.force.post.binding\": \"false\", + \"saml.signing.certificate\": \"$cert\", + \"saml.signing.private.key\": \"$key\", + \"saml.client.signature\": \"true\", + \"saml_single_logout_service_url_redirect\": \"https://localhost:5601\", + \"post.logout.redirect.uris\": \"https://localhost:5601*\" + } +}" + +curl -sS -L -X POST "${B}/admin/realms/${REALM}/clients" "${H[@]}" -d "$PC" | grep -v "Client wazuh already exists" + +# Get a client json representation +CLIENT=$(curl -sS -L -X GET "${B}/admin/realms/${REALM}/clients" "${H[@]}" -G -d 'clientId=wazuh' | jq '.[] | select(.clientId=="wazuh")') + +# Get client id +CID=$(echo $CLIENT | jq -r '.id') + +# Generate all-access and admin role for the realm +PR1='{ + "name":"all-access" +}' + +curl -sS -L -X POST "${B}/admin/realms/${REALM}/roles" "${H[@]}" -d "$PR1" | grep -v "Role with name all-access already exists" + +PR2='{ + "name":"admin" +}' + +curl -sS -L -X POST "${B}/admin/realms/${REALM}/roles" "${H[@]}" -d "$PR2" | grep -v "Role with name admin already exists" + +## create new user +PU='{ + "username": "wazuh", + "email": "hello@wazuh.com", + "firstName": "Wazuh", + "lastName": "Wazuh", + "emailVerified": true, + "enabled": true, + "credentials": [{"temporary":false,"type":"password","value":"wazuh"}], + "realmRoles": ["admin", "all-access"] +}' + +curl -sS -L -X POST "${B}/admin/realms/${REALM}/users" "${H[@]}" -d "$PU" | grep -v "User exists with same username" + +## Get a user json representation +USER=$(curl -sS -L -X GET "${B}/admin/realms/${REALM}/users" "${H[@]}" -G -d 'username=wazuh' | jq '.[] | select(.username=="wazuh")') + +### Get user id +USERID=$(echo $USER | jq -r '.id') + +# Get roles +ROLES=$(curl -sS -L -X GET "${B}/admin/realms/${REALM}/roles" "${H[@]}" -d "$PR2") + +## Assign role +ADMINID=$(echo $ROLES | jq -r '.[] | select(.name=="admin").id') +ALLACCESSID=$(echo $ROLES | jq -r '.[] | select(.name=="all-access").id') + +PA1="[ + { + \"id\": \"$ADMINID\", + \"name\": \"admin\", + \"composite\": false, + \"clientRole\": false, + \"containerId\": \"wazuh\" + }, + { + \"id\": \"$ALLACCESSID\", + \"name\": \"all-access\", + \"description\": \"\", + \"composite\": false, + \"clientRole\": false, + \"containerId\": \"wazuh\" + } +]" + +curl -sS -L -X POST "${B}/admin/realms/${REALM}/users/${USERID}/role-mappings/realm" "${H[@]}" -d "$PA1" + +# Get list of client scopes +CSCOPES=$(curl -sS -L -X GET "${B}/admin/realms/${REALM}/client-scopes" "${H[@]}") +CSID=$(echo $CSCOPES | jq -r '.[] | select(.name=="role_list").id ') +CSR=$(echo $CSCOPES | jq -r '.[] | select(.name=="role_list") ') + +# Set single to true, so opensearch works +UPDATE=$(echo $CSR | jq '.protocolMappers[] | select(.name=="role list").config.single |= "true" ') +PMID=$(echo $CSR | jq -r '.protocolMappers[] | select(.name=="role list").id') + +curl -sS -L -X PUT "${B}/admin/realms/${REALM}/client-scopes/$CSID/protocol-mappers/models/$PMID" "${H[@]}" -d "$UPDATE" + +# Set up auth realm on opensearch +certs="/usr/share/opensearch/config/certs" +ca="$certs/ca.pem" +cert="$certs/admin.pem" +key="$certs/admin-key.pem" + +securityadmin="bash /usr/share/opensearch/plugins/opensearch-security/tools/securityadmin.sh" +config_path="/usr/share/opensearch/config/opensearch-security" + +echo "To update configuration in indexer, you can run:" +echo docker exec -e JAVA_HOME=/usr/share/opensearch/jdk $indexer $securityadmin -cacert $ca -cert $cert -key $key -cd $config_path diff --git a/docker/dev.sh b/docker/dev.sh new file mode 100755 index 00000000..e16ce7d5 --- /dev/null +++ b/docker/dev.sh @@ -0,0 +1,155 @@ +#!/bin/bash + +usage() { + echo + echo "./dev.sh [-os os_version] [-osd osd_version] /wazuh_app_src action [saml/server] [server_version]" + echo + echo "where" + echo " -o os_version Specify the OS version (optional)" + echo " -d osd_version Specify the OSD version (optional)" + echo " wazuh_app_src is the path to the wazuh application source code" + echo " action is one of up | down | stop" + echo " saml to deploy a saml enabled environment (optional)" + echo " server to deploy a real server enabled environment (optional)" + exit -1 +} + +exit_with_message() { + echo $1 + exit -1 +} + +if ! command -v jq &> /dev/null; then + echo "[ERROR] jq is not installed. Please install jq to continue." + echo "sudo apt-get install jq in Debian/Ubuntu OS" + echo "sudo yum install jq in RedHat/CentOS OS" + echo "sudo pacman -Sy --noconfirm jq in Arch OS" + echo "brew install jq in MAC OS" + exit 1 +fi + +PACKAGE_PATH="../opensearch_dashboards.json" +os_version="" +osd_version="" + +while getopts ":o:d:" opt; do + case ${opt} in + o) + os_version=$OPTARG + ;; + d) + osd_version=$OPTARG + ;; + \?) + echo "Invalid option: -$OPTARG" >&2 + exit 1 + ;; + :) + echo "The -$OPTARG option requires an argument." >&2 + exit 1 + ;; + esac +done +shift $((OPTIND - 1)) + +if [ -z "$os_version" ] || [ -z "$osd_version" ]; then + if [ ! -f $PACKAGE_PATH ]; then + echo "[ERROR] The file package.json was not found." + exit 1 + fi + + if [ -z "$os_version" ]; then + echo "[INFO] OS Version not received via flag, getting the version from $PACKAGE_PATH" + os_version=$(jq -r '.opensearchDashboardsVersion' $PACKAGE_PATH) + if [ -z "$os_version" ]; then + echo "[ERROR] Could not retrieve the OS version from package.json." + exit 1 + fi + fi + + if [ -z "$osd_version" ]; then + echo "[INFO] OSD Version not received via flag, getting the version from $PACKAGE_PATH" + osd_version=$(jq -r '.opensearchDashboardsVersion' $PACKAGE_PATH) + if [ -z "$osd_version" ]; then + echo "[ERROR] Could not retrieve the OSD version from package.json." + exit 1 + fi + fi +fi + +if [ $# -lt 2 ]; then + echo "[ERROR] Incorrect number of arguments " $# ", got " $@ + echo + usage +fi + +if [[ $1 != /* ]]; then + echo "[ERROR] Source path must be absolute, and start with /" + echo + usage + exit +fi + +export PASSWORD=${PASSWORD:-admin} +export OS_VERSION=$os_version +export OSD_VERSION=$osd_version +export OSD_PORT=${PORT:-5601} +export IMPOSTER_VERSION=3.44.1 +export SRC=$1 +export OSD_MAJOR_NUMBER=$(echo $OSD_VERSION | cut -d. -f1) +export COMPOSE_PROJECT_NAME=os-dev-${OSD_VERSION//./} +export WAZUH_STACK="" + +if [[ "$OSD_MAJOR_NUMBER" -ge 2 ]]; then + export OSD_MAJOR="2.x" +else + export OSD_MAJOR="1.x" +fi + +profile="standard" +export WAZUH_DASHBOARD_CONF=./config/${OSD_MAJOR}/osd/opensearch_dashboards.yml +export SEC_CONFIG_FILE=./config/${OSD_MAJOR}/os/config.yml + +export SEC_CONFIG_PATH=/usr/share/opensearch/plugins/opensearch-security/securityconfig +if [[ "$OSD_MAJOR" == "2.x" ]]; then + export SEC_CONFIG_PATH=/usr/share/opensearch/config/opensearch-security +fi + +case "$2" in +up) + /bin/bash ../scripts/create_docker_networks.sh + docker compose --profile $profile -f dev.yml up -Vd + + # Display a command to deploy an agent when using the real server + if [[ "$3" =~ "server" ]]; then + echo + echo "**************WARNING**************" + echo "The agent version must be a published one. This uses only released versions." + echo "If you need to change de version, edit the command as you see fit." + echo "***********************************" + echo "1. (Optional) Enroll an agent (Ubuntu 20.04):" + echo "docker run --name ${COMPOSE_PROJECT_NAME}-agent-\$(date +%s) --network os-dev-${OS_VERSION} --label com.docker.compose.project=${COMPOSE_PROJECT_NAME} --env WAZUH_AGENT_VERSION=${WAZUH_STACK} -d ubuntu:20.04 bash -c '" + echo " apt update -y" + echo " apt install -y curl lsb-release" + echo " curl -so \wazuh-agent-\${WAZUH_AGENT_VERSION}.deb \\" + echo " https://packages.wazuh.com/4.x/apt/pool/main/w/wazuh-agent/wazuh-agent_\${WAZUH_AGENT_VERSION}-1_amd64.deb \\" + echo " && WAZUH_MANAGER='wazuh.manager' WAZUH_AGENT_GROUP='default' dpkg -i ./wazuh-agent-\${WAZUH_AGENT_VERSION}.deb" + echo + echo " /etc/init.d/wazuh-agent start" + echo " tail -f /var/ossec/logs/ossec.log" + echo "'" + echo + fi + ;; + down) + docker compose --profile $profile -f dev.yml down -v --remove-orphans + ;; + stop) + docker compose --profile $profile -f dev.yml -p ${COMPOSE_PROJECT_NAME} stop + ;; + *) + echo "[ERROR] Action must be up | down | stop: " + echo + usage + ;; +esac diff --git a/docker/dev.yml b/docker/dev.yml new file mode 100755 index 00000000..2b199886 --- /dev/null +++ b/docker/dev.yml @@ -0,0 +1,243 @@ +version: '2.2' + +# x-logging: &logging +# logging: +# driver: loki +# options: +# loki-url: 'http://host.docker.internal:3100/loki/api/v1/push' + +services: + exporter: + image: quay.io/prometheuscommunity/elasticsearch-exporter:latest + + # <<: *logging + + hostname: exporter-osd-${OS_VERSION} + profiles: + - 'standard' + networks: + - os-dev + - mon + command: + - '--es.uri=https://admin:${PASSWORD}@os1:9200' + - '--es.ssl-skip-verify' + - '--es.all' + + generator: + image: cfssl/cfssl + + # <<: *logging + profiles: + - 'server' + - 'saml' + - 'standard' + volumes: + - wi_certs:/certs/wi + - wd_certs:/certs/wd + - wm_certs:/certs/wm + - idp_certs:/certs/idp + - ./config/${OSD_MAJOR}/certs:/conf + - os_logs:/logs + - os_data:/data + # Included to avoid docker from creating duplicated networks + networks: + - os-dev + entrypoint: /bin/bash + command: > + -c ' + export certs=/tmp/certs + mkdir $$certs + cd $$certs + + echo "Generating CA" + cfssl gencert -initca /conf/ca.json | cfssljson -bare ca + + echo "Generating servers certificates" + for i in os1 osd imposter; do + echo "Generating cert for $$i" + cat /conf/host.json | \ + sed "s/HOST/$$i/g" | \ + cfssl gencert \ + -ca $$certs/ca.pem \ + -ca-key $$certs/ca-key.pem \ + -config /conf/cfssl.json \ + -profile=server - | \ + cfssljson -bare $$i + openssl pkcs8 -topk8 -inform pem -in $$i-key.pem -outform pem -nocrypt -out $$i.key + done + + echo "Generating clients certificates" + for i in admin filebeat saml; do + echo "Generating cert for $$i" + cat /conf/host.json | \ + sed "s/HOST/$$i/g" | \ + cfssl gencert \ + -ca $$certs/ca.pem \ + -ca-key $$certs/ca-key.pem \ + -config /conf/cfssl.json \ + -profile=client - | \ + cfssljson -bare $$i + openssl pkcs8 -topk8 -inform pem -in $$i-key.pem -outform pem -nocrypt -out $$i.key + done + + echo "Setting up permissions" + + rm /certs/wi/* /certs/wd/* /certs/wm/* + + mv $$certs/os1* /certs/wi + mv $$certs/admin* /certs/wi + mv /certs/wi/admin.key /certs/wi/admin-key.pem + cp $$certs/*ca* /certs/wi + + mv $$certs/osd* /certs/wd + cp $$certs/*ca* /certs/wd + + mv $$certs/saml* /certs/idp + mv /certs/idp/saml.key /certs/idp/saml-key.pem + cp $$certs/*ca* /certs/idp + + mv $$certs/*.* /certs/wm + + chmod 640 /certs/wi/* /certs/wd/* /certs/wm/* + chown -R 1000:1000 /certs/* + ls -alR /certs/ + + chown 1000:1000 /data /logs + chmod 775 /data /logs + sleep 300 + ' + healthcheck: + test: ['CMD-SHELL', '[ -r /certs/wi/os1.pem ]'] + interval: 2s + timeout: 5s + retries: 10 + + os1: + image: opensearchproject/opensearch:${OS_VERSION} + + # <<: *logging + profiles: + - 'standard' + environment: + - cluster.name=os-dev-cluster + - node.name=os1 + - discovery.seed_hosts=os1 + - cluster.initial_master_nodes=os1 + - bootstrap.memory_lock=true # along with the memlock settings below, disables swapping + - 'OPENSEARCH_JAVA_OPTS=-Xms512m -Xmx512m' # minimum and maximum Java heap size, recommend setting both to 50% of system RAM + - OPENSEARCH_PATH_CONF=/usr/share/opensearch/config/ + ulimits: + memlock: + soft: -1 + hard: -1 + nofile: + soft: 65536 # maximum number of open files for the OpenSearch user, set to at least 65536 on modern systems + hard: 65536 + volumes: + - wi_certs:/usr/share/opensearch/config/certs/ + - ./config/${OSD_MAJOR}/os/opensearch.yml:/usr/share/opensearch/config/opensearch.yml + - ./config/${OSD_MAJOR}/os/internal_users.yml:${SEC_CONFIG_PATH}/internal_users.yml + - ${SEC_CONFIG_FILE}:${SEC_CONFIG_PATH}/config.yml + - ./config/${OSD_MAJOR}/os/roles_mapping.yml:${SEC_CONFIG_PATH}/roles_mapping.yml + - ./config/${OSD_MAJOR}/os/roles.yml:${SEC_CONFIG_PATH}/roles.yml + + - os_logs:/var/log/os1 + - os_data:/var/lib/os1 + ports: + - 9200:9200 + - 9300:9300 + networks: + - os-dev + - mon + healthcheck: + test: + [ + 'CMD-SHELL', + "curl -v --cacert config/certs/ca.pem https://os1:9200 2>&1 | grep -q '401 Unauthorized'", + ] + interval: 1s + timeout: 5s + retries: 120 + + filebeat: + depends_on: + os1: + condition: service_healthy + image: elastic/filebeat:7.10.2 + profiles: + - 'standard' + hostname: filebeat + user: '0:0' + networks: + - os-dev + - mon + + # <<: *logging + # restart: always + entrypoint: + - '/bin/bash' + command: > + -c ' + mkdir -p /etc/filebeat + echo admin | filebeat keystore add username --stdin --force + echo ${PASSWORD}| filebeat keystore add password --stdin --force + curl -so /etc/filebeat/wazuh-template.json https://raw.githubusercontent.com/wazuh/wazuh/v4.7.2/extensions/elasticsearch/7.x/wazuh-template.json + curl -s https://packages.wazuh.com/4.x/filebeat/wazuh-filebeat-0.3.tar.gz | tar -xvz -C /usr/share/filebeat/module + # copy filebeat to preserve correct permissions without + # affecting host filesystem + cp /tmp/filebeat.yml /usr/share/filebeat/filebeat.yml + chown root.root /usr/share/filebeat/filebeat.yml + chmod go-w /usr/share/filebeat/filebeat.yml + filebeat setup -e + filebeat + ' + volumes: + - wm_certs:/etc/ssl/elastic + - ./config/${OSD_MAJOR}/filebeat/filebeat.yml:/tmp/filebeat.yml + + osd: + depends_on: + os1: + condition: service_healthy + image: quay.io/wazuh/osd-dev:${OSD_VERSION} + profiles: + - 'standard' + hostname: osd + networks: + - os-dev + - devel + - mon + user: '1000:1000' + + # <<: *logging + ports: + - ${OSD_PORT}:5601 + environment: + - 'LOGS=/proc/1/fd/1' + entrypoint: ['tail', '-f', '/dev/null'] + volumes: + - osd_cache:/home/node/.cache + - '${SRC}:/home/node/kbn/plugins/dashboards-reporting' + - wd_certs:/home/node/kbn/certs/ + - ${WAZUH_DASHBOARD_CONF}:/home/node/kbn/config/opensearch_dashboards.yml + - ./config/${OSD_MAJOR}/osd/wazuh.yml:/home/node/kbn/data/wazuh/config/wazuh.yml + +networks: + os-dev: + name: os-dev-${OS_VERSION} + driver: bridge + mon: + external: true + devel: + external: true + +volumes: + osd_cache: + certs: + os_logs: + os_data: + wi_certs: + wd_certs: + wm_certs: + idp_certs: + keycloak-data: diff --git a/public/plugin.ts b/public/plugin.ts index 553bc082..b41de3bf 100644 --- a/public/plugin.ts +++ b/public/plugin.ts @@ -32,11 +32,10 @@ export class ReportsDashboardsPlugin defaultMessage: PLUGIN_NAME, }), category: { - id: 'opensearch', - label: i18n.translate('opensearch.reports.categoryName', { - defaultMessage: 'OpenSearch Plugins', - }), - order: 2000, + id: 'explore', + label: 'Explore', + order: 100, + euiIconType: 'search' }, order: 2000, async mount(params: AppMountParameters) {