mirror of
https://github.com/Security-Onion-Solutions/securityonion.git
synced 2025-12-07 17:52:46 +01:00
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,9 @@
|
||||
{% set BROVER = salt['pillar.get']('static:broversion', '') %}
|
||||
{% set VERSION = salt['pillar.get']('static:soversion', 'HH1.1.4') %}
|
||||
{% set MASTER = salt['grains.get']('master') %}
|
||||
{% set BPF_NIDS = salt['pillar.get']('nids:bpf') %}
|
||||
{% set BPF_STATUS = 0 %}
|
||||
|
||||
|
||||
# Suricata
|
||||
|
||||
@@ -79,6 +82,32 @@ surithresholding:
|
||||
- user: 940
|
||||
- group: 940
|
||||
- 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'] == "" %}
|
||||
{% set BPF_STATUS = 1 %}
|
||||
{% else %}
|
||||
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_STATUS %}
|
||||
- contents_pillar: nids:bpf
|
||||
{% else %}
|
||||
- contents:
|
||||
- ""
|
||||
{% endif %}
|
||||
|
||||
so-suricata:
|
||||
docker_container.running:
|
||||
|
||||
Reference in New Issue
Block a user