mirror of
https://github.com/gentoo-mirror/gentoo.git
synced 2026-09-24 04:59:14 -07:00
net-analyzer/openvas-scanner: drop old 5.0.4
Package-Manager: Portage-2.3.69, Repoman-2.3.16 Signed-off-by: Hasan ÇALIŞIR <hasan.calisir@psauxit.com> Signed-off-by: Joonas Niilola <juippis@gentoo.org>
This commit is contained in:
committed by
Joonas Niilola
parent
8e5c94824f
commit
8372f7b1ca
@@ -1,2 +1 @@
|
||||
DIST openvas-scanner-5.0.4.tar.gz 236282 BLAKE2B 3105afe0fd819773b33c8194e0addaad70af4692578fe3bfbd76166004ca99e25f2f22a946810fe52da747242f1e45bae00766c4687676ec70df2d7349fa4509 SHA512 51267f832a104897a497b5dc71d1b804de4db77742e2234d111a00b1e0e01536613b16ff48d23a37013178b016b39408a25d18a694980c7e6fc600824e05e149
|
||||
DIST openvas-scanner-5.1.3.tar.gz 254159 BLAKE2B d90fa15e143ead53abce66f933a3a4cac327176cca0f23bd88fe771ed7726b1891784ae980644c8335e560d348753115e43cfae83af9704e2d1d02827163563f SHA512 5712ab275058877cfd656e268ed09c81db6617ae247c17092f1fcd037f692f2018daf21b09b82401f99a7361bb485f0e0f7d63f8ff2387839cfdd5a3aaf8424e
|
||||
|
||||
@@ -1,634 +0,0 @@
|
||||
#!/bin/bash
|
||||
# Copyright 1999-2019 Gentoo Authors
|
||||
# Distributed under the terms of the GNU General Public License v2
|
||||
# This is OpenVAS first-start/check-setup script which make things automatically for first time use.
|
||||
|
||||
|
||||
##################################################################################################
|
||||
# If you use systemd or init.d(open-rc) for OpenVAS daemons you don't need to set below settings.#
|
||||
# If you don't use any of them you can set the below command args to start daemons manually. #
|
||||
##################################################################################################
|
||||
|
||||
# OpenVAS Manager command args
|
||||
OPENVAS_MANAGER_OPTIONS="" # e.g --foreground
|
||||
OPENVAS_MANAGER_PORT="--port=9390" # Manager listen port
|
||||
OPENVAS_MANAGER_LISTEN_ADDRESS="--listen=127.0.0.1" # Manager listen address
|
||||
OPENVAS_MANAGER_SCANNER_HOST="--scanner-host=/var/run/openvassd.sock" # Scanner unix socket
|
||||
OPENVAS_MANAGER_GNUTLS_PRIORITIES="--gnutls-priorities=SECURE256:+SUITEB192:+SECURE192:+SECURE128:+SUITEB128:-MD5:-SHA1:-VERS-TLS1.0:-VERS-TLS1.1:-VERS-SSL3.0"
|
||||
|
||||
# OpenVAS Scanner command args
|
||||
OPENVAS_SCANNER_OPTIONS="" # e.g --foreground
|
||||
OPENVAS_SCANNER_LISTEN_SOCKET="--unix-socket=/var/run/openvassd.sock" # Scanner listen socket
|
||||
|
||||
# OpenVAS Security Assistant command args for reverse proxying | SSL PassThrough
|
||||
OPENVAS_SECURITY_ASSISTANT_OPTIONS="--no-redirect" # Don't listen port 80 anymore for reverse proxy
|
||||
OPENVAS_SECURITY_ASSISTANT_LISTEN_ADDRESS="--listen=127.0.0.1" # WebUI adress
|
||||
OPENVAS_SECURITY_ASSISTANT_LISTEN_PORT="--port=9392" # WebUI Port
|
||||
OPENVAS_SECURITY_ASSISTANT_MANAGER_LISTEN_ADDRESS="--mlisten=127.0.0.1" # WebUI Manager Address
|
||||
OPENVAS_SECURITY_ASSISTANT_MANAGER_PORT="--mport=9390" # WebUI Manager Port
|
||||
OPENVAS_SECURITY_ASSISTANT_GNUTLS_PRIORITIES="--gnutls-priorities=NORMAL" # TLS Settings
|
||||
|
||||
#####################################################################################################
|
||||
|
||||
# Update Environment
|
||||
source /etc/profile &>/dev/null
|
||||
source /etc/environment &>/dev/null
|
||||
source ~/.bash_profile &>/dev/null
|
||||
|
||||
# Check the needed executables.They are in our environment and have +x?
|
||||
if ! [ -x "$(command -v openvasmd)" ] ||
|
||||
! [ -x "$(command -v openvassd)" ] ||
|
||||
! [ -x "$(command -v redis-server)" ] ||
|
||||
! [ -x "$(command -v openvas-manage-certs)" ] ||
|
||||
! [ -x "$(command -v greenbone-nvt-sync)" ] ||
|
||||
! [ -x "$(command -v greenbone-scapdata-sync)" ] ||
|
||||
! [ -x "$(command -v greenbone-certdata-sync)" ]; then
|
||||
path="1"
|
||||
else
|
||||
path="0"
|
||||
fi
|
||||
|
||||
# Check Security-Assistant is exist
|
||||
if ! [ -x "$(command -v gsad)" ]; then
|
||||
gsad="1"
|
||||
else
|
||||
gsad="0"
|
||||
fi
|
||||
# Executables are not in our environment
|
||||
if [ $path -eq 1 ]; then
|
||||
echo "Can't find executables! If you installed OpenVAS to specific location e.g. /opt"
|
||||
echo "please add these PATHS to /etc/profile,also sure that they are executable"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check systemd and enable services for Gentoo/Linux
|
||||
if command -v systemctl &>/dev/null; then
|
||||
systemctl="0"
|
||||
echo "systemd found."
|
||||
systemctl enable openvas-scanner.service &>/dev/null
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "systemd.Gentoo --> openvas-scanner.service enabled."
|
||||
fi
|
||||
systemctl enable gvmd.service &>/dev/null
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "systemd.Gentoo --> gvmd.service enabled."
|
||||
fi
|
||||
systemctl enable gsa.service &>/dev/null
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "systemd.Gentoo --> gsa.service enabled."
|
||||
fi
|
||||
else
|
||||
systemctl="1"
|
||||
fi
|
||||
|
||||
# Check open-rc if exist
|
||||
if command -v rc-service &>/dev/null; then
|
||||
open_rc="0"
|
||||
else
|
||||
open_rc="1"
|
||||
fi
|
||||
|
||||
# open-rc variables
|
||||
if [ $systemctl -eq 1 ] && [ $open_rc -eq 0 ]; then
|
||||
echo "open-rc found."
|
||||
scanner_init="0"
|
||||
manager_init="0"
|
||||
assistant_init="0"
|
||||
redis_init="0"
|
||||
fi
|
||||
|
||||
# Check status of OpenVAS-Scanner systemd unit
|
||||
if [ $systemctl -eq 0 ] &&
|
||||
([ "$(systemctl is-active openvas-scanner.service)" = "active" ] ||
|
||||
[ "$(systemctl list-unit-files | grep 'enabled' | grep 'openvas-scanner.service' | awk '{print $1}')" = "openvas-scanner.service" ]); then
|
||||
scanner="0"
|
||||
else
|
||||
scanner="1"
|
||||
fi
|
||||
|
||||
# Check status of OpenVAS-Manager systemd unit
|
||||
if [ $systemctl -eq 0 ] &&
|
||||
([ "$(systemctl is-active gvmd.service)" = "active" ] ||
|
||||
[ "$(systemctl list-unit-files | grep 'enabled' | grep 'gvmd.service' | awk '{print $1}')" = "gvmd.service" ]); then
|
||||
manager="0"
|
||||
else
|
||||
manager="1"
|
||||
fi
|
||||
|
||||
# Check status of OpenVAS-Assistant systemd unit
|
||||
if [ $systemctl -eq 0 ] &&
|
||||
([ "$(systemctl is-active gsa.service)" = "active" ] ||
|
||||
[ "$(systemctl list-unit-files | grep 'enabled' | grep 'gsa.service' | awk '{print $1}')" = "gsa.service" ]); then
|
||||
assistant="0"
|
||||
else
|
||||
assistant="1"
|
||||
fi
|
||||
|
||||
# Check status of Redis systemd unit
|
||||
if [ $systemctl -eq 0 ] &&
|
||||
([ "$(systemctl is-active redis.service)" = "active" ] ||
|
||||
[ "$(systemctl list-unit-files | grep 'enabled' | grep 'redis.service' | awk '{print $1}')" = "redis.service" ]); then
|
||||
redis="0"
|
||||
else
|
||||
redis="1"
|
||||
fi
|
||||
|
||||
# We need to find correct service name for restarting.
|
||||
if [ $scanner -eq 1 ] || [ $manager -eq 1 ] || [ $assistant -eq 1 ] || [ $redis -eq 1 ]; then
|
||||
WHICHM="ExecStart=$(type openvasmd | awk '{print $3}')"
|
||||
WHICHS="ExecStart=$(type openvassd | awk '{print $3}')"
|
||||
WHICHA="ExecStart=$(type gsad | awk '{print $3}')"
|
||||
WHICHR="ExecStart=$(type redis-server | awk '{print $3}')"
|
||||
|
||||
# If you have unordinary systemd path you can add here
|
||||
DIR="/lib/systemd/system/
|
||||
/etc/systemd/system/
|
||||
/usr/lib/systemd/system/
|
||||
/usr/local/lib/systemd/system/"
|
||||
|
||||
# Find OpenVAS daemons systemd files if exist
|
||||
for i in $DIR; do
|
||||
if [ -d "$i" ]; then
|
||||
grep -rilnw "$i" -e "$WHICHM" | cut -d: -f1 | grep -oP "$i\K.*" &>>/tmp/openvas_GVM_manager_service.out
|
||||
grep -rilnw "$i" -e "$WHICHS" | cut -d: -f1 | grep -oP "$i\K.*" &>>/tmp/openvas_GVM_scanner_service.out
|
||||
grep -rilnw "$i" -e "$WHICHA" | cut -d: -f1 | grep -oP "$i\K.*" &>>/tmp/openvas_GVM_assistant_service.out
|
||||
grep -rilnw "$i" -e "$WHICHR" | cut -d: -f1 | grep -oP "$i\K.*" &>>/tmp/openvas_GVM_redis_service.out
|
||||
fi
|
||||
done
|
||||
|
||||
manager_service="$(while IFS= read -r service; do
|
||||
systemctl list-unit-files | grep -P "(^|\s)\K$service(?=\s|$)" | awk '{print $1}'
|
||||
done < /tmp/openvas_GVM_manager_service.out)"
|
||||
scanner_service="$(while IFS= read -r service; do
|
||||
systemctl list-unit-files | grep -P "(^|\s)\K$service(?=\s|$)" | awk '{print $1}'
|
||||
done < /tmp/openvas_GVM_scanner_service.out)"
|
||||
assistant_service="$(while IFS= read -r service; do
|
||||
systemctl list-unit-files | grep -P "(^|\s)\K$service(?=\s|$)" | awk '{print $1}'
|
||||
done < /tmp/openvas_GVM_assistant_service.out)"
|
||||
redis_service="$(while IFS= read -r service; do
|
||||
systemctl list-unit-files | grep -P "(^|\s)\K$service(?=\s|$)" | awk '{print $1}'
|
||||
done < /tmp/openvas_GVM_redis_service.out)"
|
||||
|
||||
rm -rf /tmp/openvas_GVM*
|
||||
COUNTM=$(wc -w <<< "${manager_service}")
|
||||
COUNTS=$(wc -w <<< "${scanner_service}")
|
||||
COUNTA=$(wc -w <<< "${assistant_service}")
|
||||
COUNTR=$(wc -w <<< "${redis_service}")
|
||||
|
||||
if [ -n "$manager_service" ] && [ $manager -eq 1 ]; then
|
||||
if [ "$(systemctl list-unit-files | grep 'enabled' | grep $manager_service | awk '{print $1}')" = "$manager_service" ]; then
|
||||
echo "systemd --> OpenVAS Manager '$manager_service' found."
|
||||
else
|
||||
echo "systemd --> '$manager_service' found but not enabled."
|
||||
echo "are you sure this is the correct systemd service for Openvas Manager"
|
||||
while true; do
|
||||
read -n 1 -p "do you want to enable '$manager_service'? --> (Y)es | (N)o | (Q)uit" answer
|
||||
echo
|
||||
case $answer in
|
||||
[Yy]* ) systemctl enable "$manager_service" &>/dev/null; echo "systemd --> '$manager_service' enabled"; break;;
|
||||
[Nn]* ) manager_service=""; echo "it seems you are not sure.ok i don't use $manager_service"; break;;
|
||||
[Qq]* ) exit;;
|
||||
* ) echo "Please answer yes,no or quit.";;
|
||||
esac
|
||||
done
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -n "$scanner_service" ] && [ $scanner -eq 1 ]; then
|
||||
if [ "$(systemctl list-unit-files | grep 'enabled' | grep $scanner_service | awk '{print $1}')" = "$scanner_service" ]; then
|
||||
echo "systemd --> OpenVAS Scanner '$scanner_service' found."
|
||||
else
|
||||
echo "systemd --> '$scanner_service' found but not enabled."
|
||||
echo "are you sure this is the correct systemd service for Openvas Scanner"
|
||||
while true; do
|
||||
read -n 1 -p "do you want to enable '$scanner_service'? --> (Y)es | (N)o | (Q)uit" answer
|
||||
echo
|
||||
case $answer in
|
||||
[Yy]* ) systemctl enable "$scanner_service" &>/dev/null; echo "systemd --> '$scanner_service' enabled"; break;;
|
||||
[Nn]* ) scanner_service=""; echo "it seems you are not sure.ok i don't use $scanner_service"; break;;
|
||||
[Qq]* ) exit;;
|
||||
* ) echo "Please answer yes,no or quit.";;
|
||||
esac
|
||||
done
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -n "$assistant_service" ] && [ $scanner -eq 1 ]; then
|
||||
if [ "$(systemctl list-unit-files | grep 'enabled' | grep $assistant_service | awk '{print $1}')" = "$assistant_service" ]; then
|
||||
echo "systemd --> GSA '$assistant_service' found."
|
||||
else
|
||||
echo "systemd --> '$assistant_service' found but not enabled."
|
||||
echo "are you sure this is the correct systemd service for Greenbone Security Assistant"
|
||||
while true; do
|
||||
read -n 1 -p "do you want to enable '$assistant_service'? --> (Y)es | (N)o | (Q)uit" answer
|
||||
echo
|
||||
case $answer in
|
||||
[Yy]* ) systemctl enable "$assistant_service" &>/dev/null; echo "systemd --> '$assistant_service' enabled"; break;;
|
||||
[Nn]* ) assistant_service=""; echo "it seems you are not sure.ok i don't use $assistant_service"; break;;
|
||||
[Qq]* ) exit;;
|
||||
* ) echo "please answer yes,no or quit.";;
|
||||
esac
|
||||
done
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -n "$redis_service" ] && [ $scanner -eq 1 ]; then
|
||||
if [ "$(systemctl list-unit-files | grep 'enabled' | grep $redis_service | awk '{print $1}')" = "$redis_service" ]; then
|
||||
echo "systemd --> redis '$redis_service' found."
|
||||
else
|
||||
echo "systemd --> '$redis_service' found but not enabled."
|
||||
echo "are you sure this is the correct systemd service for redis-server"
|
||||
while true; do
|
||||
read -n 1 -p "do you want to enable '$redis_service'? --> (Y)es | (N)o | (Q)uit" answer
|
||||
echo
|
||||
case $answer in
|
||||
[Yy]* ) systemctl enable "$redis_service" &>/dev/null; echo "systemd --> '$redis_service' enabled"; break;;
|
||||
[Nn]* ) redis_service=""; echo "it seems you are not sure.ok i don't use $redis_service"; break;;
|
||||
[Qq]* ) exit;;
|
||||
* ) echo "please answer yes,no or quit.";;
|
||||
esac
|
||||
done
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ $COUNTM -gt 1 ] || [ $COUNTS -gt 1 ] || [ $COUNTR -gt 1 ]; then
|
||||
echo "you have more than one enabled systemd service for single daemon"
|
||||
echo " check OpenVAS and Redis systemd unit files to fix it"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
restart_redis () {
|
||||
if [ $redis -eq 0 ]; then
|
||||
systemctl restart redis.service &>/dev/null
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "systemd --> redis.service is restarted."
|
||||
else
|
||||
echo "systemd --> redis.service cannot restarted."
|
||||
exit 1
|
||||
fi
|
||||
elif [[ -n "$redis_service" ]]; then
|
||||
systemctl restart "$redis_service" &>/dev/null
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "systemd --> $redis_service is restarted."
|
||||
else
|
||||
echo "systemd --> $redis_service cannot restarted."
|
||||
exit 1
|
||||
fi
|
||||
elif [[ -n "$redis_init" ]]; then
|
||||
rc-service redis stop
|
||||
sleep 5
|
||||
rc-service redis start
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "open-rc --> redis is restarted."
|
||||
else
|
||||
echo "open-rc --> redis cannot restarted."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
build_nvt () {
|
||||
if ps aux | grep -v "grep" | grep -P "(^|\s)\Kopenvassd:(?=\s|$)" &>/dev/null; then
|
||||
ps aux | grep -v "grep" | grep -P "(^|\s)\Kopenvassd:(?=\s|$)" | awk '{print $2}' | xargs kill -9 &>/dev/null
|
||||
openvassd --foreground --only-cache &>/dev/null
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "building NVT cache is done."
|
||||
else
|
||||
echo "building NVT cache is failed.."
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
openvassd --foreground --only-cache &>/dev/null
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "building NVT cache is done."
|
||||
else
|
||||
echo "building NVT cache is failed.."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
create_user () {
|
||||
GREEN="`tput setaf 2`"
|
||||
RED="`tput setaf 1`"
|
||||
norm="`tput sgr0`"
|
||||
echo "creating WebUI User.."
|
||||
openvasmd --create-user=admin --role=Admin &>/tmp/openvas_user.out
|
||||
if [ $? -eq 0 ]; then
|
||||
username="admin"
|
||||
password="$(cat /tmp/openvas_user.out | awk '{print $5}' | cut -c2-)"
|
||||
echo "${RED}!WebUI Address : ${GREEN}127.0.0.1:9392"
|
||||
echo "${RED}!WebUI Username: ${GREEN}$username"
|
||||
echo "${RED}!WebUI Password: ${GREEN}${password%??}${norm}"
|
||||
else
|
||||
echo "$(cat /tmp/openvas_user.out)"
|
||||
echo "these are active users for WebUI"
|
||||
openvasmd --get-users
|
||||
fi
|
||||
rm -rf /tmp/openvas_user.out
|
||||
}
|
||||
|
||||
# Redis & OpenVAS Scanner socket connection check for Gentoo/Linux
|
||||
if [[ -e /etc/redis.conf ]]; then
|
||||
if [ "$(openvassd -s | grep 'kb_location' | awk '{print $3}')" = "$(cat /etc/redis.conf | grep -P '(^|\s)\Kunixsocket(?=\s|$)' | awk '{print $2}')" ]; then
|
||||
echo "redis server properly configured."
|
||||
else
|
||||
redis_sock="$(openvassd -s | grep 'kb_location' | awk '{print $3}')"
|
||||
echo "redis server is not properly configured."
|
||||
echo "be sure redis server listening unix socket at $redis_sock"
|
||||
echo "you can find example redis.conf file in /etc/openvas/redis.conf.example"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# Redis & OpenVAS Scanner socket connection check for other linux distros
|
||||
if [[ -e /etc/redis/redis.conf ]]; then
|
||||
if [ "$(openvassd -s | grep 'kb_location' | awk '{print $3}')" = "$(cat /etc/redis/redis.conf | grep -P '(^|\s)\Kunixsocket(?=\s|$)' | awk '{print $2}')" ]; then
|
||||
echo "redis server properly configured."
|
||||
else
|
||||
redis_sock="$(openvassd -s | grep 'kb_location' | awk '{print $3}')"
|
||||
echo "redis server is not properly configured."
|
||||
echo "be sure redis server listening unix socket at $redis_sock"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# Create certificates for fresh install
|
||||
openvas-manage-certs -a &>/dev/null
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "certificates created."
|
||||
|
||||
elif [ "$(openvas-manage-certs -a | grep -ow 'Existing')" = "Existing" ]; then
|
||||
echo "certificates already created."
|
||||
|
||||
else
|
||||
echo "certificates cannot created."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Start to update FEED & First NVT.
|
||||
try=0
|
||||
until [ $try -ge 5 ]; do
|
||||
greenbone-nvt-sync &>/dev/null && break
|
||||
echo "can't connected! trying to update greenbone-nvt again.."
|
||||
try=$[$try+1]
|
||||
sleep 30
|
||||
done
|
||||
|
||||
# Check status
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "greenbone-nvt-sync is done."
|
||||
# Avoid your IP temporary banned because of multiple connection
|
||||
sleep 5
|
||||
# Try to update scapdata.
|
||||
try=0
|
||||
until [ $try -ge 5 ]; do
|
||||
greenbone-scapdata-sync &>/dev/null && break
|
||||
echo "can't connected! trying to update greenbone-scapdata again.."
|
||||
try=$[$try+1]
|
||||
sleep 30
|
||||
done
|
||||
# Check status
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "greenbone-scapdata-sync is done."
|
||||
# Avoid your IP temporary banned because of multiple connection
|
||||
sleep 5
|
||||
# Try to update certdata
|
||||
try=0
|
||||
until [ $try -ge 5 ]; do
|
||||
greenbone-certdata-sync &>/dev/null && break
|
||||
echo "can't connected! Trying to update greenbone-certdata again.."
|
||||
try=$[$try+1]
|
||||
sleep 30
|
||||
done
|
||||
# Check status
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "greenbone-certdata-sync is done."
|
||||
echo "building NVT cache this will take some time.."
|
||||
build_nvt
|
||||
# Check OpenVAS-Scanner is running
|
||||
if ps aux | grep -v "grep" | grep -P "(^|\s)\Kopenvassd:(?=\s|$)" &>/dev/null; then
|
||||
echo "OpenVAS-Scanner is running."
|
||||
echo "building Database this will take some time.."
|
||||
openvasmd --rebuild --progress &>/dev/null
|
||||
elif [ $scanner -eq 0 ]; then
|
||||
# Start OpenVAS-Scanner systemd unit & Rebuild Cache
|
||||
echo "systemd --> OpenVAS-Scanner is not running! trying to up.."
|
||||
systemctl start openvas-scanner.service &>/dev/null
|
||||
if [ $? -eq 0 ]; then
|
||||
# Wait for initialize
|
||||
until [ "$(ps aux | grep -v 'grep' | grep -ow 'openvassd: Waiting')" = "openvassd: Waiting" ]; do
|
||||
sleep 15
|
||||
echo "waiting for OpenVAS-Scanner to become ready.."
|
||||
done
|
||||
echo "systemd --> openvas-scanner.service started and waiting for connection."
|
||||
echo "building database this will take some time.."
|
||||
# Rebuild Cache
|
||||
openvasmd --rebuild --progress &>/dev/null
|
||||
else
|
||||
echo "systemd --> openvas-scanner.service cannot started.."
|
||||
exit 1
|
||||
fi
|
||||
elif [[ -n "$scanner_service" ]]; then
|
||||
echo "systemd --> OpenVAS-Scanner is down! trying to up.."
|
||||
systemctl start "$scanner_service" &>/dev/null
|
||||
if [ $? -eq 0 ]; then
|
||||
# Wait for initialize
|
||||
until [ "$(ps aux | grep -v 'grep' | grep -ow 'openvassd: Waiting')" = "openvassd: Waiting" ]; do
|
||||
sleep 15
|
||||
echo "waiting for OpenVAS-Scanner to become ready.."
|
||||
done
|
||||
echo "systemd --> $scanner_service is started and waiting for connection."
|
||||
echo "building database this will take some time.."
|
||||
# Rebuild Cache
|
||||
openvasmd --rebuild --progress &>/dev/null
|
||||
else
|
||||
echo "systemd --> $scanner_service cannot started.."
|
||||
exit 1
|
||||
fi
|
||||
elif [[ -n "$scanner_init" ]]; then
|
||||
# Start OpenVAS-Scanner with init.d (open-rc) & Rebuild Cache
|
||||
echo "open-rc --> OpenVAS-Scanner is down! trying to up.."
|
||||
rc-service openvas-scanner start &>/dev/null
|
||||
if [ $? -eq 0 ]; then
|
||||
# Wait for initialize
|
||||
until [ "$(ps aux | grep -v 'grep' | grep -ow 'openvassd: Waiting')" = "openvassd: Waiting" ]; do
|
||||
sleep 15
|
||||
echo "waiting for OpenVAS-Scanner to become ready.."
|
||||
done
|
||||
echo "rc-service --> openvas-scanner started and waiting for connection."
|
||||
echo "building database this will take some time.."
|
||||
# Rebuild Cache
|
||||
openvasmd --rebuild --progress &>/dev/null
|
||||
else
|
||||
echo "rc-service --> openvas-scanner cannot started.."
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo "OpenVAS-Scanner is not running! Trying to up.."
|
||||
openvassd "$OPENVAS_SCANNER_OPTIONS" "$OPENVAS_SCANNER_LISTEN_SOCKET" &>/dev/null
|
||||
# Wait for initialize
|
||||
if [ $? -eq 0 ]; then
|
||||
until [ "$(ps aux | grep -v 'grep' | grep -ow 'openvassd: Waiting')" = "openvassd: Waiting" ]; do
|
||||
sleep 15
|
||||
echo "waiting for OpenVAS-Scanner to become ready.."
|
||||
done
|
||||
else
|
||||
echo "OpenVAS Scanner cannot started manually.."
|
||||
exit 1
|
||||
fi
|
||||
echo "OpenVAS-Scanner started manually and waiting for connection."
|
||||
echo "building database this will take some time.."
|
||||
# Rebuild Cache
|
||||
openvasmd --rebuild --progress &>/dev/null
|
||||
fi
|
||||
# Check status
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "building database is done"
|
||||
create_user
|
||||
# Restart OpenVAS-Scanner
|
||||
if [ $scanner -eq 0 ]; then
|
||||
ps aux | grep -v "grep" | grep -P "(^|\s)\Kopenvassd:(?=\s|$)" | awk '{print $2}' | xargs kill -9 &>/dev/null
|
||||
restart_redis
|
||||
sleep 3
|
||||
systemctl restart openvas-scanner.service &>/dev/null
|
||||
elif [[ -n "$scanner_service" ]]; then
|
||||
ps aux | grep -v "grep" | grep -P "(^|\s)\Kopenvassd:(?=\s|$)" | awk '{print $2}' | xargs kill -9 &>/dev/null
|
||||
restart_redis
|
||||
sleep 3
|
||||
systemctl restart "$scanner_service" &>/dev/null
|
||||
elif [[ -n "$scanner_init" ]]; then
|
||||
ps aux | grep -v "grep" | grep -P "(^|\s)\Kopenvassd:(?=\s|$)" | awk '{print $2}' | xargs kill -9 &>/dev/null
|
||||
restart_redis
|
||||
sleep 3
|
||||
rc-service openvas-scanner start &>/dev/null
|
||||
else
|
||||
ps aux | grep -v "grep" | grep -P "(^|\s)\Kopenvassd:(?=\s|$)" | awk '{print $2}' | xargs kill -9 &>/dev/null
|
||||
restart_redis
|
||||
sleep 3
|
||||
openvassd "$OPENVAS_SCANNER_OPTIONS" "$OPENVAS_SCANNER_LISTEN_SOCKET" &>/dev/null
|
||||
fi
|
||||
if [ $? -eq 0 ]; then
|
||||
until [ "$(ps aux | grep -v 'grep' | grep -ow 'openvassd: Waiting')" = "openvassd: Waiting" ]; do
|
||||
sleep 10
|
||||
echo "waiting for OpenVAS-Scanner to become ready.."
|
||||
done
|
||||
echo "OpenVAS-Scanner is restarted."
|
||||
# Restart OpenVAS-Manager
|
||||
if [ $manager -eq 0 ]; then
|
||||
ps aux | grep -v "grep" | grep -P "(^|\s)\Kopenvasmd(?=\s|$)" | awk '{print $2}' | xargs kill -9 &>/dev/null
|
||||
sleep 5
|
||||
systemctl restart gvmd.service &>/dev/null
|
||||
if [ $? -eq 0 ]; then
|
||||
success="0"
|
||||
echo "systemd --> gvmd.service is restarted."
|
||||
echo "OpenVAS setup is ok."
|
||||
else
|
||||
echo "systemd --> gvmd.service cannot restarted."
|
||||
echo "OpenVAS setup is not ok!"
|
||||
exit 1
|
||||
fi
|
||||
elif [[ -n "$manager_service" ]]; then
|
||||
ps aux | grep -v "grep" | grep -P "(^|\s)\Kopenvasmd(?=\s|$)" | awk '{print $2}' | xargs kill -9 &>/dev/null
|
||||
sleep 5
|
||||
systemctl restart "$manager_service" &>/dev/null
|
||||
if [ $? -eq 0 ]; then
|
||||
success="0"
|
||||
echo "systemd --> $manager_service is restarted"
|
||||
echo "OpenVAS setup is ok."
|
||||
else
|
||||
echo "systemd --> $manager_service cannot restarted"
|
||||
echo "OpenVAS setup is not ok!"
|
||||
exit 1
|
||||
fi
|
||||
elif [[ -n "$manager_init" ]]; then
|
||||
ps aux | grep -v "grep" | grep -P "(^|\s)\Kopenvasmd(?=\s|$)" | awk '{print $2}' | xargs kill -9 &>/dev/null
|
||||
sleep 5
|
||||
rc-service gvmd start &>/dev/null
|
||||
if [ $? -eq 0 ]; then
|
||||
success="0"
|
||||
echo "open-rc --> gvmd is restarted"
|
||||
echo "OpenVAS setup is ok."
|
||||
else
|
||||
echo "open-rc --> gvmd cannot restarted"
|
||||
echo "OpenVAS setup is not ok!"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
ps aux | grep -v "grep" | grep -P "(^|\s)\Kopenvasmd(?=\s|$)" | awk '{print $2}' | xargs kill -9 &>/dev/null
|
||||
sleep 5
|
||||
openvasmd "$OPENVAS_MANAGER_OPTIONS" "$OPENVAS_MANAGER_PORT" "$OPENVAS_MANAGER_LISTEN_ADDRESS" "$OPENVAS_MANAGER_SCANNER_HOST" "$OPENVAS_MANAGER_GNUTLS_PRIORITIES" &>/dev/null
|
||||
if [ $? -eq 0 ]; then
|
||||
success="0"
|
||||
echo "OpenVAS-Manager is restarted manually"
|
||||
echo "OpenVAS setup is ok."
|
||||
else
|
||||
echo "OpenVAS-Manager cannot restarted"
|
||||
echo "OpenVAS setup is not ok!"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
else
|
||||
echo "OpenVAS setup is not ok! OpenVAS-scanner cannot restarted."
|
||||
fi
|
||||
else
|
||||
echo "OpenVAS setup is not ok! OpenVAS database build failed."
|
||||
fi
|
||||
else
|
||||
echo "OpenVAS setup is not ok! OpenVAS Certdata sync failed."
|
||||
fi
|
||||
else
|
||||
echo "OpenVAS setup is not ok! OpenVAS Scapdata sync failed."
|
||||
fi
|
||||
else
|
||||
echo "OpenVAS setup is not ok! OpenVAS NVT sync update failed."
|
||||
fi
|
||||
|
||||
# Restart WebUI
|
||||
if [[ -n "$success" ]] && [ $gsad -eq 0 ]; then
|
||||
WHICHA="$(type gsad | awk '{print $3}')"
|
||||
if [ $assistant -eq 0 ]; then
|
||||
# Time to restart OpenVAS-Security Assistant
|
||||
ps aux | grep -v "grep" | grep -P "(^|\s)\K$WHICHA(?=\s|$)" | awk '{print $2}' | xargs kill -9 &>/dev/null
|
||||
sleep 5
|
||||
systemctl restart gsa.service &>/dev/null
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "systemd --> gsa.service (OpenVAS WebUI) is restarted and ready for connection"
|
||||
else
|
||||
echo "systemd --> gsa.service (OpenVAS-WebUI) cannot restarted"
|
||||
fi
|
||||
elif [[ -n "$assistant_service" ]]; then
|
||||
if [ $COUNTA -eq 1 ]; then
|
||||
ps aux | grep -v "grep" | grep -P "(^|\s)\K$WHICHA(?=\s|$)" | awk '{print $2}' | xargs kill -9 &>/dev/null
|
||||
sleep 5
|
||||
systemctl restart "$assistant_service" &>/dev/null
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "systemd --> $assistant_service (OpenVAS WebUI) is restarted and ready for connection"
|
||||
else
|
||||
echo "systemd --> $assistan_service (OpenVAS WebUI) cannot restarted."
|
||||
fi
|
||||
else
|
||||
echo "systemd --> OpenVAS WebUI cannot restarted! you have multiple enabled systemd services ($assistant_service)"
|
||||
exit 1
|
||||
fi
|
||||
elif [[ -n "$assistant_init" ]]; then
|
||||
ps aux | grep -v "grep" | grep -P "(^|\s)\K$WHICHA(?=\s|$)" | awk '{print $2}' | xargs kill -9 &>/dev/null
|
||||
sleep 5
|
||||
rc-service gsa start &>/dev/null
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "open-rc --> gsa (OpenVAS WebUI) is restarted"
|
||||
else
|
||||
echo "open-rc --> gsa (OpenVAS WebUI) cannot restarted."
|
||||
fi
|
||||
else
|
||||
ps aux | grep -v "grep" | grep -P "(^|\s)\K$WHICHA(?=\s|$)" | awk '{print $2}' | xargs kill -9 &>/dev/null
|
||||
sleep 5
|
||||
gsad "$OPENVAS_SECURITY_ASSISTANT_OPTIONS" "$OPENVAS_SECURITY_ASSISTANT_LISTEN_ADDRESS" "$OPENVAS_SECURITY_ASSISTANT_LISTEN_PORT" "$OPENVAS_SECURITY_ASSISTANT_MANAGER_LISTEN_ADDRESS" "$OPENVAS_SECURITY_ASSISTANT_MANAGER_LISTEN_PORT" "$OPENVAS_SECURITY_ASSISTANT_GNUTLS_PRIORITIES" &>/dev/null
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "OpenVAS WebUI is restarted"
|
||||
else
|
||||
echo "OpenVAS WebUI cannot restarted"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
@@ -1,627 +0,0 @@
|
||||
#!/bin/bash
|
||||
# Copyright 1999-2019 Gentoo Authors
|
||||
# Distributed under the terms of the GNU General Public License v2
|
||||
# This is OpenVAS cron script that updates feed and reload daemons.
|
||||
# Hasan ÇALIŞIR hsntgm@gmail.com | proxy maintainer
|
||||
|
||||
# Mail settings
|
||||
MAIL_TO="root"
|
||||
MAIL_SUBJECT="CronJob-OpenVAS"
|
||||
|
||||
# If you don't use systemd or open-rc for OpenVAS daemons you can set start command args here
|
||||
# while we manually start/restart them.
|
||||
####################################################################################################
|
||||
|
||||
# OpenVAS Manager command args
|
||||
OPENVAS_MANAGER_OPTIONS="" # e.g --foreground
|
||||
OPENVAS_MANAGER_PORT="--port=9390" # Manager listen port
|
||||
OPENVAS_MANAGER_LISTEN_ADDRESS="--listen=127.0.0.1" # Manager listen address
|
||||
OPENVAS_MANAGER_SCANNER_HOST="--scanner-host=/var/run/openvassd.sock" # Scanner unix socket
|
||||
OPENVAS_MANAGER_GNUTLS_PRIORITIES="--gnutls-priorities=SECURE256:+SUITEB192:+SECURE192:+SECURE128:+SUITEB128:-MD5:-SHA1:-VERS-TLS1.0:-VERS-TLS1.1:-VERS-SSL3.0"
|
||||
|
||||
# OpenVAS Scanner command args
|
||||
OPENVAS_SCANNER_OPTIONS="" # e.g --foreground
|
||||
OPENVAS_SCANNER_LISTEN_SOCKET="--unix-socket=/var/run/openvassd.sock" # Scanner listen socket
|
||||
|
||||
# OpenVAS Security Assistant command args for reverse proxying | SSL PassThrough
|
||||
OPENVAS_SECURITY_ASSISTANT_OPTIONS="--no-redirect" # Don't listen port 80 anymore
|
||||
OPENVAS_SECURITY_ASSISTANT_LISTEN_ADDRESS="--listen=127.0.0.1" # WebUI adress
|
||||
OPENVAS_SECURITY_ASSISTANT_LISTEN_PORT="--port=9392" # WebUI Port
|
||||
OPENVAS_SECURITY_ASSISTANT_MANAGER_LISTEN_ADDRESS="--mlisten=127.0.0.1" # WebUI Manager Address
|
||||
OPENVAS_SECURITY_ASSISTANT_MANAGER_PORT="--mport=9390" # WebUI Manager Port
|
||||
OPENVAS_SECURITY_ASSISTANT_GNUTLS_PRIORITIES="--gnutls-priorities=NORMAL" # TLS Settings
|
||||
|
||||
#####################################################################################################
|
||||
|
||||
# Update Environment
|
||||
source /etc/profile &>/dev/null
|
||||
source /etc/environment &>/dev/null
|
||||
source ~/.bash_profile &>/dev/null
|
||||
|
||||
# Check the needed executables if they are in our environment and have +x
|
||||
if ! [ -x "$(command -v openvasmd)" ] || ! [ -x "$(command -v openvassd)" ] || ! [ -x "$(command -v redis-server)" ]; then
|
||||
path="1"
|
||||
else
|
||||
path="0"
|
||||
fi
|
||||
|
||||
# Check Security-Assistant is exist
|
||||
if ! [ -x "$(command -v gsad)" ]; then
|
||||
gsad="1"
|
||||
else
|
||||
gsad="0"
|
||||
fi
|
||||
|
||||
# Executables are not in our environment
|
||||
if [ $path -eq 1 ]; then
|
||||
echo "OpenVAS CronJob Failed! If you installed OpenVAS to specific location e.g. /opt" | tee -a /tmp/openvas_mail.out
|
||||
echo "please add these PATHS to /etc/profile e.g. 'PATH=$PATH:/opt/openvas/bin:/opt/openvas/sbin'" | tee -a /tmp/openvas_mail.out
|
||||
echo "also sure that they are executable e.g. 'chmod +x /opt/openvas/sbin/openvassd'" | tee -a /tmp/openvas_mail.out
|
||||
echo -e "Subject:$MAIL_SUBJECT\n$(cat /tmp/openvas_mail.out)" | sendmail -t "$MAIL_TO" &>/dev/null
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check systemd if exist
|
||||
if command -v systemctl &>/dev/null; then
|
||||
systemctl="0"
|
||||
else
|
||||
systemctl="1"
|
||||
fi
|
||||
|
||||
# Check open-rc if exist
|
||||
if command -v rc-service &>/dev/null; then
|
||||
open_rc="0"
|
||||
else
|
||||
open_rc="1"
|
||||
fi
|
||||
|
||||
# open-rc variables
|
||||
if [ $systemctl -eq 1 ] && [ $open_rc -eq 0 ]; then
|
||||
scanner_init="0"
|
||||
manager_init="0"
|
||||
assistant_init="0"
|
||||
redis_init="0"
|
||||
fi
|
||||
|
||||
# Check OpenVAS-Scanner systemd unit(common name) is active or enabled
|
||||
if [ $systemctl -eq 0 ] && ([ "$(systemctl is-active openvassd.service)" = "active" ] || [ "$(systemctl list-unit-files | grep 'enabled' | grep 'openvassd.service' | awk '{print $1}')" = "openvassd.service" ]); then
|
||||
scanner="0"
|
||||
else
|
||||
scanner="1"
|
||||
fi
|
||||
|
||||
# Check OpenVAS-Manager systemd unit(common name) is active or enabled
|
||||
if [ $systemctl -eq 0 ] && ([ "$(systemctl is-active openvasmd.service)" = "active" ] || [ "$(systemctl list-unit-files | grep 'enabled' | grep 'openvasmd.service' | awk '{print $1}')" = "openvasmd.service" ]); then
|
||||
manager="0"
|
||||
else
|
||||
manager="1"
|
||||
fi
|
||||
|
||||
# Check OpenVAS-Assistant systemd unit(common name) is active or not
|
||||
if [ $systemctl -eq 0 ] && ([ "$(systemctl is-active gsad.service)" = "active" ] || [ "$(systemctl list-unit-files | grep 'enabled' | grep 'gsad.service' | awk '{print $1}')" = "gsad.service" ]); then
|
||||
assistant="0"
|
||||
else
|
||||
assistant="1"
|
||||
fi
|
||||
|
||||
# Check Redis systemd unit(common name) is active or not
|
||||
if [ $systemctl -eq 0 ] && ([ "$(systemctl is-active redis.service)" = "active" ] || [ "$(systemctl list-unit-files | grep 'enabled' | grep 'redis.service' | awk '{print $1}')" = "redis.service" ]); then
|
||||
redis="0"
|
||||
else
|
||||
redis="1"
|
||||
fi
|
||||
|
||||
# If you don't use common systemd service names for OpenVAS
|
||||
# We need to find correct service name for restarting.
|
||||
if [ $scanner -eq 1 ] || [ $manager -eq 1 ]; then
|
||||
WHICHM="ExecStart=$(type openvasmd | awk '{print $3}')"
|
||||
WHICHS="ExecStart=$(type openvassd | awk '{print $3}')"
|
||||
WHICHA="ExecStart=$(type gsad | awk '{print $3}')"
|
||||
WHICHR="ExecStart=$(type redis-server | awk '{print $3}')"
|
||||
|
||||
# If you have unordinary systemd services PATH you can add here
|
||||
DIR="/lib/systemd/system/
|
||||
/etc/systemd/system/
|
||||
/usr/lib/systemd/system/
|
||||
/usr/local/lib/systemd/system/"
|
||||
|
||||
# Find OpenVAS daemons systemd files
|
||||
for i in $DIR; do
|
||||
if [ -d "$i" ]; then
|
||||
grep -rilnw "$i" -e "$WHICHM" | cut -d: -f1 | grep -oP "$i\K.*" &>>/tmp/openvas_GVM_manager_service.out
|
||||
grep -rilnw "$i" -e "$WHICHS" | cut -d: -f1 | grep -oP "$i\K.*" &>>/tmp/openvas_GVM_scanner_service.out
|
||||
grep -rilnw "$i" -e "$WHICHA" | cut -d: -f1 | grep -oP "$i\K.*" &>>/tmp/openvas_GVM_assistant_service.out
|
||||
grep -rilnw "$i" -e "$WHICHR" | cut -d: -f1 | grep -oP "$i\K.*" &>>/tmp/openvas_GVM_redis_service.out
|
||||
fi
|
||||
done
|
||||
|
||||
# Time to get our exact systemd service searching in enabled services
|
||||
manager_service="$(while IFS= read -r service; do
|
||||
systemctl list-unit-files | grep "enabled" | grep -P "(^|\s)\K$service(?=\s|$)" | awk '{print $1}'
|
||||
done < /tmp/openvas_GVM_manager_service.out)"
|
||||
|
||||
scanner_service="$(while IFS= read -r service; do
|
||||
systemctl list-unit-files | grep "enabled" | grep -P "(^|\s)\K$service(?=\s|$)" | awk '{print $1}'
|
||||
done < /tmp/openvas_GVM_scanner_service.out)"
|
||||
|
||||
assistant_service="$(while IFS= read -r service; do
|
||||
systemctl list-unit-files | grep "enabled" | grep -P "(^|\s)\K$service(?=\s|$)" | awk '{print $1}'
|
||||
done < /tmp/openvas_GVM_assistant_service.out)"
|
||||
|
||||
redis_service="$(while IFS= read -r service; do
|
||||
systemctl list-unit-files | grep "enabled" | grep -P "(^|\s)\K$service(?=\s|$)" | awk '{print $1}'
|
||||
done < /tmp/openvas_GVM_redis_service.out)"
|
||||
|
||||
rm -rf /tmp/openvas_GVM*
|
||||
COUNTM=$(wc -w <<< "${manager_service}")
|
||||
COUNTS=$(wc -w <<< "${scanner_service}")
|
||||
COUNTA=$(wc -w <<< "${assistant_service}")
|
||||
COUNTR=$(wc -w <<< "${redis_service}")
|
||||
|
||||
if [ $COUNTM -gt 1 ] || [ $COUNTS -gt 1 ] || [ $COUNTR -gt 1 ]; then
|
||||
echo "OpenVAS CronJob Failed! You have multiple enabled systemd service for single OpenVAS daemon or redis" | tee -a /tmp/openvas_mail.out
|
||||
echo -e "Subject:$MAIL_SUBJECT\n$(cat /tmp/openvas_mail.out)" | sendmail -t "$MAIL_TO" &>/dev/null
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# Start to update FEED & First NVT.
|
||||
try=0
|
||||
until [ $try -ge 5 ]; do
|
||||
greenbone-nvt-sync &>/dev/null && break
|
||||
echo "Can't connected! Trying to update greenbone-nvt again.." &>>/tmp/openvas_mail.out
|
||||
try=$[$try+1]
|
||||
sleep 30
|
||||
done
|
||||
|
||||
# Check status
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "greenbone-nvt-sync is done" &>>/tmp/openvas_mail.out
|
||||
# Avoid your IP temporary banned because of multiple connection
|
||||
sleep 5
|
||||
# Try to update scapdata.
|
||||
try=0
|
||||
until [ $try -ge 5 ]; do
|
||||
greenbone-scapdata-sync &>/dev/null && break
|
||||
echo "Can't connected! Trying to update greenbone-scapdata again.." &>>/tmp/openvas_mail.out
|
||||
try=$[$try+1]
|
||||
sleep 30
|
||||
done
|
||||
|
||||
# Check status
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "greenbone-scapdata-sync is done" &>>/tmp/openvas_mail.out
|
||||
# Avoid your IP temporary banned because of multiple connection
|
||||
sleep 5
|
||||
# Try to update certdata
|
||||
try=0
|
||||
until [ $try -ge 5 ]; do
|
||||
greenbone-certdata-sync &>/dev/null && break
|
||||
echo "Can't connected! Trying to update greenbone-certdata again.." &>>/tmp/openvas_mail.out
|
||||
try=$[$try+1]
|
||||
sleep 30
|
||||
done
|
||||
|
||||
# Check status
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "greenbone-certdata-sync is done" &>>/tmp/openvas_mail.out
|
||||
|
||||
# Check OpenVAS-Scanner is running
|
||||
if ps aux | grep -v "grep" | grep -P "(^|\s)\Kopenvassd:(?=\s|$)" &>/dev/null; then
|
||||
echo "OpenVAS-Scanner is running." &>>/tmp/openvas_mail.out
|
||||
openvasmd --update --progress &>/dev/null
|
||||
|
||||
elif [ $scanner -eq 0 ]; then
|
||||
# Start OpenVAS-Scanner systemd unit & Rebuild Cache
|
||||
echo "OpenVAS-Scanner is down! Trying to up.." &>>/tmp/openvas_mail.out
|
||||
systemctl start openvassd.service &>/dev/null
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
# Wait for initialize
|
||||
until [ "$(ps aux | grep -v 'grep' | grep -ow 'openvassd: Waiting')" = "openvassd: Waiting" ]; do
|
||||
sleep 15
|
||||
echo "Waiting for OpenVAS-Scanner to become ready.." &>>/tmp/openvas_mail.out
|
||||
done
|
||||
echo "openvassd.service started and waiting for connection." &>>/tmp/openvas_mail.out
|
||||
# Rebuild Cache
|
||||
openvasmd --update --progress &>/dev/null
|
||||
else
|
||||
echo "openvassd.service cannot started.." | tee -a /tmp/openvas_mail.out
|
||||
echo -e "Subject:$MAIL_SUBJECT\n$(cat /tmp/openvas_mail.out)" | sendmail -t "$MAIL_TO" &>/dev/null
|
||||
exit 1
|
||||
fi
|
||||
|
||||
elif [[ -n "$scanner_service" ]]; then
|
||||
echo "OpenVAS-Scanner is down! Trying to up.." &>>/tmp/openvas_mail.out
|
||||
systemctl start "$scanner_service" &>/dev/null
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
# Wait for initialize
|
||||
until [ "$(ps aux | grep -v 'grep' | grep -ow 'openvassd: Waiting')" = "openvassd: Waiting" ]; do
|
||||
sleep 15
|
||||
echo "Waiting for OpenVAS-Scanner to become ready.." &>>/tmp/openvas_mail.out
|
||||
done
|
||||
echo "$scanner_service is started and waiting for connection." &>>/tmp/openvas_mail.out
|
||||
# Rebuild Cache
|
||||
openvasmd --update --progress &>/dev/null
|
||||
else
|
||||
echo "$scanner_service cannot started.." | tee -a /tmp/openvas_mail.out
|
||||
echo -e "Subject:$MAIL_SUBJECT\n$(cat /tmp/openvas_mail.out)" | sendmail -t "$MAIL_TO" &>/dev/null
|
||||
exit 1
|
||||
fi
|
||||
|
||||
elif [[ -n "$scanner_init" ]]; then
|
||||
# Start OpenVAS-Scanner with init.d (open-rc) & Rebuild Cache
|
||||
echo "OpenVAS-Scanner is down! Trying to up.." &>>/tmp/openvas_mail.out
|
||||
rc-service openvassd start &>/dev/null
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
# Wait for initialize
|
||||
until [ "$(ps aux | grep -v 'grep' | grep -ow 'openvassd: Waiting')" = "openvassd: Waiting" ]; do
|
||||
sleep 15
|
||||
echo "Waiting for OpenVAS-Scanner to become ready.." &>>/tmp/openvas_mail.out
|
||||
done
|
||||
echo "rc-service --> openvassd started and waiting for connection." &>>/tmp/openvas_mail.out
|
||||
# Rebuild Cache
|
||||
openvasmd --update --progress &>/dev/null
|
||||
else
|
||||
echo "rc-service --> openvassd cannot started.." | tee -a /tmp/openvas_mail.out
|
||||
echo -e "Subject:$MAIL_SUBJECT\n$(cat /tmp/openvas_mail.out)" | sendmail -t "$MAIL_TO" &>/dev/null
|
||||
exit 1
|
||||
fi
|
||||
|
||||
else
|
||||
echo "OpenVAS-Scanner is down! Trying to up.." &>>/tmp/openvas_mail.out
|
||||
openvassd "$OPENVAS_SCANNER_OPTIONS" "$OPENVAS_SCANNER_LISTEN_SOCKET" &>/dev/null
|
||||
# Wait for initialize
|
||||
if [ $? -eq 0 ]; then
|
||||
until [ "$(ps aux | grep -v 'grep' | grep -ow 'openvassd: Waiting')" = "openvassd: Waiting" ]; do
|
||||
sleep 15
|
||||
echo "Waiting for OpenVAS-Scanner to become ready.." &>>/tmp/openvas_mail.out
|
||||
done
|
||||
else
|
||||
echo "OpenVAS Scanner cannot started manually.." | tee -a /tmp/openvas_mail.out
|
||||
echo -e "Subject:$MAIL_SUBJECT\n$(cat /tmp/openvas_mail.out)" | sendmail -t "$MAIL_TO" &>/dev/null
|
||||
exit 1
|
||||
fi
|
||||
echo "OpenVAS-Scanner started manually and waiting for connection." &>>/tmp/openvas_mail.out
|
||||
# Rebuild Cache
|
||||
openvasmd --update --progress &>/dev/null
|
||||
fi
|
||||
|
||||
# Check status
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Updating NVT cache is done" &>>/tmp/openvas_mail.out
|
||||
|
||||
# Restart OpenVAS-Scanner
|
||||
if [ $scanner -eq 0 ]; then
|
||||
ps aux | grep -v "grep" | grep -P "(^|\s)\Kopenvassd:(?=\s|$)" | awk '{print $2}' | xargs kill -9 &>/dev/null
|
||||
sleep 3
|
||||
|
||||
# Try to restart redis service before OpenVAS-Scanner
|
||||
if [ $redis -eq 0 ]; then
|
||||
systemctl restart redis.service &>/dev/null
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "systemd --> redis.service is restarted." &>>/tmp/openvas_mail.out
|
||||
else
|
||||
echo "systemd --> redis.service cannot restarted." | tee -a /tmp/openvas_mail.out
|
||||
echo -e "Subject:$MAIL_SUBJECT\n$(cat /tmp/openvas_mail.out)" | sendmail -t "$MAIL_TO" &>/dev/null
|
||||
exit 1
|
||||
fi
|
||||
|
||||
elif [[ -n "$redis_service" ]]; then
|
||||
systemctl restart "$redis_service" &>/dev/null
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "systemd --> $redis_service is restarted." &>>/tmp/openvas_mail.out
|
||||
else
|
||||
echo "systemd --> $redis_service cannot restarted." | tee -a /tmp/openvas_mail.out
|
||||
echo -e "Subject:$MAIL_SUBJECT\n$(cat /tmp/openvas_mail.out)" | sendmail -t "$MAIL_TO" &>/dev/null
|
||||
exit 1
|
||||
fi
|
||||
|
||||
elif [[ -n "$redis_init" ]]; then
|
||||
rc-service redis stop
|
||||
sleep 5
|
||||
rc-service redis start
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "open-rc --> redis is restarted." &>>/tmp/openvas_mail.out
|
||||
else
|
||||
echo "open-rc --> redis cannot restarted." | tee -a /tmp/openvas_mail.out
|
||||
echo -e "Subject:$MAIL_SUBJECT\n$(cat /tmp/openvas_mail.out)" | sendmail -t "$MAIL_TO" &>/dev/null
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
systemctl restart openvassd.service &>/dev/null
|
||||
|
||||
elif [[ -n "$scanner_service" ]]; then
|
||||
ps aux | grep -v "grep" | grep -P "(^|\s)\Kopenvassd:(?=\s|$)" | awk '{print $2}' | xargs kill -9 &>/dev/null
|
||||
sleep 3
|
||||
|
||||
# Try to restart redis service before OpenVAS-Scanner
|
||||
if [ $redis -eq 0 ]; then
|
||||
systemctl restart redis.service &>/dev/null
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "systemd --> redis.service is restarted." &>>/tmp/openvas_mail.out
|
||||
else
|
||||
echo "systemd --> redis.service cannot restarted." | tee -a /tmp/openvas_mail.out
|
||||
echo -e "Subject:$MAIL_SUBJECT\n$(cat /tmp/openvas_mail.out)" | sendmail -t "$MAIL_TO" &>/dev/null
|
||||
exit 1
|
||||
fi
|
||||
|
||||
elif [[ -n "$redis_service" ]]; then
|
||||
systemctl restart "$redis_service" &>/dev/null
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "systemd --> $redis_service is restarted." &>>/tmp/openvas_mail.out
|
||||
else
|
||||
echo "systemd --> $redis_service cannot restarted." | tee -a /tmp/openvas_mail.out
|
||||
echo -e "Subject:$MAIL_SUBJECT\n$(cat /tmp/openvas_mail.out)" | sendmail -t "$MAIL_TO" &>/dev/null
|
||||
exit 1
|
||||
fi
|
||||
|
||||
elif [[ -n "$redis_init" ]]; then
|
||||
rc-service redis stop
|
||||
sleep 5
|
||||
rc-service redis start
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "open-rc --> redis is restarted." &>>/tmp/openvas_mail.out
|
||||
else
|
||||
echo "open-rc --> redis cannot restarted." | tee -a /tmp/openvas_mail.out
|
||||
echo -e "Subject:$MAIL_SUBJECT\n$(cat /tmp/openvas_mail.out)" | sendmail -t "$MAIL_TO" &>/dev/null
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
systemctl restart "$scanner_service" &>/dev/null
|
||||
|
||||
elif [[ -n "$scanner_init" ]]; then
|
||||
ps aux | grep -v "grep" | grep -P "(^|\s)\Kopenvassd:(?=\s|$)" | awk '{print $2}' | xargs kill -9 &>/dev/null
|
||||
sleep 3
|
||||
|
||||
# Try to restart redis service before OpenVAS-Scanner
|
||||
if [ $redis -eq 0 ]; then
|
||||
systemctl restart redis.service &>/dev/null
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "systemd --> redis.service is restarted." &>>/tmp/openvas_mail.out
|
||||
else
|
||||
echo "systemd --> redis.service cannot restarted." | tee -a /tmp/openvas_mail.out
|
||||
echo -e "Subject:$MAIL_SUBJECT\n$(cat /tmp/openvas_mail.out)" | sendmail -t "$MAIL_TO" &>/dev/null
|
||||
exit 1
|
||||
fi
|
||||
|
||||
elif [[ -n "$redis_service" ]]; then
|
||||
systemctl restart "$redis_service" &>/dev/null
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "systemd --> $redis_service is restarted." &>>/tmp/openvas_mail.out
|
||||
else
|
||||
echo "systemd --> $redis_service cannot restarted." | tee -a /tmp/openvas_mail.out
|
||||
echo -e "Subject:$MAIL_SUBJECT\n$(cat /tmp/openvas_mail.out)" | sendmail -t "$MAIL_TO" &>/dev/null
|
||||
exit 1
|
||||
fi
|
||||
|
||||
elif [[ -n "$redis_init" ]]; then
|
||||
rc-service redis stop
|
||||
sleep 5
|
||||
rc-service redis start
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "open-rc --> redis is restarted." &>>/tmp/openvas_mail.out
|
||||
else
|
||||
echo "open-rc --> redis cannot restarted." | tee -a /tmp/openvas_mail.out
|
||||
echo -e "Subject:$MAIL_SUBJECT\n$(cat /tmp/openvas_mail.out)" | sendmail -t "$MAIL_TO" &>/dev/null
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
rc-service openvassd start &>/dev/null
|
||||
|
||||
else
|
||||
ps aux | grep -v "grep" | grep -P "(^|\s)\Kopenvassd:(?=\s|$)" | awk '{print $2}' | xargs kill -9 &>/dev/null
|
||||
sleep 3
|
||||
|
||||
# Try to restart redis service before OpenVAS-Scanner
|
||||
if [ $redis -eq 0 ]; then
|
||||
systemctl restart redis.service &>/dev/null
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "systemd --> redis.service is restarted." &>>/tmp/openvas_mail.out
|
||||
else
|
||||
echo "systemd --> redis.service cannot restarted." | tee -a /tmp/openvas_mail.out
|
||||
echo -e "Subject:$MAIL_SUBJECT\n$(cat /tmp/openvas_mail.out)" | sendmail -t "$MAIL_TO" &>/dev/null
|
||||
exit 1
|
||||
fi
|
||||
|
||||
elif [[ -n "$redis_service" ]]; then
|
||||
systemctl restart "$redis_service" &>/dev/null
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "systemd --> $redis_service is restarted." &>>/tmp/openvas_mail.out
|
||||
else
|
||||
echo "systemd --> $redis_service cannot restarted." | tee -a /tmp/openvas_mail.out
|
||||
echo -e "Subject:$MAIL_SUBJECT\n$(cat /tmp/openvas_mail.out)" | sendmail -t "$MAIL_TO" &>/dev/null
|
||||
exit 1
|
||||
fi
|
||||
|
||||
elif [[ -n "$redis_init" ]]; then
|
||||
rc-service redis stop
|
||||
sleep 5
|
||||
rc-service redis start
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "open-rc --> redis is restarted." &>>/tmp/openvas_mail.out
|
||||
else
|
||||
echo "open-rc --> redis cannot restarted." | tee -a /tmp/openvas_mail.out
|
||||
echo -e "Subject:$MAIL_SUBJECT\n$(cat /tmp/openvas_mail.out)" | sendmail -t "$MAIL_TO" &>/dev/null
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
openvassd "$OPENVAS_SCANNER_OPTIONS" "$OPENVAS_SCANNER_LISTEN_SOCKET" &>/dev/null
|
||||
fi
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
until [ "$(ps aux | grep -v 'grep' | grep -ow 'openvassd: Waiting')" = "openvassd: Waiting" ]; do
|
||||
sleep 10
|
||||
echo "Waiting for OpenVAS-Scanner to become ready.." &>>/tmp/openvas_mail.out
|
||||
done
|
||||
echo "OpenVAS-Scanner is restarted." &>>/tmp/openvas_mail.out
|
||||
|
||||
# Restart OpenVAS-Manager
|
||||
if [ $manager -eq 0 ]; then
|
||||
ps aux | grep -v "grep" | grep -P "(^|\s)\Kopenvasmd(?=\s|$)" | awk '{print $2}' | xargs kill -9 &>/dev/null
|
||||
sleep 5
|
||||
systemctl restart openvasmd.service &>/dev/null
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
success="0"
|
||||
echo "systemd --> openvasmd.service is restarted" &>>/tmp/openvas_mail.out
|
||||
echo "OpenVAS CronJob Success!" | tee -a /tmp/openvas_mail.out
|
||||
echo -e "Subject:$MAIL_SUBJECT\n$(cat /tmp/openvas_mail.out)" | sendmail -t "$MAIL_TO" &>/dev/null
|
||||
else
|
||||
echo "systemd --> openvasmd.service cannot restarted" &>>/tmp/openvas_mail.out
|
||||
echo "OpenVAS CronJob Failed!" | tee -a /tmp/openvas_mail.out
|
||||
echo -e "Subject:$MAIL_SUBJECT\n$(cat /tmp/openvas_mail.out)" | sendmail -t "$MAIL_TO" &>/dev/null
|
||||
exit 1
|
||||
fi
|
||||
|
||||
elif [[ -n "$manager_service" ]]; then
|
||||
ps aux | grep -v "grep" | grep -P "(^|\s)\Kopenvasmd(?=\s|$)" | awk '{print $2}' | xargs kill -9 &>/dev/null
|
||||
sleep 5
|
||||
systemctl restart "$manager_service" &>/dev/null
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
success="0"
|
||||
echo "systemd --> $manager_service is restarted" &>>/tmp/openvas_mail.out
|
||||
echo "OpenVAS CronJob Success!" | tee -a /tmp/openvas_mail.out
|
||||
echo -e "Subject:$MAIL_SUBJECT\n$(cat /tmp/openvas_mail.out)" | sendmail -t "$MAIL_TO" &>/dev/null
|
||||
else
|
||||
echo "systemd --> $manager_service cannot restarted" &>>/tmp/openvas_mail.out
|
||||
echo "OpenVAS CronJob Failed!" | tee -a /tmp/openvas_mail.out
|
||||
echo -e "Subject:$MAIL_SUBJECT\n$(cat /tmp/openvas_mail.out)" | sendmail -t "$MAIL_TO" &>/dev/null
|
||||
exit 1
|
||||
fi
|
||||
|
||||
elif [[ -n "$manager_init" ]]; then
|
||||
ps aux | grep -v "grep" | grep -P "(^|\s)\Kopenvasmd(?=\s|$)" | awk '{print $2}' | xargs kill -9 &>/dev/null
|
||||
sleep 5
|
||||
rc-service openvasmd start &>/dev/null
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
success="0"
|
||||
echo "open-rc --> openvasmd is restarted" &>>/tmp/openvas_mail.out
|
||||
echo "OpenVAS CronJob Success!" | tee -a /tmp/openvas_mail.out
|
||||
echo -e "Subject:$MAIL_SUBJECT\n$(cat /tmp/openvas_mail.out)" | sendmail -t "$MAIL_TO" &>/dev/null
|
||||
else
|
||||
echo "open-rc --> openvasmd cannot restarted" &>>/tmp/openvas_mail.out
|
||||
echo "OpenVAS CronJob Failed!" | tee -a /tmp/openvas_mail.out
|
||||
echo -e "Subject:$MAIL_SUBJECT\n$(cat /tmp/openvas_mail.out)" | sendmail -t "$MAIL_TO" &>/dev/null
|
||||
exit 1
|
||||
fi
|
||||
|
||||
else
|
||||
ps aux | grep -v "grep" | grep -P "(^|\s)\Kopenvasmd(?=\s|$)" | awk '{print $2}' | xargs kill -9 &>/dev/null
|
||||
sleep 5
|
||||
openvasmd "$OPENVAS_MANAGER_OPTIONS" "$OPENVAS_MANAGER_PORT" "$OPENVAS_MANAGER_LISTEN_ADDRESS" "$OPENVAS_MANAGER_SCANNER_HOST" "$OPENVAS_MANAGER_GNUTLS_PRIORITIES" &>/dev/null
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
success="0"
|
||||
echo "OpenVAS-Manager is restarted manually" &>>/tmp/openvas_mail.out
|
||||
echo "OpenVAS CronJob Success!" | tee -a /tmp/openvas_mail.out
|
||||
echo -e "Subject:$MAIL_SUBJECT\n$(cat /tmp/openvas_mail.out)" | sendmail -t "$MAIL_TO" &>/dev/null
|
||||
else
|
||||
echo "OpenVAS-Manager cannot restarted" &>>/tmp/openvas_mail.out
|
||||
echo "OpenVAS CronJob Failed!" | tee -a /tmp/openvas_mail.out
|
||||
echo -e "Subject:$MAIL_SUBJECT\n$(cat /tmp/openvas_mail.out)" | sendmail -t "$MAIL_TO" &>/dev/null
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
else
|
||||
echo "OpenVAS CronJob Failed! openvas-scanner cannot restarted" | tee -a /tmp/openvas_mail.out
|
||||
echo -e "Subject:$MAIL_SUBJECT\n$(cat /tmp/openvas_mail.out)" | sendmail -t "$MAIL_TO" &>/dev/null
|
||||
fi
|
||||
else
|
||||
echo "OpenVAS CronJob Failed! OpenVAS NVT cache build failed" | tee -a /tmp/openvas_mail.out
|
||||
echo -e "Subject:$MAIL_SUBJECT\n$(cat /tmp/openvas_mail.out)" | sendmail -t "$MAIL_TO" &>/dev/null
|
||||
fi
|
||||
else
|
||||
echo "OpenVAS CronJob Failed! OpenVAS Certdata sync failed!" | tee -a /tmp/openvas_mail.out
|
||||
echo -e "Subject:$MAIL_SUBJECT\n$(cat /tmp/openvas_mail.out)" | sendmail -t "$MAIL_TO" &>/dev/null
|
||||
fi
|
||||
else
|
||||
echo "OpenVAS CronJob Failed! OpenVAS Scapdata sync failed!" | tee -a /tmp/openvas_mail.out
|
||||
echo -e "Subject:$MAIL_SUBJECT\n$(cat /tmp/openvas_mail.out)" | sendmail -t "$MAIL_TO" &>/dev/null
|
||||
fi
|
||||
else
|
||||
echo "OpenVAS CronJob Failed! OpenVAS NVT sync update failed!" | tee -a /tmp/openvas_mail.out
|
||||
echo -e "Subject:$MAIL_SUBJECT\n$(cat /tmp/openvas_mail.out)" | sendmail -t "$MAIL_TO" &>/dev/null
|
||||
fi
|
||||
rm -rf /tmp/openvas_mail.out
|
||||
|
||||
# Restart WebUI
|
||||
if [[ -n "$success" ]] && [ $gsad -eq 0 ]; then
|
||||
WHICHA="$(type gsad | awk '{print $3}')"
|
||||
|
||||
if [ $assistant -eq 0 ]; then
|
||||
# Time to restart OpenVAS-Security Assistant
|
||||
ps aux | grep -v "grep" | grep -P "(^|\s)\K$WHICHA(?=\s|$)" | awk '{print $2}' | xargs kill -9 &>/dev/null
|
||||
sleep 5
|
||||
systemctl restart gsad.service &>/dev/null
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "systemd --> gsad.service (OpenVAS WebUI) is restarted" | tee -a /tmp/openvas_mail.out
|
||||
echo -e "Subject:$MAIL_SUBJECT\n$(cat /tmp/openvas_mail.out)" | sendmail -t "$MAIL_TO" &>/dev/null
|
||||
else
|
||||
echo "systemd --> gsad.service (OpenVAS-WebUI) cannot restarted" | tee -a /tmp/openvas_mail.out
|
||||
echo -e "Subject:$MAIL_SUBJECT\n$(cat /tmp/openvas_mail.out)" | sendmail -t "$MAIL_TO" &>/dev/null
|
||||
fi
|
||||
|
||||
elif [[ -n "$assistant_service" ]]; then
|
||||
if [ $COUNTA -eq 1 ]; then
|
||||
ps aux | grep -v "grep" | grep -P "(^|\s)\K$WHICHA(?=\s|$)" | awk '{print $2}' | xargs kill -9 &>/dev/null
|
||||
sleep 5
|
||||
systemctl restart "$assistant_service" &>/dev/null
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "systemd --> $assistant_service (OpenVAS WebUI) is restarted" | tee -a /tmp/openvas_mail.out
|
||||
echo -e "Subject:$MAIL_SUBJECT\n$(cat /tmp/openvas_mail.out)" | sendmail -t "$MAIL_TO" &>/dev/null
|
||||
else
|
||||
echo "systemd --> $assistan_service (OpenVAS WebUI) cannot restarted." | tee -a /tmp/openvas_mail.out
|
||||
echo -e "Subject:$MAIL_SUBJECT\n$(cat /tmp/openvas_mail.out)" | sendmail -t "$MAIL_TO" &>/dev/null
|
||||
fi
|
||||
else
|
||||
echo "systemd --> OpenVAS WebUI cannot restarted! You have multiple enabled systemd services ($assistant_service)" | tee -a /tmp/openvas_mail.out
|
||||
echo -e "Subject:$MAIL_SUBJECT\n$(cat /tmp/openvas_mail.out)" | sendmail -t "$MAIL_TO" &>/dev/null
|
||||
exit 1
|
||||
fi
|
||||
|
||||
elif [[ -n "$assistant_init" ]]; then
|
||||
ps aux | grep -v "grep" | grep -P "(^|\s)\K$WHICHA(?=\s|$)" | awk '{print $2}' | xargs kill -9 &>/dev/null
|
||||
sleep 5
|
||||
rc-service gsad start &>/dev/null
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "open-rc --> gsad (OpenVAS WebUI) is restarted" | tee -a /tmp/openvas_mail.out
|
||||
echo -e "Subject:$MAIL_SUBJECT\n$(cat /tmp/openvas_mail.out)" | sendmail -t "$MAIL_TO" &>/dev/null
|
||||
else
|
||||
echo "open-rc --> gsad (OpenVAS WebUI) cannot restarted." | tee -a /tmp/openvas_mail.out
|
||||
echo -e "Subject:$MAIL_SUBJECT\n$(cat /tmp/openvas_mail.out)" | sendmail -t "$MAIL_TO" &>/dev/null
|
||||
fi
|
||||
else
|
||||
ps aux | grep -v "grep" | grep -P "(^|\s)\K$WHICHA(?=\s|$)" | awk '{print $2}' | xargs kill -9 &>/dev/null
|
||||
sleep 5
|
||||
gsad "$OPENVAS_SECURITY_ASSISTANT_OPTIONS" "$OPENVAS_SECURITY_ASSISTANT_LISTEN_ADDRESS" "$OPENVAS_SECURITY_ASSISTANT_LISTEN_PORT" "$OPENVAS_SECURITY_ASSISTANT_MANAGER_LISTEN_ADDRESS" "$OPENVAS_SECURITY_ASSISTANT_MANAGER_LISTEN_PORT" "$OPENVAS_SECURITY_ASSISTANT_GNUTLS_PRIORITIES" &>/dev/null
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "OpenVAS WebUI is restarted" | tee -a /tmp/openvas_mail.out
|
||||
echo -e "Subject:$MAIL_SUBJECT\n$(cat /tmp/openvas_mail.out)" | sendmail -t "$MAIL_TO" &>/dev/null
|
||||
else
|
||||
echo "OpenVAS WebUI cannot restarted" | tee -a /tmp/openvas_mail.out
|
||||
echo -e "Subject:$MAIL_SUBJECT\n$(cat /tmp/openvas_mail.out)" | sendmail -t "$MAIL_TO" &>/dev/null
|
||||
fi
|
||||
fi
|
||||
rm -rf /tmp/openvas_mail.out
|
||||
fi
|
||||
@@ -1,39 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
if [ -f /etc/openvas/openvassd.conf ]; then
|
||||
. /etc/openvas/openvassd.conf
|
||||
fi
|
||||
|
||||
if [ "$auto_plugin_update" != "yes" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
opts=""
|
||||
case "$update_method" in
|
||||
rsync)
|
||||
opts = "$opts --rsync"
|
||||
;;
|
||||
wget)
|
||||
opts = "$opts --wget"
|
||||
;;
|
||||
curl)
|
||||
opts = "$opts --curl"
|
||||
;;
|
||||
esac
|
||||
|
||||
# Export openvas-nvt-sync's environment variables if they are defined
|
||||
[ \! -z "$NVT_DIR" ] && export NVT_DIR
|
||||
[ \! -z "$OV_RSYNC_FEED" ] && export OV_RSYNC_FEED
|
||||
[ \! -z "$OV_HTTP_FEED" ] && export OV_HTTP_FEED
|
||||
|
||||
/usr/sbin/openvas-nvt-sync $opts >& /dev/null
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Error updating OpenVAS plugins. Please run openvas-nvt-sync manually."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$notify_openvas_scanner" == "yes" ]; then
|
||||
/etc/init.d/openvas-scanner reloadplugins
|
||||
fi
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
diff -ru openvas-scanner-4.0.1/CMakeLists.txt openvas-scanner-4.0.1.mkcert/CMakeLists.txt
|
||||
--- openvas-scanner-4.0.1/CMakeLists.txt 2014-04-23 16:00:47.000000000 +0200
|
||||
+++ openvas-scanner-4.0.1.mkcert/CMakeLists.txt 2014-05-26 16:04:23.093548608 +0200
|
||||
@@ -258,7 +258,6 @@
|
||||
# DESTINATION ${OPENVAS_SYSCONF_DIR})
|
||||
|
||||
install (FILES ${CMAKE_BINARY_DIR}/tools/openvas-mkcert
|
||||
- ${CMAKE_BINARY_DIR}/tools/openvas-mkcert-client
|
||||
${CMAKE_BINARY_DIR}/tools/openvas-nvt-sync
|
||||
DESTINATION ${SBINDIR}
|
||||
PERMISSIONS OWNER_EXECUTE OWNER_READ OWNER_WRITE
|
||||
@@ -269,7 +268,15 @@
|
||||
PERMISSIONS OWNER_EXECUTE OWNER_READ OWNER_WRITE
|
||||
GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
|
||||
|
||||
-install (FILES ${CMAKE_BINARY_DIR}/doc/openvassd.8
|
||||
+install (FILES ${CMAKE_BINARY_DIR}/tools/openvas-mkcert-client
|
||||
+ DESTINATION ${BINDIR}
|
||||
+ PERMISSIONS OWNER_EXECUTE OWNER_READ OWNER_WRITE
|
||||
+ GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
|
||||
+
|
||||
+install (FILES ${CMAKE_SOURCE_DIR}/doc/openvas-mkcert-client.1
|
||||
+ DESTINATION ${DATADIR}/man/man1 )
|
||||
+
|
||||
+install (FILES ${CMAKE_BINARY_DIR}/doc/openvassd.8
|
||||
DESTINATION ${DATADIR}/man/man8 )
|
||||
|
||||
install (FILES ${CMAKE_SOURCE_DIR}/doc/openvas-mkcert.8
|
||||
Only in openvas-scanner-4.0.1.mkcert/: CMakeLists.txt~
|
||||
@@ -1,15 +0,0 @@
|
||||
diff -ru openvas-scanner-4.0.1/CMakeLists.txt openvas-scanner-4.0.1.rules/CMakeLists.txt
|
||||
--- openvas-scanner-4.0.1/CMakeLists.txt 2014-04-23 16:00:47.000000000 +0200
|
||||
+++ openvas-scanner-4.0.1.rules/CMakeLists.txt 2014-05-26 16:07:37.454116277 +0200
|
||||
@@ -171,6 +171,10 @@
|
||||
set (OPENVASSD_DEBUGMSG "${OPENVAS_LOG_DIR}/openvassd.dump")
|
||||
set (OPENVASSD_CONF "${OPENVAS_SYSCONF_DIR}/openvassd.conf")
|
||||
|
||||
+if (NOT OPENVASSD_RULES)
|
||||
+ set (OPENVASSD_RULES "${OPENVAS_DATA_DIR}/openvassd.rules")
|
||||
+endif (NOT OPENVASSD_RULES)
|
||||
+
|
||||
set (NVT_TIMEOUT "320")
|
||||
|
||||
message ("-- Install prefix: ${CMAKE_INSTALL_PREFIX}")
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
CMakeLists.txt | 2 +-
|
||||
tools/greenbone-nvt-sync | 2 +-
|
||||
2 files changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
||||
index c691100..d78ffa6 100644
|
||||
--- a/CMakeLists.txt
|
||||
+++ b/CMakeLists.txt
|
||||
@@ -155,7 +155,7 @@ set (OPENVAS_DATA_DIR "${DATADIR}/openvas")
|
||||
set (OPENVAS_STATE_DIR "${LOCALSTATEDIR}/lib/openvas")
|
||||
set (OPENVAS_LOG_DIR "${LOCALSTATEDIR}/log/openvas")
|
||||
set (OPENVAS_CACHE_DIR "${LOCALSTATEDIR}/cache/openvas")
|
||||
-set (OPENVAS_PID_DIR "${LOCALSTATEDIR}/run")
|
||||
+set (OPENVAS_PID_DIR "/run")
|
||||
set (OPENVAS_SYSCONF_DIR "${SYSCONFDIR}/openvas")
|
||||
|
||||
set (OPENVAS_NVT_DIR "${OPENVAS_STATE_DIR}/plugins")
|
||||
@@ -1,22 +0,0 @@
|
||||
#!/sbin/openrc-run
|
||||
# Copyright 1999-2011 Gentoo Foundation
|
||||
# Distributed under the terms of the GNU General Public License v2
|
||||
|
||||
depend() {
|
||||
need net
|
||||
}
|
||||
|
||||
start() {
|
||||
ebegin "Starting openvassd (scanner)"
|
||||
start-stop-daemon --start --name openvassd \
|
||||
--exec /usr/sbin/openvassd \
|
||||
--pidfile /var/run/openvassd.pid
|
||||
eend $?
|
||||
}
|
||||
|
||||
stop() {
|
||||
ebegin "Stop openvassd (scanner)"
|
||||
start-stop-daemon --stop --name openvassd \
|
||||
--pidfile /var/run/openvassd.pid
|
||||
eend $?
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
#Listen on given address - by default scanner listens on all addresses
|
||||
#SCANNER_LISTEN=--listen=127.0.0.1
|
||||
|
||||
#Listen on given port - by default 9391
|
||||
SCANNER_PORT=--port=9391
|
||||
|
||||
#Send the packets with the source IP of IP1,IP2,IP3....
|
||||
#SCANNER_SRCIP=--src-ip=127.0.0.1,192.168.1.2
|
||||
|
||||
# Extra Arguments
|
||||
# SCANNER_EXTRA_ARGS=""
|
||||
|
||||
# Set to yes if plugins should be automatically updated via a cron job
|
||||
auto_plugin_update=no
|
||||
|
||||
# Notify OpenVAS scanner after update by seding it SIGHUP?
|
||||
notify_openvas_scanner=yes
|
||||
|
||||
# Method to use to get updates. The default is via rsync
|
||||
# Note that only wget and curl support retrieval via proxy
|
||||
# update_method=rsync|wget|curl
|
||||
|
||||
# Additionaly, you can specify the following variables
|
||||
#NVT_DIR where to extract plugins (absolute path)
|
||||
#OV_RSYNC_FEED URL of rsync feed
|
||||
#OV_HTTP_FEED URL of http feed
|
||||
@@ -1,25 +0,0 @@
|
||||
#!/sbin/openrc-run
|
||||
# Copyright 1999-2014 Gentoo Foundation
|
||||
# Distributed under the terms of the GNU General Public License v2
|
||||
|
||||
name="OpenVAS Scanner"
|
||||
command="/usr/sbin/openvassd"
|
||||
command_args="${SCANNER_LISTEN} ${SCANNER_PORT} ${SCANNER_SRCIP} ${SCANNER_EXTRA_ARGS}"
|
||||
pidfile="/run/openvassd.pid"
|
||||
extra_stopped_commands="create_cache"
|
||||
|
||||
depend() {
|
||||
after bootmisc
|
||||
need localmount net
|
||||
}
|
||||
|
||||
start_pre() {
|
||||
checkpath --directory --mode 0775 --quiet /var/cache/openvas
|
||||
}
|
||||
|
||||
create_cache() {
|
||||
checkpath --directory --mode 0775 --quiet /var/cache/openvas
|
||||
ebegin "Generating initial Cache"
|
||||
/usr/sbin/openvassd --foreground --only-cache
|
||||
eend $?
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
# logrotate for openvas
|
||||
/var/log/openvas/openvassd.log {
|
||||
rotate 4
|
||||
weekly
|
||||
compress
|
||||
delaycompress
|
||||
missingok
|
||||
postrotate
|
||||
/bin/kill -HUP `pidof openvassd`
|
||||
endscript
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
[Unit]
|
||||
Description=OpenVAS Scanner
|
||||
After=network.target
|
||||
Before=openvasmd.service
|
||||
|
||||
[Service]
|
||||
EnvironmentFile=-/etc/openvas/openvassd-daemon.conf
|
||||
ExecStart=/usr/sbin/openvassd -f ${SCANNER_PORT} ${SCANNER_LISTEN} ${SCANNER_SRCIP} ${SCANNER_EXTRA_ARGS}
|
||||
Restart=always
|
||||
RestartSec=1
|
||||
User=root
|
||||
Group=root
|
||||
TimeoutSec=1200
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
@@ -1 +0,0 @@
|
||||
d /var/cache/openvassd 0775
|
||||
@@ -1,72 +0,0 @@
|
||||
# Copyright 1999-2018 Gentoo Authors
|
||||
# Distributed under the terms of the GNU General Public License v2
|
||||
|
||||
EAPI=7
|
||||
|
||||
DL_ID=2129
|
||||
MY_PN=openvassd
|
||||
inherit cmake-utils systemd
|
||||
|
||||
DESCRIPTION="A remote security scanner for Linux (OpenVAS-scanner)"
|
||||
HOMEPAGE="http://www.openvas.org/"
|
||||
SRC_URI="http://wald.intevation.org/frs/download.php/${DL_ID}/${P/_beta/+beta}.tar.gz"
|
||||
|
||||
SLOT="0"
|
||||
LICENSE="GPL-2"
|
||||
KEYWORDS="~amd64 ~arm ~ppc ~x86"
|
||||
IUSE=""
|
||||
|
||||
DEPEND="
|
||||
app-crypt/gpgme
|
||||
>=dev-libs/glib-2.16:2
|
||||
dev-libs/libgcrypt:0
|
||||
>=net-analyzer/openvas-libraries-8.0.2
|
||||
"
|
||||
RDEPEND="${DEPEND}
|
||||
!net-analyzer/openvas-plugins
|
||||
!net-analyzer/openvas-server
|
||||
"
|
||||
BDEPEND="
|
||||
virtual/pkgconfig
|
||||
"
|
||||
|
||||
S="${WORKDIR}"/${P/_beta/+beta}
|
||||
|
||||
PATCHES=(
|
||||
"${FILESDIR}"/${PN}-4.0.3-mkcertclient.patch
|
||||
"${FILESDIR}"/${PN}-4.0.3-rulesdir.patch
|
||||
"${FILESDIR}"/${PN}-4.0.3-run.patch
|
||||
)
|
||||
|
||||
src_prepare() {
|
||||
cmake-utils_src_prepare
|
||||
sed \
|
||||
-e '/^install.*OPENVAS_CACHE_DIR.*/d' \
|
||||
-i CMakeLists.txt || die
|
||||
}
|
||||
|
||||
src_configure() {
|
||||
local mycmakeargs=(
|
||||
-DLOCALSTATEDIR="${EPREFIX}/var"
|
||||
-DSYSCONFDIR="${EPREFIX}/etc"
|
||||
)
|
||||
cmake-utils_src_configure
|
||||
}
|
||||
|
||||
src_install() {
|
||||
cmake-utils_src_install
|
||||
|
||||
newinitd "${FILESDIR}"/${MY_PN}.init ${MY_PN}
|
||||
|
||||
insinto /etc/openvas
|
||||
doins "${FILESDIR}"/${MY_PN}.conf "${FILESDIR}"/${MY_PN}-daemon.conf
|
||||
dosym ../openvas/${MY_PN}-daemon.conf /etc/conf.d/${MY_PN}
|
||||
|
||||
insinto /etc/logrotate.d
|
||||
doins "${FILESDIR}"/${MY_PN}.logrotate
|
||||
|
||||
dodoc "${FILESDIR}"/openvas-nvt-sync-cron
|
||||
|
||||
systemd_newtmpfilesd "${FILESDIR}"/${MY_PN}.tmpfiles.d ${MY_PN}.conf
|
||||
systemd_dounit "${FILESDIR}"/${MY_PN}.service
|
||||
}
|
||||
@@ -80,10 +80,6 @@ src_install() {
|
||||
insinto /etc/openvas/sysconfig
|
||||
doins "${FILESDIR}"/${MY_PN}-daemon.conf
|
||||
|
||||
insinto /etc/openvas/scripts
|
||||
doins "${FILESDIR}"/openvas-feed-sync "${FILESDIR}"/first-start
|
||||
fperms 0755 /etc/openvas/scripts/{openvas-feed-sync,first-start}
|
||||
|
||||
newinitd "${FILESDIR}/${MY_PN}.init" ${MY_PN}
|
||||
newconfd "${FILESDIR}/${MY_PN}-daemon.conf" ${MY_PN}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user