mirror of
https://github.com/Security-Onion-Solutions/securityonion.git
synced 2025-12-07 17:52:46 +01:00
Merge pull request #264 from Security-Onion-Solutions/feature/bpf-suricata
Suricata - Initial bpf support
This commit is contained in:
37
salt/common/tools/sbin/so-bpf-compile
Normal file
37
salt/common/tools/sbin/so-bpf-compile
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Copyright 2014 Google Inc. All rights reserved.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
if [ "$#" -lt 2 ]; then
|
||||||
|
cat 1>&2 <<EOF
|
||||||
|
$0 compiles a BPF expression to be passed to stenotype to apply a socket filter.
|
||||||
|
Its first argument is the interface (link type is required) and all other arguments
|
||||||
|
are passed to TCPDump.
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
$0 eth0 dst port 80
|
||||||
|
$0 eth0 udp port 53
|
||||||
|
EOF
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
interface="$1"
|
||||||
|
shift
|
||||||
|
sudo tcpdump -i $interface -ddd $@ | tail -n+2 |
|
||||||
|
while read line; do
|
||||||
|
cols=( $line )
|
||||||
|
printf "%04x%02x%02x%08x" ${cols[0]} ${cols[1]} ${cols[2]} ${cols[3]}
|
||||||
|
done
|
||||||
|
echo ""
|
||||||
@@ -17,6 +17,8 @@
|
|||||||
{% set BROVER = salt['pillar.get']('static:broversion', '') %}
|
{% set BROVER = salt['pillar.get']('static:broversion', '') %}
|
||||||
{% set VERSION = salt['pillar.get']('static:soversion', 'HH1.1.4') %}
|
{% set VERSION = salt['pillar.get']('static:soversion', 'HH1.1.4') %}
|
||||||
{% set MASTER = salt['grains.get']('master') %}
|
{% set MASTER = salt['grains.get']('master') %}
|
||||||
|
{% set BPF_NIDS = salt['pillar.get']('nids:bpf') %}
|
||||||
|
|
||||||
|
|
||||||
# Suricata
|
# Suricata
|
||||||
|
|
||||||
@@ -80,6 +82,30 @@ surithresholding:
|
|||||||
- group: 940
|
- group: 940
|
||||||
- template: jinja
|
- template: jinja
|
||||||
|
|
||||||
|
# BPF compilation and configuration
|
||||||
|
{% if BPF_NIDS %}
|
||||||
|
{% set BPF_CALC = salt['cmd.script']('/usr/sbin/so-bpf-compile', interface + ' ' + BPF_NIDS|join(" ") ) %}
|
||||||
|
{% if BPF_CALC['stderr'] != "" %}
|
||||||
|
suribpfcompilationfailure:
|
||||||
|
test.configurable_test_state:
|
||||||
|
- changes: False
|
||||||
|
- result: False
|
||||||
|
- comment: "BPF Syntax Error - Discarding Specified BPF"
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
suribpf:
|
||||||
|
file.managed:
|
||||||
|
- name: /opt/so/conf/suricata/bpf
|
||||||
|
- user: 940
|
||||||
|
- group: 940
|
||||||
|
{% if BPF_CALC['stderr'] == "" %}
|
||||||
|
- contents_pillar: nids:bpf
|
||||||
|
{% else %}
|
||||||
|
- contents:
|
||||||
|
- ""
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
so-suricata:
|
so-suricata:
|
||||||
docker_container.running:
|
docker_container.running:
|
||||||
- image: {{ MASTER }}:5000/soshybridhunter/so-suricata:{{ VERSION }}
|
- image: {{ MASTER }}:5000/soshybridhunter/so-suricata:{{ VERSION }}
|
||||||
@@ -91,8 +117,10 @@ so-suricata:
|
|||||||
- /opt/so/conf/suricata/threshold.conf:/etc/suricata/threshold.conf:ro
|
- /opt/so/conf/suricata/threshold.conf:/etc/suricata/threshold.conf:ro
|
||||||
- /opt/so/conf/suricata/rules:/etc/suricata/rules:ro
|
- /opt/so/conf/suricata/rules:/etc/suricata/rules:ro
|
||||||
- /opt/so/log/suricata/:/var/log/suricata/:rw
|
- /opt/so/log/suricata/:/var/log/suricata/:rw
|
||||||
|
- /opt/so/conf/suricata/bpf:/etc/suricata/bpf:ro
|
||||||
- network_mode: host
|
- network_mode: host
|
||||||
- watch:
|
- watch:
|
||||||
- file: /opt/so/conf/suricata/suricata.yaml
|
- file: /opt/so/conf/suricata/suricata.yaml
|
||||||
- file: surithresholding
|
- file: surithresholding
|
||||||
- file: /opt/so/conf/suricata/rules/
|
- file: /opt/so/conf/suricata/rules/
|
||||||
|
- file: /opt/so/conf/suricata/bpf
|
||||||
|
|||||||
Reference in New Issue
Block a user