mirror of
https://github.com/Security-Onion-Solutions/securityonion.git
synced 2026-01-25 17:33:35 +01:00
merge with dev and fix merge conflict in so-functions https://github.com/Security-Onion-Solutions/securityonion/issues/3264
This commit is contained in:
@@ -1 +1 @@
|
||||
net.ipv4.ip_local_reserved_ports=55000,57314
|
||||
net.ipv4.ip_local_reserved_ports=55000,57314,47760-47860
|
||||
@@ -49,6 +49,11 @@ sosaltstackperms:
|
||||
- gid: 939
|
||||
- dir_mode: 770
|
||||
|
||||
so_log_perms:
|
||||
file.directory:
|
||||
- name: /opt/so/log
|
||||
- dir_mode: 755
|
||||
|
||||
# Create a state directory
|
||||
statedir:
|
||||
file.directory:
|
||||
@@ -64,21 +69,6 @@ salttmp:
|
||||
- group: 939
|
||||
- makedirs: True
|
||||
|
||||
# Install epel
|
||||
{% if grains['os'] == 'CentOS' %}
|
||||
repair_yumdb:
|
||||
cmd.run:
|
||||
- name: 'mv -f /var/lib/rpm/__db* /tmp && yum clean all'
|
||||
- onlyif:
|
||||
- 'yum check-update 2>&1 | grep "Error: rpmdb open failed"'
|
||||
|
||||
epel:
|
||||
pkg.installed:
|
||||
- skip_suggestions: True
|
||||
- pkgs:
|
||||
- epel-release
|
||||
{% endif %}
|
||||
|
||||
# Install common packages
|
||||
{% if grains['os'] != 'CentOS' %}
|
||||
commonpkgs:
|
||||
@@ -238,6 +228,30 @@ commonlogrotateconf:
|
||||
- month: '*'
|
||||
- dayweek: '*'
|
||||
|
||||
# Create the status directory
|
||||
sostatusdir:
|
||||
file.directory:
|
||||
- name: /opt/so/log/sostatus
|
||||
- user: 0
|
||||
- group: 0
|
||||
- makedirs: True
|
||||
|
||||
sostatus_log:
|
||||
file.managed:
|
||||
- name: /opt/so/log/sostatus/status.log
|
||||
- mode: 644
|
||||
|
||||
# Install sostatus check cron
|
||||
'/usr/sbin/so-status -q; echo $? > /opt/so/log/sostatus/status.log 2>&1':
|
||||
cron.present:
|
||||
- user: root
|
||||
- minute: '*/1'
|
||||
- hour: '*'
|
||||
- daymonth: '*'
|
||||
- month: '*'
|
||||
- dayweek: '*'
|
||||
|
||||
|
||||
{% if role in ['eval', 'manager', 'managersearch', 'standalone'] %}
|
||||
# Lock permissions on the backup directory
|
||||
backupdir:
|
||||
@@ -274,9 +288,10 @@ docker:
|
||||
- file: docker_daemon
|
||||
|
||||
# Reserve OS ports for Docker proxy in case boot settings are not already applied/present
|
||||
# 55000 = Wazuh, 57314 = Strelka, 47760-47860 = Zeek
|
||||
dockerapplyports:
|
||||
cmd.run:
|
||||
- name: if [ ! -s /etc/sysctl.d/99-reserved-ports.conf ]; then sysctl -w net.ipv4.ip_local_reserved_ports="55000,57314"; fi
|
||||
- name: if [ ! -s /etc/sysctl.d/99-reserved-ports.conf ]; then sysctl -w net.ipv4.ip_local_reserved_ports="55000,57314,47760-47860"; fi
|
||||
|
||||
# Reserve OS ports for Docker proxy
|
||||
dockerreserveports:
|
||||
|
||||
@@ -162,6 +162,23 @@ get_random_value() {
|
||||
head -c 5000 /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w $length | head -n 1
|
||||
}
|
||||
|
||||
gpg_rpm_import() {
|
||||
if [[ "$OS" == "centos" ]]; then
|
||||
if [[ "$WHATWOULDYOUSAYYAHDOHERE" == "setup" ]]; then
|
||||
local RPMKEYSLOC="../salt/repo/client/files/centos/keys"
|
||||
else
|
||||
local RPMKEYSLOC="$UPDATEDIR/salt/repo/client/files/centos/keys"
|
||||
fi
|
||||
|
||||
RPMKEYS=('RPM-GPG-KEY-EPEL-7' 'GPG-KEY-WAZUH' 'docker.pub' 'SALTSTACK-GPG-KEY.pub' 'securityonion.pub')
|
||||
|
||||
for RPMKEY in "${RPMKEYS[@]}"; do
|
||||
rpm --import $RPMKEYSLOC/$RPMKEY
|
||||
echo "Imported $RPMKEY"
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
header() {
|
||||
printf '%s\n' "" "$banner" " $*" "$banner"
|
||||
}
|
||||
@@ -419,6 +436,20 @@ valid_proxy() {
|
||||
[[ $has_prefix == true ]] && [[ $valid_url == true ]] && return 0 || return 1
|
||||
}
|
||||
|
||||
valid_ntp_list() {
|
||||
local string=$1
|
||||
local ntp_arr
|
||||
IFS="," read -r -a ntp_arr <<< "$string"
|
||||
|
||||
for ntp in "${ntp_arr[@]}"; do
|
||||
if ! valid_ip4 "$ntp" && ! valid_hostname "$ntp" && ! valid_fqdn "$ntp"; then
|
||||
return 1
|
||||
fi
|
||||
done
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
valid_string() {
|
||||
local str=$1
|
||||
local min_length=${2:-1}
|
||||
|
||||
@@ -60,15 +60,19 @@ def main(quiet):
|
||||
no_prunable = True
|
||||
for t_list in grouped_tag_lists:
|
||||
try:
|
||||
# Keep the 2 most current images
|
||||
# Group tags by version, in case multiple images exist with the same version string
|
||||
t_list.sort(key=lambda x: Version(get_image_version(x)), reverse=True)
|
||||
if len(t_list) <= 2:
|
||||
grouped_t_list = [ list(it) for _,it in groupby(t_list, lambda x: get_image_version(x)) ]
|
||||
|
||||
# Keep the 2 most current version groups
|
||||
if len(grouped_t_list) <= 2:
|
||||
continue
|
||||
else:
|
||||
no_prunable = False
|
||||
for tag in t_list[2:]:
|
||||
if not quiet: print(f'Removing image {tag}')
|
||||
client.images.remove(tag)
|
||||
for group in grouped_t_list[2:]:
|
||||
for tag in group:
|
||||
if not quiet: print(f'Removing image {tag}')
|
||||
client.images.remove(tag)
|
||||
except InvalidVersion as e:
|
||||
print(f'so-{get_so_image_basename(t_list[0])}: {e.args[0]}', file=sys.stderr)
|
||||
exit(1)
|
||||
|
||||
21
salt/common/tools/sbin/so-elasticsearch-indices-list
Executable file
21
salt/common/tools/sbin/so-elasticsearch-indices-list
Executable file
@@ -0,0 +1,21 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Copyright 2014,2015,2016,2017,2018,2019,2020,2021 Security Onion Solutions, LLC
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
{%- set NODEIP = salt['pillar.get']('elasticsearch:mainip', '') -%}
|
||||
|
||||
. /usr/sbin/so-common
|
||||
|
||||
curl -s -k -L https://{{ NODEIP }}:9200/_cat/indices?pretty
|
||||
25
salt/common/tools/sbin/so-elasticsearch-pipeline-view
Executable file
25
salt/common/tools/sbin/so-elasticsearch-pipeline-view
Executable file
@@ -0,0 +1,25 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Copyright 2014,2015,2016,2017,2018,2019,2020,2021 Security Onion Solutions, LLC
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
{%- set NODEIP = salt['pillar.get']('elasticsearch:mainip', '') -%}
|
||||
|
||||
. /usr/sbin/so-common
|
||||
|
||||
if [ "$1" == "" ]; then
|
||||
curl -s -k -L https://{{ NODEIP }}:9200/_ingest/pipeline/* | jq .
|
||||
else
|
||||
curl -s -k -L https://{{ NODEIP }}:9200/_ingest/pipeline/$1 | jq .
|
||||
fi
|
||||
21
salt/common/tools/sbin/so-elasticsearch-shards-list
Executable file
21
salt/common/tools/sbin/so-elasticsearch-shards-list
Executable file
@@ -0,0 +1,21 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Copyright 2014,2015,2016,2017,2018,2019,2020,2021 Security Onion Solutions, LLC
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
{%- set NODEIP = salt['pillar.get']('elasticsearch:mainip', '') -%}
|
||||
|
||||
. /usr/sbin/so-common
|
||||
|
||||
curl -s -k -L https://{{ NODEIP }}:9200/_cat/shards?pretty
|
||||
21
salt/common/tools/sbin/so-elasticsearch-template-remove
Executable file
21
salt/common/tools/sbin/so-elasticsearch-template-remove
Executable file
@@ -0,0 +1,21 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Copyright 2014,2015,2016,2017,2018,2019,2020,2021 Security Onion Solutions, LLC
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
{%- set NODEIP = salt['pillar.get']('elasticsearch:mainip', '') -%}
|
||||
|
||||
. /usr/sbin/so-common
|
||||
|
||||
curl -s -k -L -XDELETE https://{{ NODEIP }}:9200/_template/$1
|
||||
25
salt/common/tools/sbin/so-elasticsearch-template-view
Executable file
25
salt/common/tools/sbin/so-elasticsearch-template-view
Executable file
@@ -0,0 +1,25 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Copyright 2014,2015,2016,2017,2018,2019,2020,2021 Security Onion Solutions, LLC
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
{%- set NODEIP = salt['pillar.get']('elasticsearch:mainip', '') -%}
|
||||
|
||||
. /usr/sbin/so-common
|
||||
|
||||
if [ "$1" == "" ]; then
|
||||
curl -s -k -L https://{{ NODEIP }}:9200/_template/* | jq .
|
||||
else
|
||||
curl -s -k -L https://{{ NODEIP }}:9200/_template/$1 | jq .
|
||||
fi
|
||||
@@ -15,4 +15,4 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
curl -X GET -k -L https://localhost:9200/_cat/indices?v
|
||||
curl -X GET -k -L "https://localhost:9200/_cat/indices?v&s=index"
|
||||
|
||||
0
salt/common/tools/sbin/so-kibana-space-defaults
Normal file → Executable file
0
salt/common/tools/sbin/so-kibana-space-defaults
Normal file → Executable file
25
salt/common/tools/sbin/so-logstash-events
Executable file
25
salt/common/tools/sbin/so-logstash-events
Executable file
@@ -0,0 +1,25 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Copyright 2014,2015,2016,2017,2018,2019,2020,2021 Security Onion Solutions, LLC
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
{%- set NODEIP = salt['pillar.get']('elasticsearch:mainip', '') -%}
|
||||
|
||||
. /usr/sbin/so-common
|
||||
|
||||
if [ "$1" == "" ]; then
|
||||
for i in $(curl -s -L http://{{ NODEIP }}:9600/_node/stats | jq .pipelines | jq '. | to_entries | .[].key' | sed 's/\"//g'); do echo ${i^}:; curl -s localhost:9600/_node/stats | jq .pipelines.$i.events; done
|
||||
else
|
||||
curl -s -L http://{{ NODEIP }}:9600/_node/stats | jq .pipelines.$1.events
|
||||
fi
|
||||
25
salt/common/tools/sbin/so-logstash-pipeline-stats
Executable file
25
salt/common/tools/sbin/so-logstash-pipeline-stats
Executable file
@@ -0,0 +1,25 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Copyright 2014,2015,2016,2017,2018,2019,2020,2021 Security Onion Solutions, LLC
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
{%- set NODEIP = salt['pillar.get']('elasticsearch:mainip', '') -%}
|
||||
|
||||
. /usr/sbin/so-common
|
||||
|
||||
if [ "$1" == "" ]; then
|
||||
curl -s -L http://{{ NODEIP }}:9600/_node/stats | jq .pipelines
|
||||
else
|
||||
curl -s -L http://{{ NODEIP }}:9600/_node/stats | jq .pipelines.$1
|
||||
fi
|
||||
@@ -17,4 +17,8 @@
|
||||
|
||||
. /usr/sbin/so-common
|
||||
|
||||
# Check to see if we are already running
|
||||
IS_RUNNING=$(ps aux | pgrep -f "so-playbook-sync" | wc -l)
|
||||
[ "$IS_RUNNING" -gt 2 ] && echo "$(date) - Multiple Playbook Sync processes already running...exiting." && exit 0
|
||||
|
||||
docker exec so-soctopus python3 playbook_play-sync.py
|
||||
|
||||
@@ -66,11 +66,13 @@ mkdir -p /opt/so/log/raid
|
||||
{%- if grains['sosmodel'] in ['SOSMN', 'SOSSNNV'] %}
|
||||
#check_boss_raid
|
||||
check_software_raid
|
||||
echo "osraid=$BOSSRAID nsmraid=$SWRAID" > /opt/so/log/raid/status.log
|
||||
#echo "osraid=$BOSSRAID nsmraid=$SWRAID" > /opt/so/log/raid/status.log
|
||||
echo "osraid=1 nsmraid=$SWRAID" > /opt/so/log/raid/status.log
|
||||
{%- elif grains['sosmodel'] in ['SOS1000F', 'SOS1000', 'SOSSN7200', 'SOS10K', 'SOS4000'] %}
|
||||
#check_boss_raid
|
||||
check_lsi_raid
|
||||
echo "osraid=$BOSSRAID nsmraid=$LSIRAID" > /opt/so/log/raid/status.log
|
||||
#echo "osraid=$BOSSRAID nsmraid=$LSIRAID" > /opt/so/log/raid/status.log
|
||||
echo "osraid=1 nsmraid=$LSIRAID" > /opt/so/log/raid/status.log
|
||||
{%- else %}
|
||||
exit 0
|
||||
{%- endif %}
|
||||
|
||||
@@ -115,7 +115,7 @@ clean() {
|
||||
}
|
||||
|
||||
# Check to see if we are already running
|
||||
IS_RUNNING=$(ps aux | grep "so-sensor-clean" | grep -v grep | wc -l)
|
||||
IS_RUNNING=$(ps aux | pgrep -f "so-sensor-clean" | wc -l)
|
||||
[ "$IS_RUNNING" -gt 2 ] && echo "$(date) - $IS_RUNNING sensor clean script processes running...exiting." >>$LOG && exit 0
|
||||
|
||||
if [ "$CUR_USAGE" -gt "$CRIT_DISK_USAGE" ]; then
|
||||
|
||||
@@ -4,90 +4,184 @@
|
||||
|
||||
if [[ $1 =~ ^(-q|--quiet) ]]; then
|
||||
quiet=true
|
||||
elif [[ $1 =~ ^(-v|--verbose) ]]; then
|
||||
verbose=true
|
||||
fi
|
||||
|
||||
sshd_config=/etc/ssh/sshd_config
|
||||
temp_config=/tmp/sshd_config
|
||||
|
||||
before=
|
||||
after=
|
||||
reload_required=false
|
||||
change_header_printed=false
|
||||
|
||||
print_sshd_t() {
|
||||
check_sshd_t() {
|
||||
local string=$1
|
||||
local state=$2
|
||||
echo "${state}:"
|
||||
|
||||
local grep_out
|
||||
grep_out=$(sshd -T | grep "^${string}")
|
||||
|
||||
if [[ $state == "Before" ]]; then
|
||||
before=$grep_out
|
||||
before=$grep_out
|
||||
}
|
||||
|
||||
print_diff() {
|
||||
local diff
|
||||
diff=$(diff -dbB <(echo $before) <(echo $after) | awk 'NR>1')
|
||||
|
||||
if [[ -n $diff ]]; then
|
||||
if [[ $change_header_printed == false ]]; then
|
||||
printf '%s\n' '' "Changes" '-------' ''
|
||||
change_header_printed=true
|
||||
fi
|
||||
echo -e "$diff\n"
|
||||
fi
|
||||
}
|
||||
|
||||
replace_or_add() {
|
||||
local type=$1
|
||||
local string=$2
|
||||
if grep -q "$type" $temp_config; then
|
||||
sed -i "/$type .*/d" $temp_config
|
||||
fi
|
||||
printf "%s\n\n" "$string" >> $temp_config
|
||||
reload_required=true
|
||||
}
|
||||
|
||||
test_config() {
|
||||
local msg
|
||||
msg=$(sshd -t -f $temp_config)
|
||||
local ret=$?
|
||||
|
||||
if [[ -n $msg ]]; then
|
||||
echo "Error found in temp sshd config:"
|
||||
echo $msg
|
||||
fi
|
||||
|
||||
return $ret
|
||||
}
|
||||
|
||||
main() {
|
||||
if ! [[ $quiet ]]; then echo "Copying current config to $temp_config"; fi
|
||||
cp $sshd_config $temp_config
|
||||
|
||||
# Add newline to ssh for legibility
|
||||
echo "" >> $temp_config
|
||||
|
||||
# Ciphers
|
||||
check_sshd_t "ciphers"
|
||||
|
||||
local bad_ciphers=(
|
||||
"3des-cbc"
|
||||
"aes128-cbc"
|
||||
"aes192-cbc"
|
||||
"aes256-cbc"
|
||||
"arcfour"
|
||||
"arcfour128"
|
||||
"arcfour256"
|
||||
"blowfish-cbc"
|
||||
"cast128-cbc"
|
||||
)
|
||||
|
||||
local cipher_string=$before
|
||||
for cipher in "${bad_ciphers[@]}"; do
|
||||
cipher_string=$(echo "$cipher_string" | sed "s/${cipher}\(,\|\$\)//g" | sed 's/,$//')
|
||||
done
|
||||
|
||||
after=$cipher_string
|
||||
|
||||
if [[ $verbose ]]; then print_diff; fi
|
||||
|
||||
if [[ $before != "$after" ]]; then
|
||||
replace_or_add "ciphers" "$cipher_string" && test_config || exit 1
|
||||
fi
|
||||
|
||||
# KexAlgorithms
|
||||
check_sshd_t "kexalgorithms"
|
||||
|
||||
local bad_kexalgs=(
|
||||
"diffie-hellman-group-exchange-sha1"
|
||||
"diffie-hellman-group-exchange-sha256"
|
||||
"diffie-hellman-group1-sha1"
|
||||
"diffie-hellman-group14-sha1"
|
||||
"ecdh-sha2-nistp256"
|
||||
"ecdh-sha2-nistp521"
|
||||
"ecdh-sha2-nistp384"
|
||||
)
|
||||
|
||||
local kexalg_string=$before
|
||||
for kexalg in "${bad_kexalgs[@]}"; do
|
||||
kexalg_string=$(echo "$kexalg_string" | sed "s/${kexalg}\(,\|\$\)//g" | sed 's/,$//')
|
||||
done
|
||||
|
||||
after=$kexalg_string
|
||||
|
||||
if [[ $verbose ]]; then print_diff; fi
|
||||
|
||||
if [[ $before != "$after" ]]; then
|
||||
replace_or_add "kexalgorithms" "$kexalg_string" && test_config || exit 1
|
||||
fi
|
||||
|
||||
# Macs
|
||||
check_sshd_t "macs"
|
||||
|
||||
local bad_macs=(
|
||||
"hmac-sha2-512"
|
||||
"umac-128@openssh.com"
|
||||
"hmac-sha2-256"
|
||||
"umac-64@openssh.com"
|
||||
"hmac-sha1"
|
||||
"hmac-sha1-etm@openssh.com"
|
||||
"umac-64-etm@openssh.com"
|
||||
)
|
||||
|
||||
local macs_string=$before
|
||||
for mac in "${bad_macs[@]}"; do
|
||||
macs_string=$(echo "$macs_string" | sed "s/${mac}\(,\|\$\)//g" | sed 's/,$//')
|
||||
done
|
||||
|
||||
after=$macs_string
|
||||
|
||||
if [[ $verbose ]]; then print_diff; fi
|
||||
|
||||
if [[ $before != "$after" ]]; then
|
||||
replace_or_add "macs" "$macs_string" && test_config || exit 1
|
||||
fi
|
||||
|
||||
# HostKeyAlgorithms
|
||||
check_sshd_t "hostkeyalgorithms"
|
||||
|
||||
local optional_suffix_regex_hka="\(-cert-v01@openssh.com\)\?"
|
||||
local bad_hostkeyalg_list=(
|
||||
"ecdsa-sha2-nistp256"
|
||||
"ecdsa-sha2-nistp384"
|
||||
"ecdsa-sha2-nistp521"
|
||||
"ssh-rsa"
|
||||
"ssh-dss"
|
||||
)
|
||||
|
||||
local hostkeyalg_string=$before
|
||||
for alg in "${bad_hostkeyalg_list[@]}"; do
|
||||
hostkeyalg_string=$(echo "$hostkeyalg_string" | sed "s/${alg}${optional_suffix_regex_hka}\(,\|\$\)//g" | sed 's/,$//')
|
||||
done
|
||||
|
||||
after=$hostkeyalg_string
|
||||
|
||||
if [[ $verbose ]]; then print_diff; fi
|
||||
|
||||
if [[ $before != "$after" ]]; then
|
||||
replace_or_add "hostkeyalgorithms" "$hostkeyalg_string" && test_config || exit 1
|
||||
fi
|
||||
|
||||
if [[ $reload_required == true ]]; then
|
||||
mv -f $temp_config $sshd_config
|
||||
if ! [[ $quiet ]]; then echo "Reloading sshd to load config changes"; fi
|
||||
systemctl reload sshd
|
||||
echo "[ WARNING ] Any new ssh sessions will need to remove and reaccept the host key fingerprint for this server before reconnecting."
|
||||
else
|
||||
after=$grep_out
|
||||
fi
|
||||
|
||||
echo $grep_out
|
||||
}
|
||||
|
||||
print_msg() {
|
||||
local msg=$1
|
||||
if ! [[ $quiet ]]; then
|
||||
printf "%s\n" \
|
||||
"----" \
|
||||
"$msg" \
|
||||
"----" \
|
||||
""
|
||||
if ! [[ $quiet ]]; then echo "No changes made to temp file, cleaning up"; fi
|
||||
rm -f $temp_config
|
||||
fi
|
||||
}
|
||||
|
||||
if ! [[ $quiet ]]; then print_sshd_t "ciphers" "Before"; fi
|
||||
sshd -T | grep "^ciphers" | sed -e "s/\(3des-cbc\|aes128-cbc\|aes192-cbc\|aes256-cbc\|arcfour\|arcfour128\|arcfour256\|blowfish-cbc\|cast128-cbc\|rijndael-cbc@lysator.liu.se\)\,\?//g" >> /etc/ssh/sshd_config
|
||||
if ! [[ $quiet ]]; then
|
||||
print_sshd_t "ciphers" "After"
|
||||
echo ""
|
||||
fi
|
||||
|
||||
if [[ $before != $after ]]; then
|
||||
reload_required=true
|
||||
fi
|
||||
|
||||
if ! [[ $quiet ]]; then print_sshd_t "kexalgorithms" "Before"; fi
|
||||
sshd -T | grep "^kexalgorithms" | sed -e "s/\(diffie-hellman-group14-sha1\|ecdh-sha2-nistp256\|diffie-hellman-group-exchange-sha256\|diffie-hellman-group1-sha1\|diffie-hellman-group-exchange-sha1\|ecdh-sha2-nistp521\|ecdh-sha2-nistp384\)\,\?//g" >> /etc/ssh/sshd_config
|
||||
if ! [[ $quiet ]]; then
|
||||
print_sshd_t "kexalgorithms" "After"
|
||||
echo ""
|
||||
fi
|
||||
|
||||
if [[ $before != $after ]]; then
|
||||
reload_required=true
|
||||
fi
|
||||
|
||||
if ! [[ $quiet ]]; then print_sshd_t "macs" "Before"; fi
|
||||
sshd -T | grep "^macs" | sed -e "s/\(hmac-sha2-512,\|umac-128@openssh.com,\|hmac-sha2-256,\|umac-64@openssh.com,\|hmac-sha1,\|hmac-sha1-etm@openssh.com,\|umac-64-etm@openssh.com,\|hmac-sha1\)//g" >> /etc/ssh/sshd_config
|
||||
if ! [[ $quiet ]]; then
|
||||
print_sshd_t "macs" "After"
|
||||
echo ""
|
||||
fi
|
||||
|
||||
if [[ $before != $after ]]; then
|
||||
reload_required=true
|
||||
fi
|
||||
|
||||
if ! [[ $quiet ]]; then print_sshd_t "hostkeyalgorithms" "Before"; fi
|
||||
sshd -T | grep "^hostkeyalgorithms" | sed "s|ecdsa-sha2-nistp256,||g" | sed "s|ssh-rsa,||g" >> /etc/ssh/sshd_config
|
||||
if ! [[ $quiet ]]; then
|
||||
print_sshd_t "hostkeyalgorithms" "After"
|
||||
echo ""
|
||||
fi
|
||||
|
||||
if [[ $before != $after ]]; then
|
||||
reload_required=true
|
||||
fi
|
||||
|
||||
if [[ $reload_required == true ]]; then
|
||||
print_msg "Reloading sshd to load config changes..."
|
||||
systemctl reload sshd
|
||||
fi
|
||||
|
||||
{% if grains['os'] != 'CentOS' %}
|
||||
print_msg "[ WARNING ] Any new ssh sessions will need to remove and reaccept the ECDSA key for this server before reconnecting."
|
||||
{% endif %}
|
||||
|
||||
main
|
||||
|
||||
@@ -24,6 +24,7 @@ INSTALLEDSALTVERSION=$(salt --versions-report | grep Salt: | awk {'print $2'})
|
||||
DEFAULT_SALT_DIR=/opt/so/saltstack/default
|
||||
BATCHSIZE=5
|
||||
SOUP_LOG=/root/soup.log
|
||||
WHATWOULDYOUSAYYAHDOHERE=soup
|
||||
|
||||
add_common() {
|
||||
cp $UPDATE_DIR/salt/common/tools/sbin/so-common $DEFAULT_SALT_DIR/salt/common/tools/sbin/
|
||||
@@ -229,6 +230,13 @@ masterunlock() {
|
||||
fi
|
||||
}
|
||||
|
||||
preupgrade_changes_2.3.50_repo() {
|
||||
# We made repo changes in 2.3.50 and this prepares for that on upgrade
|
||||
echo "Checking to see if 2.3.50 repo changes are needed."
|
||||
|
||||
[[ "$INSTALLEDVERSION" == 2.3.30 || "$INSTALLEDVERSION" == 2.3.40 ]] && up_2.3.3X_to_2.3.50_repo
|
||||
}
|
||||
|
||||
preupgrade_changes() {
|
||||
# This function is to add any new pillar items if needed.
|
||||
echo "Checking to see if changes are needed."
|
||||
@@ -238,6 +246,7 @@ preupgrade_changes() {
|
||||
[[ "$INSTALLEDVERSION" =~ rc.3 ]] && rc3_to_2.3.0
|
||||
[[ "$INSTALLEDVERSION" == 2.3.0 || "$INSTALLEDVERSION" == 2.3.1 || "$INSTALLEDVERSION" == 2.3.2 || "$INSTALLEDVERSION" == 2.3.10 ]] && up_2.3.0_to_2.3.20
|
||||
[[ "$INSTALLEDVERSION" == 2.3.20 || "$INSTALLEDVERSION" == 2.3.21 ]] && up_2.3.2X_to_2.3.30
|
||||
[[ "$INSTALLEDVERSION" == 2.3.30 || "$INSTALLEDVERSION" == 2.3.40 ]] && up_2.3.3X_to_2.3.50
|
||||
}
|
||||
|
||||
postupgrade_changes() {
|
||||
@@ -408,6 +417,36 @@ up_2.3.2X_to_2.3.30() {
|
||||
sed -i "/^strelka:/a \\ repos: \n - https://github.com/Neo23x0/signature-base" /opt/so/saltstack/local/pillar/global.sls;
|
||||
fi
|
||||
check_log_size_limit
|
||||
INSTALLEDVERSION=2.3.30
|
||||
}
|
||||
|
||||
up_2.3.3X_to_2.3.50_repo() {
|
||||
echo "Performing 2.3.50 repo actions."
|
||||
if [[ "$OS" == "centos" ]]; then
|
||||
# Import GPG Keys
|
||||
gpg_rpm_import
|
||||
|
||||
if [ $is_airgap -eq 1 ]; then
|
||||
echo "Deleting unneeded repo files."
|
||||
DELREPOS=('CentOS-Base' 'CentOS-CR' 'CentOS-Debuginfo' 'docker-ce' 'CentOS-fasttrack' 'CentOS-Media' 'CentOS-Sources' 'CentOS-Vault' 'CentOS-x86_64-kernel' 'epel' 'epel-testing' 'saltstack' 'wazuh')
|
||||
|
||||
for DELREPO in "${DELREPOS[@]}"; do
|
||||
if [[ -f "/etc/yum.repos.d/$DELREPO.repo" ]]; then
|
||||
echo "Deleting $DELREPO.repo"
|
||||
rm -f "/etc/yum.repos.d/$DELREPO.repo"
|
||||
fi
|
||||
done
|
||||
|
||||
# Copy the new repo file if not airgap
|
||||
cp $UPDATE_DIR/salt/repo/client/files/centos/securityonion.repo /etc/yum.repos.d/
|
||||
yum clean all
|
||||
yum repolist
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
up_2.3.3X_to_2.3.50() {
|
||||
INSTALLEDVERSION=2.3.50
|
||||
}
|
||||
|
||||
verify_upgradespace() {
|
||||
@@ -502,22 +541,18 @@ upgrade_salt() {
|
||||
echo "Performing upgrade of Salt from $INSTALLEDSALTVERSION to $NEWSALTVERSION."
|
||||
echo ""
|
||||
# If CentOS
|
||||
if [ "$OS" == "centos" ]; then
|
||||
if [[ $OS == 'centos' ]]; then
|
||||
echo "Removing yum versionlock for Salt."
|
||||
echo ""
|
||||
yum versionlock delete "salt-*"
|
||||
echo "Updating Salt packages and restarting services."
|
||||
echo ""
|
||||
if [ $is_airgap -eq 0 ]; then
|
||||
sh $UPDATE_DIR/salt/salt/scripts/bootstrap-salt.sh -r -F -M -x python3 stable "$NEWSALTVERSION"
|
||||
else
|
||||
sh $UPDATE_DIR/salt/salt/scripts/bootstrap-salt.sh -F -M -x python3 stable "$NEWSALTVERSION"
|
||||
fi
|
||||
sh $UPDATE_DIR/salt/salt/scripts/bootstrap-salt.sh -r -F -M -x python3 stable "$NEWSALTVERSION"
|
||||
echo "Applying yum versionlock for Salt."
|
||||
echo ""
|
||||
yum versionlock add "salt-*"
|
||||
# Else do Ubuntu things
|
||||
elif [ "$OS" == "ubuntu" ]; then
|
||||
elif [[ $OS == 'ubuntu' ]]; then
|
||||
echo "Removing apt hold for Salt."
|
||||
echo ""
|
||||
apt-mark unhold "salt-common"
|
||||
@@ -628,6 +663,7 @@ else
|
||||
update_registry
|
||||
update_docker_containers "soup"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "Stopping Salt Minion service."
|
||||
systemctl stop salt-minion
|
||||
@@ -638,6 +674,8 @@ echo "Stopping Salt Master service."
|
||||
systemctl stop salt-master
|
||||
echo ""
|
||||
|
||||
preupgrade_changes_2.3.50_repo
|
||||
|
||||
# Does salt need upgraded. If so update it.
|
||||
if [ "$UPGRADESALT" == "1" ]; then
|
||||
echo "Upgrading Salt"
|
||||
@@ -652,7 +690,8 @@ fi
|
||||
echo "Checking if Salt was upgraded."
|
||||
echo ""
|
||||
# Check that Salt was upgraded
|
||||
if [[ $(salt --versions-report | grep Salt: | awk {'print $2'}) != "$NEWSALTVERSION" ]]; then
|
||||
SALTVERSIONPOSTUPGRADE=$(salt --versions-report | grep Salt: | awk {'print $2'})
|
||||
if [[ "$SALTVERSIONPOSTUPGRADE" != "$NEWSALTVERSION" ]]; then
|
||||
echo "Salt upgrade failed. Check of indicators of failure in $SOUP_LOG."
|
||||
echo "Once the issue is resolved, run soup again."
|
||||
echo "Exiting."
|
||||
|
||||
Reference in New Issue
Block a user