diff --git a/salt/filebeat/etc/filebeat.yml b/salt/filebeat/etc/filebeat.yml index 0da9b68bc..4706e4c5a 100644 --- a/salt/filebeat/etc/filebeat.yml +++ b/salt/filebeat/etc/filebeat.yml @@ -3,6 +3,7 @@ {%- set BROVER = salt['pillar.get']('static:broversion', 'COMMUNITY') %} {%- set WAZUHENABLED = salt['pillar.get']('static:wazuh_enabled', '1') %} {%- set FLEETENABLED = salt['pillar.get']('static:fleet_enabled', '1') %} +{%- set STRELKAENABLED = salt['pillar.get']('static:strelka_enabled', '1') %} name: {{ HOSTNAME }} @@ -126,6 +127,19 @@ filebeat.prospectors: clean_removed: false close_removed: false +{%- endif %} + +{%- if STRELKAENABLED == '1' %} + + - type: log + paths: + - /opt/so/log/strelka/strelka.log + fields: + type: strelka + fields_under_root: true + clean_removed: false + close_removed: false + {%- endif %} #----------------------------- Logstash output --------------------------------- output.logstash: diff --git a/salt/strelka/files/backend/backend.yaml b/salt/strelka/files/backend/backend.yaml new file mode 100644 index 000000000..40ea1b5b3 --- /dev/null +++ b/salt/strelka/files/backend/backend.yaml @@ -0,0 +1,423 @@ +{%- set ip = salt['pillar.get']('static:masterip', '') %} +logging_cfg: '/etc/strelka/logging.yaml' +limits: + max_files: 5000 + time_to_live: 900 + max_depth: 15 + distribution: 600 + scanner: 150 +coordinator: + addr: '{{ ip }}:6380' + db: 0 +tasting: + mime_db: null + yara_rules: '/etc/strelka/taste/' +scanners: + 'ScanBase64': + - positive: + filename: '^base64_' + priority: 5 + 'ScanBatch': + - positive: + flavors: + - 'text/x-msdos-batch' + - 'batch_file' + priority: 5 + 'ScanBzip2': + - positive: + flavors: + - 'application/x-bzip2' + - 'bzip2_file' + priority: 5 + 'ScanDocx': + - positive: + flavors: + - 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' + priority: 5 + options: + extract_text: False + 'ScanElf': + - positive: + flavors: + - 'application/x-object' + - 'application/x-executable' + - 'application/x-sharedlib' + - 'application/x-coredump' + - 'elf_file' + priority: 5 + 'ScanEmail': + - positive: + flavors: + - 'application/vnd.ms-outlook' + - 'message/rfc822' + - 'email_file' + priority: 5 + 'ScanEntropy': + - positive: + flavors: + - '*' + priority: 5 + 'ScanExiftool': + - positive: + flavors: + - 'application/msword' + - 'application/vnd.openxmlformats-officedocument' + - 'application/vnd.openxmlformats-officedocument.presentationml.presentation' + - 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' + - 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' + - 'olecf_file' + - 'ooxml_file' + - 'audio/mpeg' + - 'mp3_file' + - 'mhtml_file' + - 'application/pdf' + - 'pdf_file' + - 'text/rtf' + - 'rtf_file' + - 'wordml_file' + - 'application/x-dosexec' + - 'mz_file' + - 'application/x-object' + - 'application/x-executable' + - 'application/x-sharedlib' + - 'application/x-coredump' + - 'elf_file' + - 'lnk_file' + - 'application/x-mach-binary' + - 'macho_file' + - 'image/gif' + - 'gif_file' + - 'image/jpeg' + - 'jpeg_file' + - 'image/png' + - 'png_file' + - 'image/tiff' + - 'type_is_tiff' + - 'image/x-ms-bmp' + - 'bmp_file' + - 'application/x-shockwave-flash' + - 'fws_file' + - 'psd_file' + - 'video/mp4' + - 'video/quicktime' + - 'video/x-msvideo' + - 'avi_file' + - 'video/x-ms-wmv' + - 'wmv_file' + priority: 5 + options: + tmp_directory: '/dev/shm/' + 'ScanGif': + - positive: + flavors: + - 'image/gif' + - 'gif_file' + priority: 5 + 'ScanGzip': + - positive: + flavors: + - 'application/gzip' + - 'application/x-gzip' + - 'gzip_file' + priority: 5 + 'ScanHash': + - positive: + flavors: + - '*' + priority: 5 + 'ScanHeader': + - positive: + flavors: + - '*' + priority: 5 + options: + length: 50 + 'ScanHtml': + - positive: + flavors: + - 'hta_file' + - 'text/html' + - 'html_file' + priority: 5 + options: + parser: "html5lib" + 'ScanIni': + - positive: + filename: '(\.([Cc][Ff][Gg]|[Ii][Nn][Ii])|PROJECT)$' + flavors: + - 'ini_file' + priority: 5 + 'ScanJarManifest': + - positive: + flavors: + - 'jar_manifest_file' + priority: 5 + 'ScanJavascript': + - negative: + flavors: + - 'text/html' + - 'html_file' + positive: + flavors: + - 'javascript_file' + - 'text/javascript' + priority: 5 + options: + beautify: True + 'ScanJpeg': + - positive: + flavors: + - 'image/jpeg' + - 'jpeg_file' + priority: 5 + 'ScanJson': + - positive: + flavors: + - 'application/json' + - 'json_file' + priority: 5 + 'ScanLibarchive': + - positive: + flavors: + - 'application/vnd.ms-cab-compressed' + - 'cab_file' + - 'application/x-7z-compressed' + - '_7zip_file' + - 'application/x-cpio' + - 'cpio_file' + - 'application/x-xar' + - 'xar_file' + - 'arj_file' + - 'iso_file' + - 'application/x-debian-package' + - 'debian_package_file' + priority: 5 + options: + limit: 1000 + 'ScanLzma': + - positive: + flavors: + - 'application/x-lzma' + - 'lzma_file' + - 'application/x-xz' + - 'xz_file' + priority: 5 + 'ScanMacho': + - positive: + flavors: + - 'application/x-mach-binary' + - 'macho_file' + priority: 5 + options: + tmp_directory: '/dev/shm/' + 'ScanMmbot': + - positive: + flavors: + - 'vb_file' + - 'vbscript' + priority: 5 + options: + server: 'strelka_mmrpc_1:33907' + 'ScanOcr': + - positive: + flavors: + - 'image/jpeg' + - 'jpeg_file' + - 'image/png' + - 'png_file' + - 'image/tiff' + - 'type_is_tiff' + - 'image/x-ms-bmp' + - 'bmp_file' + priority: 5 + options: + extract_text: False + tmp_directory: '/dev/shm/' + 'ScanOle': + - positive: + flavors: + - 'application/CDFV2' + - 'application/msword' + - 'olecf_file' + priority: 5 + 'ScanPdf': + - positive: + flavors: + - 'application/pdf' + - 'pdf_file' + priority: 5 + options: + extract_text: False + limit: 2000 + 'ScanPe': + - positive: + flavors: + - 'application/x-dosexec' + - 'mz_file' + priority: 5 + 'ScanPgp': + - positive: + flavors: + - 'application/pgp-keys' + - 'pgp_file' + priority: 5 + 'ScanPhp': + - positive: + flavors: + - 'text/x-php' + - 'php_file' + priority: 5 + 'ScanPkcs7': + - positive: + flavors: + - 'pkcs7_file' + priority: 5 + options: + tmp_directory: '/dev/shm/' + 'ScanPlist': + - positive: + flavors: + - 'bplist_file' + - 'plist_file' + priority: 5 + options: + keys: + - 'KeepAlive' + - 'Label' + - 'NetworkState' + - 'Program' + - 'ProgramArguments' + - 'RunAtLoad' + - 'StartInterval' + 'ScanRar': + - positive: + flavors: + - 'application/x-rar' + - 'rar_file' + priority: 5 + options: + limit: 1000 + 'ScanRpm': + - positive: + flavors: + - 'application/x-rpm' + - 'rpm_file' + priority: 5 + options: + tmp_directory: '/dev/shm/' + 'ScanRtf': + - positive: + flavors: + - 'text/rtf' + - 'rtf_file' + priority: 5 + options: + limit: 1000 + 'ScanRuby': + - positive: + flavors: + - 'text/x-ruby' + priority: 5 + 'ScanSwf': + - positive: + flavors: + - 'application/x-shockwave-flash' + - 'fws_file' + - 'cws_file' + - 'zws_file' + priority: 5 + 'ScanTar': + - positive: + flavors: + - 'application/x-tar' + - 'tar_file' + priority: 5 + options: + limit: 1000 + 'ScanTnef': + - positive: + flavors: + - 'application/vnd.ms-tnef' + - 'tnef_file' + priority: 5 + 'ScanUpx': + - positive: + flavors: + - 'upx_file' + priority: 5 + options: + tmp_directory: '/dev/shm/' + 'ScanUrl': + - negative: + flavors: + - 'javascript_file' + positive: + flavors: + - 'text/plain' + priority: 5 + 'ScanVb': + - positive: + flavors: + - 'vb_file' + - 'vbscript' + priority: 5 + 'ScanVba': + - positive: + flavors: + - 'mhtml_file' + - 'application/msword' + - 'olecf_file' + - 'wordml_file' + priority: 5 + options: + analyze_macros: True + 'ScanX509': + - positive: + flavors: + - 'x509_der_file' + priority: 5 + options: + type: 'der' + - positive: + flavors: + - 'x509_pem_file' + priority: 5 + options: + type: 'pem' + 'ScanXml': + - positive: + flavors: + - 'application/xml' + - 'text/xml' + - 'xml_file' + - 'mso_file' + - 'soap_file' + priority: 5 + 'ScanYara': + - positive: + flavors: + - '*' + priority: 5 + options: + location: '/etc/yara/' + 'ScanZip': + - positive: + flavors: + - 'application/java-archive' + - 'application/zip' + - 'zip_file' + - 'application/vnd.openxmlformats-officedocument' + - 'application/vnd.openxmlformats-officedocument.presentationml.presentation' + - 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' + - 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' + - 'ooxml_file' + priority: 5 + options: + limit: 1000 + password_file: '/etc/strelka/passwords.dat' + 'ScanZlib': + - positive: + flavors: + - 'application/zlib' + - 'zlib_file' + priority: 5 diff --git a/salt/strelka/files/backend/logging.yaml b/salt/strelka/files/backend/logging.yaml new file mode 100644 index 000000000..b21d3c396 --- /dev/null +++ b/salt/strelka/files/backend/logging.yaml @@ -0,0 +1,78 @@ +version: 1 +formatters: + simple: + format: '%(asctime)s - [%(levelname)s] %(name)s [%(module)s.%(funcName)s]: %(message)s' + datefmt: '%Y-%m-%d %H:%M:%S' +handlers: + console: + class: logging.StreamHandler + formatter: simple + stream: ext://sys.stdout +root: + level: DEBUG + handlers: [console] +loggers: + OpenSSL: + propagate: 0 + bs4: + propagate: 0 + bz2: + propagate: 0 + chardet: + propagate: 0 + docx: + propagate: 0 + elftools: + propagate: 0 + email: + propagate: 0 + entropy: + propagate: 0 + esprima: + propagate: 0 + gzip: + propagate: 0 + hashlib: + propagate: 0 + json: + propagate: 0 + libarchive: + propagate: 0 + lxml: + propagate: 0 + lzma: + propagate: 0 + macholibre: + propagate: 0 + olefile: + propagate: 0 + oletools: + propagate: 0 + pdfminer: + propagate: 0 + pefile: + propagate: 0 + pgpdump: + propagate: 0 + pygments: + propagate: 0 + pylzma: + propagate: 0 + rarfile: + propagate: 0 + requests: + propagate: 0 + rpmfile: + propagate: 0 + ssdeep: + propagate: 0 + tarfile: + propagate: 0 + tnefparse: + propagate: 0 + yara: + propagate: 0 + zipfile: + propagate: 0 + zlib: + propagate: 0 diff --git a/salt/strelka/files/backend/passwords.dat b/salt/strelka/files/backend/passwords.dat new file mode 100644 index 000000000..e9541f540 --- /dev/null +++ b/salt/strelka/files/backend/passwords.dat @@ -0,0 +1,2 @@ +infected +password diff --git a/salt/strelka/files/backend/taste/taste.yara b/salt/strelka/files/backend/taste/taste.yara new file mode 100644 index 000000000..15d2dffbb --- /dev/null +++ b/salt/strelka/files/backend/taste/taste.yara @@ -0,0 +1,748 @@ +// Archive Files + +rule _7zip_file +{ + meta: + type = "archive" + strings: + $a = { 37 7A BC AF 27 1C } + condition: + $a at 0 +} + +rule arj_file +{ + meta: + type = "archive" + condition: + uint16(0) == 0xEA60 +} + +rule cab_file +{ + meta: + type = "archive" + strings: + $a = { 4D 53 43 46 00 00 00 00 } + condition: + $a at 0 or + ( uint16(0) == 0x5A4D and $a ) +} + +rule cpio_file +{ + meta: + type = "archive" + strings: + $a = { 30 37 30 37 30 31 } + condition: + $a at 0 +} + +rule iso_file +{ + meta: + type = "archive" + strings: + $a = { 43 44 30 30 31 } + condition: + $a at 0x8001 and $a at 0x8801 and $a at 0x9001 +} + +rule mhtml_file +{ + meta: + type = "archive" + strings: + $a = "MIME-Version: 1.0" + $b = "This document is a Single File Web Page, also known as a Web Archive file" + condition: + $a at 0 and $b +} + +rule rar_file +{ + meta: + type = "archive" + condition: + uint16(0) == 0x6152 and uint8(2) == 0x72 and uint16(3) == 0x1A21 and uint8(5) == 0x07 +} + +rule tar_file +{ + meta: + type = "archive" + strings: + $a = { 75 73 74 61 72 } + condition: + uint16(0) == 0x9D1F or + uint16(0) == 0xA01F or + $a at 257 +} + +rule xar_file +{ + meta: + type = "archive" + condition: + uint32(0) == 0x21726178 +} + +rule zip_file +{ + meta: + type = "archive" + condition: + ( uint32(0) == 0x04034B50 and not uint32(4) == 0x00060014 ) +} + +// Audio Files + +rule mp3_file +{ + meta: + type = "audio" + condition: + uint16(0) == 0x4449 and uint8(2) == 0x33 +} + +// Certificate Files + +rule pkcs7_file +{ + meta: + type = "certificate" + strings: + $a = "-----BEGIN PKCS7-----" + condition: + (uint16(0) == 0x8230 and uint16(4) == 0x0906) or + uint32(0) == 0x09068030 or + $a at 0 +} + +rule x509_der_file +{ + meta: + type = "certificate" + condition: + uint16(0) == 0x8230 and ( uint16(4) == 0x8230 or uint16(4) == 0x8130 ) +} + +rule x509_pem_file +{ + meta: + type = "certificate" + strings: + $a = "-----BEGIN CERTI" + condition: + $a at 0 +} + +// Compressed Files + +rule bzip2_file +{ + meta: + type = "compressed" + condition: + uint16(0) == 0x5A42 and uint8(2) == 0x68 +} + +rule gzip_file +{ + meta: + type = "compressed" + condition: + uint16(0) == 0x8B1F and uint8(2) == 0x08 +} + +rule lzma_file +{ + meta: + type = "compressed" + condition: + uint16(0) == 0x005D and uint8(2) == 0x00 +} + +rule xz_file +{ + meta: + type = "compressed" + condition: + uint32(0) == 0x587A37FD and uint16(4) == 0x005A +} + +// Document Files + +rule doc_subheader_file +{ + meta: + type = "document" + condition: + uint32(0) == 0x00C1A5EC +} + +rule mso_file +{ + meta: + type = "document" + strings: + $a = { 3C 3F 6D 73 6F 2D 61 70 70 6C 69 63 61 74 69 6F 6E 20 } // + condition: + $a at 0 or + $b at 0 or + $c at 0 or + $d at 0 or + $e at 0 or + $f at 0 or + $g at 0 or + $h at 0 or + $i at 0 or + $j at 0 or + $k at 0 or + $l at 0 or + $m at 0 or + $n at 0 +} + +rule json_file +{ + meta: + type = "text" + strings: + $a = { 7B [0-5] 22 } + condition: + $a at 0 +} + +rule php_file +{ + meta: + type = "text" + strings: + $a = { 3c 3f 70 68 70 } + condition: + $a at 0 +} + +rule soap_file +{ + meta: + description = "Simple Object Access Protocol" + type = "text" + strings: + $a = { 3C 73 6F 61 70 65 6E 76 3A 45 6E 76 65 6C 6F 70 65 } // + $c = { 3C 73 74 79 6C 65 53 68 65 65 74 20 78 6D 6C 6E 73 3D } // . +{%- set MASTER = grains['master'] %} +{%- set MASTERIP = salt['pillar.get']('static:masterip', '') %} + +# Strelka config +strelkaconfdir: + file.directory: + - name: /opt/so/conf/strelka + - user: 939 + - group: 939 + - makedirs: True + +# Strelka logs +strelkalogdir: + file.directory: + - name: /opt/so/log/strelka + - user: 939 + - group: 939 + - makedirs: True + +# Sync dynamic config to conf dir +strelkasync: + file.recurse: + - name: /opt/so/conf/strelka/ + - source: salt://strelka/files + - user: 939 + - group: 939 + - template: jinja + +strelkadatadir: + file.directory: + - name: /nsm/strelka + - user: 939 + - group: 939 + - makedirs: True + +strelkastagedir: + file.directory: + - name: /nsm/strelka/processed + - user: 939 + - group: 939 + - makedirs: True + + +so-strelka-frontendimage: + cmd.run: + - name: docker pull --disable-content-trust=false docker.io/soshybridhunter/so-strelka-frontend:HH1.1.5 + +so-strelka-coordinatorimage: + cmd.run: + - name: docker pull --disable-content-trust=false docker.io/redis:5.0.5-alpine3.10 + +so-strelka-gatekeeperimage: + cmd.run: + - name: docker pull --disable-content-trust=false docker.io/redis:5.0.5-alpine3.10 + +so-strelka-backendimage: + cmd.run: + - name: docker pull --disable-content-trust=false docker.io/soshybridhunter/so-strelka-backend:HH1.1.5 + +so-strelka-managerimage: + cmd.run: + - name: docker pull --disable-content-trust=false docker.io/soshybridhunter/so-strelka-manager:HH1.1.5 + +so-strelka-backendimage: + cmd.run: + - name: docker pull --disable-content-trust=false docker.io/soshybridhunter/so-strelka-backend:HH1.1.5 + + +strelka_coordinator: + docker_container.running: + - require: + - so-strelka-coordinatorimage + - image: docker.io/redis:5.0.5-alpine3.10 + - name: so-strelka-coordinator + - command: redis-server --save "" --appendonly no + - port_bindings: + - 0.0.0.0:6380:6379 + +strelka_gatekeeper: + docker_container.running: + - require: + - so-strelka-gatekeeperimage + - image: docker.io/redis:5.0.5-alpine3.10 + - name: so-strelka-gatekeeper + - command: redis-server --save "" --appendonly no --maxmemory-policy allkeys-lru + - port_bindings: + - 0.0.0.0:6381:6379 + +strelka_frontend: + docker_container.running: + - require: + - so-strelka-frontendimage + - image: docker.io/soshybridhunter/so-strelka-frontend:HH1.1.5 + - binds: + - /opt/so/conf/strelka/frontend/:/etc/strelka/:ro + - /opt/so/log/strelka/:/var/log/strelka/:rw + - privileged: True + - name: so-strelka-frontend + - command: strelka-frontend + - port_bindings: + - 0.0.0.0:57314:57314 + +strelka_backend: + docker_container.running: + - require: + - so-strelka-backendimage + - image: docker.io/soshybridhunter/so-strelka-backend:HH1.1.5 + - restart_policy: unless-stopped + - binds: + - /opt/so/conf/strelka/backend/:/etc/strelka/:ro + - /opt/so/conf/strelka/backend/yara:/etc/yara/:ro + - name: so-strelka-backend + - command: strelka-backend + +strelka_manager: + docker_container.running: + - require: + - so-strelka-managerimage + - image: docker.io/soshybridhunter/so-strelka-manager:HH1.1.5 + - binds: + - /opt/so/conf/strelka/manager/:/etc/strelka/:ro + - name: so-strelka-manager + - command: strelka-manager + +strelka_filestream: + docker_container.running: + - require: + - so-strelka-filestreamimage + - image: docker.io/soshybridhunter/so-strelka-filestream:HH1.1.5 + - image: docker.io/wlambert/sfilestream:grpc + - binds: + - /opt/so/conf/strelka/filestream/:/etc/strelka/:ro + - /nsm/strelka:/nsm/strelka + - name: so-strelka-filestream + - command: strelka-filestream