os:kali:openvas
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revision | |||
| os:kali:openvas [2024/12/03 12:09] – [Postgresql 16 to 17] warnaud | os:kali:openvas [2025/08/30 11:57] (current) – [MANUAL WAY] warnaud | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ====== PURPOSE ====== | ||
| + | Vulnerability scanner for guest systems hosted in UniFR\\ | ||
| + | 6CPU/ | ||
| + | Default IP: 192.168.1.42/ | ||
| + | OS: Kali Linux\\ | ||
| + | Open ports: SSH/HTTPS\\ | ||
| + | |||
| + | |||
| + | |||
| + | ====== INSTALL ====== | ||
| + | Iso 2021.2 from [[https:// | ||
| + | Full US install (XFCE + large collection)\\ | ||
| + | One account at install (sudoers): warnaud LOL | ||
| + | |||
| + | ====== POST-INSTALL ====== | ||
| + | ===== network ===== | ||
| + | <code bash> nmtui</ | ||
| + | <code bash> | ||
| + | apt update | ||
| + | apt upgrade | ||
| + | systemctl enable ssh | ||
| + | </ | ||
| + | |||
| + | |||
| + | ====== SSH ====== | ||
| + | ===== root key-only ===== | ||
| + | <code bash>vi / | ||
| + | <code perl> | ||
| + | <code bash> | ||
| + | ===== from some IP ===== | ||
| + | |||
| + | |||
| + | ====== IPv6/ | ||
| + | ===== IPv6 ===== | ||
| + | <code bash> | ||
| + | </ | ||
| + | <code bash>vi / | ||
| + | <code perl> | ||
| + | <code bash> | ||
| + | ===== Rsyslog ===== | ||
| + | <code bash>vi / | ||
| + | <code perl> | ||
| + | # 2020-01-15 renvoi vers (r)syslog.unifr.ch | ||
| + | # la nouvelle machine est vx-ditsyslog.unifr.ch 134.21.201.50 | ||
| + | # l' | ||
| + | # utiliser l' | ||
| + | # le choix est laissé au sysadmin. | ||
| + | *.* | ||
| + | </ | ||
| + | ===== NTP ===== | ||
| + | <code bash> | ||
| + | apt install ntp ntpdate | ||
| + | vi / | ||
| + | </ | ||
| + | <code perl> | ||
| + | #pool 0.debian.pool.ntp.org iburst | ||
| + | #pool 1.debian.pool.ntp.org iburst | ||
| + | #pool 2.debian.pool.ntp.org iburst | ||
| + | #pool 3.debian.pool.ntp.org iburst | ||
| + | server ntp.fortier-family.com iburst</ | ||
| + | <code bash> | ||
| + | ntpq -p</ | ||
| + | |||
| + | |||
| + | |||
| + | ====== OpenVAS ====== | ||
| + | ===== Check ===== | ||
| + | Verify haveged is running | ||
| + | <code bash>ps aux | grep -i have</ | ||
| + | ===== Install/ | ||
| + | <code bash>apt install gvm | ||
| + | gvm-setup | ||
| + | </ | ||
| + | First update takes ages...\\ | ||
| + | :!: Don't forget to get the password for the admin account :!: | ||
| + | ===== Update ===== | ||
| + | <code bash> | ||
| + | |||
| + | ==== MANUAL WAY ==== | ||
| + | |||
| + | * Update NVT Feed | ||
| + | <code bash> | ||
| + | |||
| + | * Update SCAP Feed | ||
| + | <code bash> | ||
| + | |||
| + | * Update CERT Feed | ||
| + | <code bash> | ||
| + | |||
| + | * Update gvmd DATA Feed | ||
| + | <code bash> | ||
| + | |||
| + | |||
| + | ==== crontab ==== | ||
| + | <code perl> | ||
| + | 0 12 * * * for optimize in vaccum analyse cleanup-report-formats cleanup-result-nvts cleanup-config-prefs cleanup-result-severities update-report-cache; | ||
| + | 0 13 * * * sudo -u _gvm greenbone-scapdata-sync >/ | ||
| + | 0 15 * * * sudo -u _gvm greenbone-feed-sync --type GVMD_DATA 2>/ | ||
| + | 0 17 * * * sudo -u _gvm greenbone-certdata-sync >/ | ||
| + | 0 19 * * * sudo -u _gvm greenbone-nvt-sync >/ | ||
| + | </ | ||
| + | ====== PDF Problem ====== | ||
| + | Since September https:// | ||
| + | <code bash> | ||
| + | vi / | ||
| + | </ | ||
| + | <code perl> | ||
| + | % \usepackage[utf8x]{inputenc}</ | ||
| + | |||
| + | ===== Service ===== | ||
| + | <code bash> | ||
| + | systemctl enable greenbone-security-assistant | ||
| + | systemctl status gvmd ospd-openvas greenbone-security-assistant | ||
| + | |||
| + | gvm-check-setup</ | ||
| + | :!: greenbone-security-assistant doesn' | ||
| + | |||
| + | |||
| + | |||
| + | ===== Reset password ===== | ||
| + | <code bash>su - _gvm -s /bin/sh -c "gvmd --user=admin --new-password mypasswd; history -c" | ||
| + | history -c</ | ||
| + | |||
| + | |||
| + | |||
| + | ====== Xrdp ====== | ||
| + | |||
| + | <code bash>apt install xrdp</ | ||
| + | < | ||
| + | ===== Fixing "xrdp Authentication is requiredto create a color managed device" | ||
| + | ==== Doesn' | ||
| + | |||
| + | <code bash> | ||
| + | echo " | ||
| + | if ((action.id == " | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | } | ||
| + | | ||
| + | |||
| + | echo " | ||
| + | Action=org.freedesktop.color-manager.create-device; | ||
| + | ResultAny=no | ||
| + | ResultInactive=no | ||
| + | ResultActive=yes" | ||
| + | </ | ||
| + | :!: | ||
| + | <code bash>cp / | ||
| + | rm / | ||
| + | |||
| + | ==== Working solution ==== | ||
| + | |||
| + | <code bash> | ||
| + | vi / | ||
| + | </ | ||
| + | switch all values to yes | ||
| + | <code perl> | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | </ | ||
| + | And then: | ||
| + | <code bash> | ||
| + | vi / | ||
| + | <code perl> | ||
| + | polkit.addRule(function(action, | ||
| + | if ((action.id == " | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | } | ||
| + | }); | ||
| + | </ | ||
| + | ====== Debug ====== | ||
| + | In case of problem... | ||
| + | <code bash> gvm-check-setup | ||
| + | systemctl status gvmd ospd-openvas greenbone-security-assistant | ||
| + | multitail / | ||
| + | </ | ||
| + | ====== Upgrade ====== | ||
| + | ===== Postgresql 13 to 14 ===== | ||
| + | <code bash> | ||
| + | apt update | ||
| + | apt install postgresql-14 postgresql-server-dev-14 | ||
| + | diff / | ||
| + | diff / | ||
| + | systemctl stop postgresql | ||
| + | su - postgres | ||
| + | </ | ||
| + | as user postgres | ||
| + | <code bash> | ||
| + | / | ||
| + | --old-datadir=/ | ||
| + | --new-datadir=/ | ||
| + | --old-bindir=/ | ||
| + | --new-bindir=/ | ||
| + | --old-options '-c config_file=/ | ||
| + | --new-options '-c config_file=/ | ||
| + | --check | ||
| + | </ | ||
| + | if there is an error like "There seems to be a postmaster servicing the new cluster. | ||
| + | Please shutdown that postmaster and try again." | ||
| + | |||
| + | Then migrate data: | ||
| + | <code bash> | ||
| + | / | ||
| + | --old-datadir=/ | ||
| + | --new-datadir=/ | ||
| + | --old-bindir=/ | ||
| + | --new-bindir=/ | ||
| + | --old-options '-c config_file=/ | ||
| + | --new-options '-c config_file=/ | ||
| + | |||
| + | exit | ||
| + | </ | ||
| + | then as root, swap the ports and relaunch service | ||
| + | <code bash> | ||
| + | vi / | ||
| + | # ...and change "port = 5433" to "port = 5432" | ||
| + | |||
| + | vi / | ||
| + | # ...and change "port = 5432" to "port = 5433" | ||
| + | |||
| + | |||
| + | systemctl disable postgresql@13-main.service | ||
| + | systemctl start postgresql | ||
| + | </ | ||
| + | ===== Postgresql 14 to 15 ===== | ||
| + | <code bash> | ||
| + | apt update | ||
| + | apt install postgresql-15 postgresql-server-dev-15 | ||
| + | diff / | ||
| + | diff / | ||
| + | systemctl stop postgresql | ||
| + | su - postgres | ||
| + | </ | ||
| + | as user postgres | ||
| + | <code bash> | ||
| + | / | ||
| + | --old-datadir=/ | ||
| + | --new-datadir=/ | ||
| + | --old-bindir=/ | ||
| + | --new-bindir=/ | ||
| + | --old-options '-c config_file=/ | ||
| + | --new-options '-c config_file=/ | ||
| + | --check | ||
| + | </ | ||
| + | if there is an error like "There seems to be a postmaster servicing the new cluster. | ||
| + | Please shutdown that postmaster and try again." | ||
| + | |||
| + | Then migrate data: | ||
| + | <code bash> | ||
| + | / | ||
| + | --old-datadir=/ | ||
| + | --new-datadir=/ | ||
| + | --old-bindir=/ | ||
| + | --new-bindir=/ | ||
| + | --old-options '-c config_file=/ | ||
| + | --new-options '-c config_file=/ | ||
| + | |||
| + | exit | ||
| + | </ | ||
| + | then as root, swap the ports and relaunch service | ||
| + | <code bash> | ||
| + | vi / | ||
| + | # ...and change "port = 5433" to "port = 5432" | ||
| + | |||
| + | vi / | ||
| + | # ...and change "port = 5432" to "port = 5433" | ||
| + | |||
| + | |||
| + | systemctl disable postgresql@14-main.service | ||
| + | systemctl start postgresql | ||
| + | </ | ||
| + | ===== Postgresql 15 to 16 ===== | ||
| + | Reference: https:// | ||
| + | <code bash> pg_lsclusters</ | ||
| + | < | ||
| + | Ver Cluster Port Status Owner Data directory | ||
| + | 15 main 5432 online postgres / | ||
| + | 16 main 5433 online postgres / | ||
| + | <code bash> | ||
| + | pg_lsclusters</ | ||
| + | < | ||
| + | Ver Cluster Port Status Owner Data directory | ||
| + | 15 main 5432 online postgres / | ||
| + | </ | ||
| + | <code bash> | ||
| + | < | ||
| + | ... | ||
| + | Success. Please check that the upgraded cluster works. If it does, | ||
| + | you can remove the old cluster with | ||
| + | pg_dropcluster 15 main | ||
| + | |||
| + | Ver Cluster Port Status Owner Data directory | ||
| + | 15 main 5433 down | ||
| + | Ver Cluster Port Status Owner Data directory | ||
| + | 16 main 5432 online postgres / | ||
| + | </ | ||
| + | <code bash> | ||
| + | apt purge postgresql-15 postgresql-client-15 | ||
| + | </ | ||
| + | |||
| + | ===== Postgresql 16 to 17 ===== | ||
| + | <code bash> pg_lsclusters</ | ||
| + | < | ||
| + | Ver Cluster Port Status Owner Data directory | ||
| + | 16 main 5432 online postgres / | ||
| + | 17 main 5433 online postgres / | ||
| + | <code bash> | ||
| + | pg_lsclusters</ | ||
| + | < | ||
| + | Ver Cluster Port Status Owner Data directory | ||
| + | 16 main 5432 online postgres / | ||
| + | </ | ||
| + | <code bash> | ||
| + | < | ||
| + | .... | ||
| + | Stopping target cluster... | ||
| + | Stopping old cluster... | ||
| + | Disabling automatic startup of old cluster... | ||
| + | Starting upgraded cluster on port 5432... | ||
| + | Running finish phase upgrade hook scripts ... | ||
| + | vacuumdb: processing database " | ||
| + | vacuumdb: processing database " | ||
| + | vacuumdb: processing database " | ||
| + | vacuumdb: processing database " | ||
| + | vacuumdb: processing database " | ||
| + | vacuumdb: processing database " | ||
| + | vacuumdb: processing database " | ||
| + | vacuumdb: processing database " | ||
| + | vacuumdb: processing database " | ||
| + | |||
| + | Success. Please check that the upgraded cluster works. If it does, | ||
| + | you can remove the old cluster with | ||
| + | pg_dropcluster 16 main | ||
| + | |||
| + | Ver Cluster Port Status Owner Data directory | ||
| + | 16 main 5433 down | ||
| + | Ver Cluster Port Status Owner Data directory | ||
| + | 17 main 5432 online postgres / | ||
| + | |||
| + | </ | ||
| + | <code bash> | ||
| + | apt purge postgresql-16 postgresql-client-16 | ||
| + | </ | ||
| + | ====== Logrotate ====== | ||
| + | There was an issue with / | ||
| + | <code bash> | ||
| + | systemctl --failed | ||
| + | UNIT LOAD | ||
| + | ● logrotate.service loaded failed failed Rotate log files | ||
| + | |||
| + | LOAD = Reflects whether the unit definition was properly loaded. | ||
| + | ACTIVE = The high-level unit activation state, i.e. generalization of SUB. | ||
| + | SUB = The low-level unit activation state, values depend on unit type. | ||
| + | 1 loaded units listed. | ||
| + | |||
| + | systemctl status logrotate | ||
| + | × logrotate.service - Rotate log files | ||
| + | | ||
| + | | ||
| + | TriggeredBy: | ||
| + | Docs: man: | ||
| + | | ||
| + | Process: 96050 ExecStart=/ | ||
| + | Main PID: 96050 (code=exited, | ||
| + | CPU: 24ms | ||
| + | |||
| + | Jun 01 06:54:28 svx-vs1 systemd[1]: Starting Rotate log files... | ||
| + | Jun 01 06:54:28 svx-vs1 logrotate[96050]: | ||
| + | Jun 01 06:54:28 svx-vs1 logrotate[96050]: | ||
| + | Jun 01 06:54:28 svx-vs1 systemd[1]: logrotate.service: | ||
| + | Jun 01 06:54:28 svx-vs1 systemd[1]: logrotate.service: | ||
| + | Jun 01 06:54:28 svx-vs1 systemd[1]: Failed to start Rotate log files. | ||
| + | </ | ||
| + | Indeed: | ||
| + | <code bash> | ||
| + | grep "/ | ||
| + | / | ||
| + | / | ||
| + | / | ||
| + | / | ||
| + | </ | ||
| + | |||
| + | let's " | ||
| + | < | ||
| + | mv / | ||
| + | systemctl restart logrotate | ||
| + | </ | ||
| + | ====== postgreSQL ====== | ||
| + | :! using psql works, the .conf crashes the gvmd service... :!:\\ | ||
| + | Using [[https:// | ||
| + | <code bash> su - postgres | ||
| + | psql</ | ||
| + | <code sql> | ||
| + | ALTER SYSTEM SET | ||
| + | | ||
| + | ALTER SYSTEM SET | ||
| + | | ||
| + | ALTER SYSTEM SET | ||
| + | | ||
| + | ALTER SYSTEM SET | ||
| + | | ||
| + | ALTER SYSTEM SET | ||
| + | | ||
| + | ALTER SYSTEM SET | ||
| + | | ||
| + | ALTER SYSTEM SET | ||
| + | | ||
| + | ALTER SYSTEM SET | ||
| + | | ||
| + | ALTER SYSTEM SET | ||
| + | | ||
| + | ALTER SYSTEM SET | ||
| + | | ||
| + | ALTER SYSTEM SET | ||
| + | | ||
| + | ALTER SYSTEM SET | ||
| + | | ||
| + | ALTER SYSTEM SET | ||
| + | | ||
| + | ALTER SYSTEM SET | ||
| + | | ||
| + | ALTER SYSTEM SET | ||
| + | | ||
| + | ALTER SYSTEM SET | ||
| + | | ||
| + | </ | ||
| + | ===== Optimisation ===== | ||
| + | From : https:// | ||
| + | <code bash> | ||
| + | / | ||
| + | / | ||
| + | / | ||
| + | / | ||
| + | / | ||
| + | / | ||
| + | / | ||
| + | </ | ||
| + | in the crontab: | ||
| + | <code bash> for optimize in vaccum analyse cleanup-report-formats cleanup-result-nvts cleanup-config-prefs cleanup-result-severities update-report-cache; | ||
| + | |||
| + | |||
| + | |||
| + | |||
| + | |||
| + | |||
| + | ====== Checks after update ====== | ||
| + | * scan | ||
| + | * pdf generation | ||
| + | |||
| + | ====== Journal ====== | ||
| + | * PDF 0 Byte -> edit var/ | ||
| + | * Redis server out of memory <=> task stopped ( add more ram (32GB) + 64GB swap)< | ||
| + | dd if=/ | ||
| + | echo " | ||
| + | chmod 0600 / | ||
| + | mkswap / | ||
| + | swapon / | ||
| + | |||
| + | echo "/ | ||
| + | |||
| + | |||
| + | ====== Services update ====== | ||
| + | <code bash> | ||
| + | apt update && apt dist-upgrade -y | ||
| + | gvm-stop | ||
| + | su - _gvm -s /bin/sh -c "gvmd --migrate" | ||
| + | vi / | ||
| + | systemctl daemon-reload && systemctl restart gvmd.service gsad.service greenbone-security-assistant.service</ | ||
| + | |||
| + | |||
| + | ====== Running on different port ====== | ||
| + | <code bash> vi / | ||
| + | <code perl> | ||
| + | [Unit] | ||
| + | Description=Greenbone Security Assistant daemon (gsad) | ||
| + | Documentation=man: | ||
| + | After=network.target gvmd.service | ||
| + | Wants=gvmd.service | ||
| + | |||
| + | [Service] | ||
| + | Type=exec | ||
| + | User=_gvm | ||
| + | Group=_gvm | ||
| + | RuntimeDirectory=gsad | ||
| + | RuntimeDirectoryMode=2775 | ||
| + | PIDFile=/ | ||
| + | ExecStart=/ | ||
| + | Restart=always | ||
| + | TimeoutStopSec=10 | ||
| + | |||
| + | [Install] | ||
| + | WantedBy=multi-user.target | ||
| + | Alias=greenbone-security-assistant.service | ||
| + | </ | ||
| + | Change | ||
| + | <code perl> ExecStart=/ | ||
| + | to | ||
| + | <code perl> ExecStart=/ | ||
| + | |||
| + | ====== Email size ====== | ||
| + | If you get the message "Note: This report exceeds the maximum length of XXXXX characters..." | ||
| + | <code bash> | ||
| + | vi / | ||
| + | <code perl> | ||
| + | ... | ||
| + | ExecStart=/ | ||
| + | ... | ||
| + | </ | ||
| + | <code bash> | ||
| + | systemctl daemon-reload | ||
| + | systemctl restart gvmd | ||
| + | systemctl status gvmd | ||
| + | </ | ||
| + | <code perl> | ||
| + | ● gvmd.service - Greenbone Vulnerability Manager daemon (gvmd) | ||
| + | | ||
| + | | ||
| + | Docs: man:gvmd(8) | ||
| + | Process: 278417 ExecStart=/ | ||
| + | Main PID: 278420 (gvmd) | ||
| + | Tasks: 1 (limit: 9312) | ||
| + | | ||
| + | CPU: 1.742s | ||
| + | | ||
| + | | ||
| + | |||
| + | Nov 15 09:29:48 kali systemd[1]: Starting gvmd.service - Greenbone Vulnerability Manager daemon (gvmd)... | ||
| + | Nov 15 09:29:48 kali systemd[1]: gvmd.service: | ||
| + | Nov 15 09:29:51 kali systemd[1]: Started gvmd.service - Greenbone Vulnerability Manager daemon (gvmd). | ||
| + | </ | ||
| + | Better: | ||
| + | < | ||
| + | ExecStart=/ | ||
| + | </ | ||
| + | ====== References ====== | ||
| + | * https:// | ||
| + | * https:// | ||
| + | * https:// | ||
| + | * https:// | ||
| + | * https:// | ||
| + | * https:// | ||
| + | * https:// | ||
| + | * https:// | ||
| + | * https:// | ||
| + | * https:// | ||
| + | * https:// | ||
| + | * https:// | ||
| + | * https:// | ||
| + | * https:// | ||
