-
Notifications
You must be signed in to change notification settings - Fork 0
/
vasctl
executable file
·110 lines (103 loc) · 2.96 KB
/
vasctl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#! /bin/bash
#Version
version="1.0"
#root init vasctl
if [ "$EUID" != "0" ]; then
echo "[INFO] Please run as root"
exit
fi
#Parm init
if [ "$1" = "" ] || [ "$1" = "-h" ]; then
echo "Welcome to vasctl $version !"
echo ""
echo "Usage:"
echo ""
echo "Installing OpenVAS to your OS:"
echo "Debian: # vasctl install debian"
echo "Arch: # vasctl install arch"
echo ""
echo "Daemon control"
echo "Start all daemons: # vasctl start debian >>> -r"
echo "Stop all daemons : # vasctl stop >>> -x"
echo ""
echo "Update OpenVAS"
echo "# vasctl update >>> -u"
echo ""
echo "Use '-h' to show this help"
echo "The commands should be executed this way: install; update; start; stop"
echo "Report bugs and get source or help: https://GitHub.com/Secure-Solutions/openVAS-control"
exit
fi
#Install
if [ "$1" = "install" ] || [ "$1" = "-i" ]; then
#Debian
if [ "$2" = "debian" ]; then
echo "Installing OpenVAS for Debian!"
echo "[INFO] Updating apt ..."
apt update
echo "[INFO] Installing packages ..."
echo "[INFO] Please choose yes for UNIX socket later ..."
read -n 1 -s -p "[INFO] Press any key to continue .."
echo ""
apt install openvas -y
fi
#Arch
if [ "$2" = "arch" ]; then
echo "Installing OpenVAS for Arch!"
echo "kb_location = /var/lib/redis/redis.sock" > /etc/openvas/openvassd.conf
fi
echo "[INFO] Configuring the environment ..."
echo $(cat /etc/redis.conf) >> /etc/redis.vasctl.bk
echo "unixsocket /var/lib/redis/redis.sock" > /etc/redis.conf
echo "unixsocketperm 700" >> /etc/redis.conf
echo "port 0" >> /etc/redis.conf
echo "timeout 0" >> /etc/redis.conf
echo "databases 128" >> /etc/redis.conf
systemctl start openvas-scanner.service
openvasmd --create-user=admin --role=Admin
echo "[INFO] Generating random password for user 'Admin' ..."
randompass="$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 13 ; echo '')"
openvasmd --user=admin --new-password=$randompass
echo "[!ALERT!] CHOOSEN PASSWORD: $randompass <-- write it down!"
echo "[INFO] Installation done!"
exit
fi
#Run
if [ "$1" = "start" ] || [ "$1" = "-r" ]; then
echo "[INFO] Starting Redis.service"
systemctl start redis.service
echo "[INFO] Starting openvasmd"
openvasmd -p 9390 -a 127.0.0.1
echo "[INFO] Starting gsad"
gsad -f --listen=127.0.0.1 --mlisten=127.0.0.1 --mport=9390
echo "[DONE] Connect to 127.0.0.1:9390"
exit
fi
#Stop
if [ "$1" = "stop" ] || [ "$1" = "-x" ]; then
echo "[INFO] Stopping Redis.service"
systemctl stop redis.service
echo "[INFO] Killing openvasmd"
killall openvasmd -9
echo "[INFO] Killing gsad"
killall gsad -9
echo "[DONE] Ready."
exit
fi
#Update
if [ "$1" = "update" ] || [ "$1" = "-u" ]; then
echo "[INFO] Updating please wait ..."
#Debian
if [ "$2" = "debian" ]; then
openvas-certdata-sync
fi
#Arch
if [ "$2" = "arch" ]; then
openvas-manage-certs -a
greenbone-nvt-sync
greenbone-scapdata-sync
greenbone-certdata-sync
fi
echo "[INFO] Ready."
exit
fi