-
Notifications
You must be signed in to change notification settings - Fork 522
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/2.4/dev' into 2.4/detections-def…
…aults
- Loading branch information
Showing
10 changed files
with
165 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,10 @@ | ||
{% import_yaml 'bpf/defaults.yaml' as BPFDEFAULTS %} | ||
{% set BPFMERGED = salt['pillar.get']('bpf', BPFDEFAULTS.bpf, merge=True) %} | ||
{% import 'bpf/macros.jinja' as MACROS %} | ||
|
||
{{ MACROS.remove_comments(BPFMERGED, 'pcap') }} | ||
|
||
{% set PCAPBPF = BPFMERGED.pcap %} | ||
{% from 'vars/globals.map.jinja' import GLOBALS %} | ||
{% if GLOBALS.pcap_engine == "TRANSITION" %} | ||
{% set PCAPBPF = ["ip and host 255.255.255.1 and port 1"] %} | ||
{% else %} | ||
{% import_yaml 'bpf/defaults.yaml' as BPFDEFAULTS %} | ||
{% set BPFMERGED = salt['pillar.get']('bpf', BPFDEFAULTS.bpf, merge=True) %} | ||
{% import 'bpf/macros.jinja' as MACROS %} | ||
{{ MACROS.remove_comments(BPFMERGED, 'pcap') }} | ||
{% set PCAPBPF = BPFMERGED.pcap %} | ||
{% endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#!/bin/bash | ||
NOROOT=1 | ||
. /usr/sbin/so-common | ||
|
||
{%- set proxy = salt['pillar.get']('manager:proxy') %} | ||
{%- set noproxy = salt['pillar.get']('manager:no_proxy', '') %} | ||
|
||
# Download the rules from the internet | ||
{%- if proxy %} | ||
export http_proxy={{ proxy }} | ||
export https_proxy={{ proxy }} | ||
export no_proxy="{{ noproxy }}" | ||
{%- endif %} | ||
|
||
repos="/opt/so/conf/strelka/repos.txt" | ||
output_dir=/nsm/rules/yara | ||
gh_status=$(curl -s -o /dev/null -w "%{http_code}" https://github.com) | ||
clone_dir="/tmp" | ||
if [ "$gh_status" == "200" ] || [ "$gh_status" == "301" ]; then | ||
|
||
while IFS= read -r repo; do | ||
if ! $(echo "$repo" | grep -qE '^#'); then | ||
# Remove old repo if existing bc of previous error condition or unexpected disruption | ||
repo_name=`echo $repo | awk -F '/' '{print $NF}'` | ||
[ -d $output_dir/$repo_name ] && rm -rf $output_dir/$repo_name | ||
|
||
# Clone repo and make appropriate directories for rules | ||
git clone $repo $clone_dir/$repo_name | ||
echo "Analyzing rules from $clone_dir/$repo_name..." | ||
mkdir -p $output_dir/$repo_name | ||
# Ensure a copy of the license is available for the rules | ||
[ -f $clone_dir/$repo_name/LICENSE ] && cp $clone_dir/$repo_name/LICENSE $output_dir/$repo_name | ||
|
||
# Copy over rules | ||
for i in $(find $clone_dir/$repo_name -name "*.yar*"); do | ||
rule_name=$(echo $i | awk -F '/' '{print $NF}') | ||
cp $i $output_dir/$repo_name | ||
done | ||
rm -rf $clone_dir/$repo_name | ||
fi | ||
done < $repos | ||
|
||
echo "Done!" | ||
|
||
/usr/sbin/so-yara-update | ||
|
||
else | ||
echo "Server returned $gh_status status code." | ||
echo "No connectivity to Github...exiting..." | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/bin/bash | ||
# Copyright Security Onion Solutions LLC and/or licensed to Security Onion Solutions LLC under one | ||
# or more contributor license agreements. Licensed under the Elastic License 2.0 as shown at | ||
# https://securityonion.net/license; you may not use this file except in compliance with the | ||
# Elastic License 2.0. | ||
|
||
NOROOT=1 | ||
. /usr/sbin/so-common | ||
|
||
echo "Starting to check for yara rule updates at $(date)..." | ||
|
||
newcounter=0 | ||
excludedcounter=0 | ||
excluded_rules=({{ EXCLUDEDRULES | join(' ') }}) | ||
|
||
# Pull down the SO Rules | ||
SORULEDIR=/nsm/rules/yara | ||
OUTPUTDIR=/opt/so/saltstack/local/salt/strelka/rules | ||
|
||
mkdir -p $OUTPUTDIR | ||
# remove all rules prior to copy so we can clear out old rules | ||
rm -f $OUTPUTDIR/* | ||
|
||
for i in $(find $SORULEDIR -name "*.yar" -o -name "*.yara"); do | ||
rule_name=$(echo $i | awk -F '/' '{print $NF}') | ||
if [[ ! "${excluded_rules[*]}" =~ ${rule_name} ]]; then | ||
echo "Adding rule: $rule_name..." | ||
cp $i $OUTPUTDIR/$rule_name | ||
((newcounter++)) | ||
else | ||
echo "Excluding rule: $rule_name..." | ||
((excludedcounter++)) | ||
fi | ||
done | ||
|
||
if [ "$newcounter" -gt 0 ] || [ "$excludedcounter" -gt 0 ];then | ||
echo "$newcounter rules added." | ||
echo "$excludedcounter rule(s) excluded." | ||
fi | ||
|
||
echo "Finished rule updates at $(date)..." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters