Différences
Ci-dessous, les différences entre deux révisions de la page.
| Prochaine révision | Révision précédente | ||
| elearning:workbooks:centos:6:sec:l108 [2020/02/21 06:10] – créée admin | elearning:workbooks:centos:6:sec:l108 [2024/04/26 09:28] (Version actuelle) – admin | ||
|---|---|---|---|
| Ligne 1: | Ligne 1: | ||
| ~~PDF: | ~~PDF: | ||
| - | Version : **2020.01** | + | Version : **2024.01** |
| Dernière mise-à-jour : ~~LASTMOD~~ | Dernière mise-à-jour : ~~LASTMOD~~ | ||
| Ligne 7: | Ligne 7: | ||
| ======LRF408 - Sécurité Applicative====== | ======LRF408 - Sécurité Applicative====== | ||
| - | Dans cette unité, vous allez apprendre : | + | =====Contenu du Module===== |
| - | * Comment installer et utiliser l' | + | * **LRF408 - Sécurité Applicative** |
| - | * Comment installer et utiliser l' | + | * Contenu du Module |
| - | * Comment mettre en place un **chroot** | + | |
| - | * Comment sécuriser | + | |
| + | * Les Outils | ||
| + | * LAB #1 - Netwox | ||
| + | * Installation | ||
| + | * Utilisation | ||
| + | * Avertissement important | ||
| + | * LAB #2 - OpenVAS | ||
| + | | ||
| + | | ||
| + | * Installation | ||
| + | | ||
| + | | ||
| + | * Analyse des Résultats | ||
| + | * Les Contres-Mesures | ||
| + | * LAB #3 - La commande | ||
| + | | ||
| + | | ||
| + | * Testez | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | * Hôte virtuel par nom | ||
| + | * Hôte virtuel par adresse IP | ||
| + | * mod_auth_basic | ||
| + | * Configuration de la sécurité avec .htaccess | ||
| + | * Mise en place d'un fichier de mots de passe | ||
| + | * mod_auth_mysql | ||
| + | * Installation | ||
| + | * Configuration de MariaDB | ||
| + | * Configuration d' | ||
| + | * mod_authnz_ldap | ||
| + | * mod_ssl | ||
| + | * Présentation de SSL | ||
| + | * Fonctionnement de SSL | ||
| + | * Installation de ssl | ||
| + | * Configuration de SSL | ||
| + | * Mise en place des paramètres de sécurité SSL | ||
| + | * Tester Votre Configuration | ||
| =====Le Problématique===== | =====Le Problématique===== | ||
| Ligne 19: | Ligne 57: | ||
| =====Préparation===== | =====Préparation===== | ||
| - | |||
| - | <WRAP center round todo 50%> | ||
| - | **A Faire** - Arrêtez votre VM et configurez la RAM à 2 Go. Redémarrez votre VM. | ||
| - | </ | ||
| =====Les Outils===== | =====Les Outils===== | ||
| Ligne 35: | Ligne 69: | ||
| < | < | ||
| - | [root@centos7 ~]# wget http://ftp.tu-chemnitz.de/ | + | [root@centos7 ~]# wget https://www.dropbox.com/scl/fi/e55p8pmn5sbo4uflddpue/ |
| </ | </ | ||
| Ligne 206: | Ligne 240: | ||
| < | < | ||
| - | [root@centos6 ~]# yum install openvas-scanner openvas-manager openvas-gsa openvas-cli | + | [root@centos6 ~]# yum install openvas-scanner openvas-manager openvas-gsa openvas-cli |
| </ | </ | ||
| Ligne 427: | Ligne 461: | ||
| </ | </ | ||
| - | Mettez à jour les modules d' | + | Téléchargez le script **greenbone-nvt-sync** |
| < | < | ||
| - | [root@centos7 ~]# openvas-nvt-sync | + | [root@centos7 ~]# wget https:// |
| + | |||
| + | [root@centos7 ~]# mv greenbone-nvt-sync? | ||
| + | </ | ||
| + | |||
| + | Si vous ne pouvez pas téléchargez le script **greenbone-nvt-sync**, | ||
| + | |||
| + | < | ||
| + | [root@centos7 ~]# vi greenbone-nvt-sync | ||
| + | [root@centos7 ~]# cat greenbone-nvt-sync | ||
| + | #!/bin/sh | ||
| + | # Copyright (C) 2009-2021 Greenbone Networks GmbH | ||
| + | # | ||
| + | # SPDX-License-Identifier: | ||
| + | # | ||
| + | # 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 2 | ||
| + | # 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. | ||
| + | # 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, write to the Free Software | ||
| + | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | ||
| + | |||
| + | # This script updates the local Network Vulnerability Tests (NVTs) from the | ||
| + | # Greenbone Security Feed (GSF) or the Greenbone Community Feed (GCF). | ||
| + | |||
| + | VERSION=@OPENVAS_VERSION@ | ||
| + | |||
| + | # SETTINGS | ||
| + | # ======== | ||
| + | |||
| + | # PRIVATE_SUBDIR defines a subdirectory of the NVT directory that is excluded | ||
| + | # from the feed sync. This is where to place your own NVTs. | ||
| + | if [ -z " | ||
| + | then | ||
| + | PRIVATE_SUBDIR=" | ||
| + | fi | ||
| + | |||
| + | # RSYNC_DELETE controls whether files which are not part of the repository will | ||
| + | # be removed from the local directory after synchronization. The default value | ||
| + | # for this setting is | ||
| + | # " | ||
| + | # which means that files which are not part of the feed or private directory | ||
| + | # will be deleted. | ||
| + | RSYNC_DELETE=" | ||
| + | |||
| + | # RSYNC_SSH_OPTS contains options which should be passed to ssh for the rsync | ||
| + | # connection to the repository. | ||
| + | RSYNC_SSH_OPTS=" | ||
| + | |||
| + | # RSYNC_COMPRESS specifies the compression level to use for the rsync connection. | ||
| + | RSYNC_COMPRESS=" | ||
| + | |||
| + | # RSYNC_CHMOD specifies the permissions to chmod the files to. | ||
| + | RSYNC_CHMOD=" | ||
| + | |||
| + | # Verbosity flag for rsync. " | ||
| + | RSYNC_VERBOSE=" | ||
| + | |||
| + | # RSYNC_OPTIONS controls the general parameters for the rsync connection. | ||
| + | RSYNC_OPTIONS=" | ||
| + | |||
| + | # Script and feed information which will be made available to user through | ||
| + | # command line options and automated tools. | ||
| + | # Script name which will be used for logging | ||
| + | SCRIPT_NAME=" | ||
| + | |||
| + | # Result of selftest () is stored here. If it is not 0, the selftest has failed | ||
| + | # and the sync script is unlikely to work. | ||
| + | SELFTEST_FAIL=0 | ||
| + | |||
| + | # Port to use for synchronization. Default value is 24. | ||
| + | PORT=24 | ||
| + | |||
| + | # Directory where the OpenVAS configuration is located | ||
| + | OPENVAS_SYSCONF_DIR=" | ||
| + | |||
| + | # Directory where the feed update lock file will be placed. | ||
| + | OPENVAS_FEED_LOCK_PATH=" | ||
| + | |||
| + | # Location of the GSF Access Key | ||
| + | ACCESS_KEY=" | ||
| + | |||
| + | # If ENABLED is set to 0, the sync script will not perform a synchronization. | ||
| + | ENABLED=1 | ||
| + | |||
| + | # LOG_CMD defines the command to use for logging. To have logger log to stderr | ||
| + | # as well as syslog, add " | ||
| + | # all will be logged in the standard error and the socket error check will be | ||
| + | # disabled. | ||
| + | LOG_CMD=" | ||
| + | |||
| + | check_logger () { | ||
| + | logger -p daemon.info -t $SCRIPT_NAME " | ||
| + | if [ $? -gt 0 ] | ||
| + | then | ||
| + | LOG_CMD=" | ||
| + | $LOG_CMD -p daemon.warning "The log facility is not working as expected. All messages will be written to the standard error stream." | ||
| + | fi | ||
| + | } | ||
| + | check_logger | ||
| + | |||
| + | |||
| + | # Source configuration file if it is readable | ||
| + | [ -r $OPENVAS_SYSCONF_DIR/ | ||
| + | |||
| + | # NVT_DIR is the place where the NVTs are located. | ||
| + | if [ -z " | ||
| + | then | ||
| + | NVT_DIR=" | ||
| + | fi | ||
| + | |||
| + | log_write () { | ||
| + | $LOG_CMD -p daemon.notice $1 | ||
| + | } | ||
| + | |||
| + | log_debug () { | ||
| + | $LOG_CMD -p daemon.debug " | ||
| + | } | ||
| + | |||
| + | log_info () { | ||
| + | $LOG_CMD -p daemon.info " | ||
| + | } | ||
| + | |||
| + | log_notice () { | ||
| + | $LOG_CMD -p daemon.notice " | ||
| + | } | ||
| + | |||
| + | log_warning () { | ||
| + | $LOG_CMD -p daemon.warning " | ||
| + | } | ||
| + | |||
| + | log_err () { | ||
| + | $LOG_CMD -p daemon.err " | ||
| + | } | ||
| + | |||
| + | stderr_write () | ||
| + | { | ||
| + | echo " | ||
| + | } | ||
| + | |||
| + | # Read the general information about the feed origin from | ||
| + | # the file " | ||
| + | get_feed_info () | ||
| + | { | ||
| + | INFOFILE=" | ||
| + | if [ -r $INFOFILE ] ; then | ||
| + | FEED_VERSION=`grep PLUGIN_SET $INFOFILE | sed -e ' | ||
| + | FEED_NAME=`awk -F\" '/ | ||
| + | FEED_VENDOR=`awk -F\" '/ | ||
| + | FEED_HOME=`awk -F\" '/ | ||
| + | FEED_PRESENT=1 | ||
| + | else | ||
| + | FEED_PRESENT=0 | ||
| + | fi | ||
| + | |||
| + | if [ -z " | ||
| + | FEED_NAME=" | ||
| + | fi | ||
| + | |||
| + | if [ -z " | ||
| + | FEED_VENDOR=" | ||
| + | fi | ||
| + | |||
| + | if [ -z " | ||
| + | FEED_HOME=" | ||
| + | fi | ||
| + | } | ||
| + | |||
| + | # Prevent that root executes this script | ||
| + | if [ "`id -u`" -eq " | ||
| + | then | ||
| + | stderr_write "$0 must not be executed as privileged user root" | ||
| + | stderr_write | ||
| + | stderr_write " | ||
| + | stderr_write " | ||
| + | stderr_write "files with a non-privileged user." | ||
| + | |||
| + | log_err " | ||
| + | exit 1 | ||
| + | fi | ||
| + | |||
| + | # Always try to get the information when started. | ||
| + | # This also ensures variables like FEED_PRESENT are set. | ||
| + | get_feed_info | ||
| + | |||
| + | # Determine whether a GSF access key is present. If yes, | ||
| + | # then use the Greenbone Security Feed. Else use the | ||
| + | # Greenbone Community Feed. | ||
| + | if [ -e $ACCESS_KEY ] | ||
| + | then | ||
| + | RESTRICTED=1 | ||
| + | else | ||
| + | RESTRICTED=0 | ||
| + | |||
| + | if [ -z " | ||
| + | COMMUNITY_NVT_RSYNC_FEED=rsync:// | ||
| + | # An alternative syntax which might work if the above doesn' | ||
| + | # COMMUNITY_NVT_RSYNC_FEED=rsync@feed.community.greenbone.net::/ | ||
| + | fi | ||
| + | fi | ||
| + | |||
| + | RSYNC=`command -v rsync` | ||
| + | |||
| + | if [ -z " | ||
| + | SYNC_TMP_DIR=/ | ||
| + | # If we have mktemp, create a temporary dir (safer) | ||
| + | if [ -n " | ||
| + | SYNC_TMP_DIR=`mktemp -t -d greenbone-nvt-sync.XXXXXXXXXX` || { echo " | ||
| + | trap "rm -rf $SYNC_TMP_DIR" | ||
| + | fi | ||
| + | else | ||
| + | SYNC_TMP_DIR=" | ||
| + | fi | ||
| + | |||
| + | # Initialize this indicator variable with default assuming the | ||
| + | # feed is not up-to-date. | ||
| + | FEED_CURRENT=0 | ||
| + | |||
| + | # This function uses gos-state-manager to get information about the settings. | ||
| + | # If gos-state-manager is not installed the values of the settings can not be | ||
| + | # retrieved. | ||
| + | # | ||
| + | # Input: option | ||
| + | # Output: value as string or empty String if gos-state-manager is not installed | ||
| + | # or option not set | ||
| + | get_value () | ||
| + | { | ||
| + | value="" | ||
| + | key=$1 | ||
| + | if which gos-state-manager 1>/ | ||
| + | then | ||
| + | if gos-state-manager get " | ||
| + | then | ||
| + | value=" | ||
| + | fi | ||
| + | fi | ||
| + | echo " | ||
| + | } | ||
| + | |||
| + | # Creates a restricted access copy of the access key if necessary. | ||
| + | setup_temp_access_key () { | ||
| + | if [ -e " | ||
| + | then | ||
| + | FILE_ACCESS=`stat -c%a " | ||
| + | fi | ||
| + | if [ -n " | ||
| + | then | ||
| + | TEMP_ACCESS_KEY_DIR=`mktemp -d` | ||
| + | TEMP_ACCESS_KEY=" | ||
| + | cp " | ||
| + | chmod 400 " | ||
| + | else | ||
| + | TEMP_ACCESS_KEY_DIR="" | ||
| + | TEMP_ACCESS_KEY=" | ||
| + | fi | ||
| + | } | ||
| + | |||
| + | # Deletes the read-only copy of the access key. | ||
| + | cleanup_temp_access_key () { | ||
| + | if [ -n " | ||
| + | then | ||
| + | rm -rf " | ||
| + | fi | ||
| + | TEMP_ACCESS_KEY_DIR="" | ||
| + | TEMP_ACCESS_KEY="" | ||
| + | } | ||
| + | |||
| + | is_feed_current () { | ||
| + | if [ -z " | ||
| + | then | ||
| + | log_write "Could not determine feed version." | ||
| + | FEED_CURRENT=0 | ||
| + | return $FEED_CURRENT | ||
| + | fi | ||
| + | |||
| + | if [ -z " | ||
| + | then | ||
| + | log_notice "rsync not available, skipping feed version test" | ||
| + | FEED_CURRENT=0 | ||
| + | rm -rf $FEED_INFO_TEMP_DIR | ||
| + | cleanup_temp_access_key | ||
| + | return 0 | ||
| + | fi | ||
| + | |||
| + | FEED_INFO_TEMP_DIR=`mktemp -d` | ||
| + | |||
| + | if [ -e $ACCESS_KEY ] | ||
| + | then | ||
| + | gsmproxy=$(get_value proxy_feed | sed -r -e ' | ||
| + | syncport=$(get_value syncport) | ||
| + | if [ " | ||
| + | then | ||
| + | PORT=" | ||
| + | fi | ||
| + | |||
| + | read feeduser < $ACCESS_KEY | ||
| + | custid=`awk -F@ 'NR > 1 { exit }; { print $1 }' $ACCESS_KEY` | ||
| + | if [ -z " | ||
| + | then | ||
| + | log_err "Could not determine credentials, | ||
| + | exit 1 | ||
| + | fi | ||
| + | |||
| + | setup_temp_access_key | ||
| + | |||
| + | if [ " | ||
| + | then | ||
| + | RSYNC_SSH_PROXY_CMD="" | ||
| + | else | ||
| + | if [ -e $OPENVAS_SYSCONF_DIR/ | ||
| + | then | ||
| + | RSYNC_SSH_PROXY_CMD=" | ||
| + | else | ||
| + | RSYNC_SSH_PROXY_CMD=" | ||
| + | fi | ||
| + | fi | ||
| + | |||
| + | rsync -e "ssh $RSYNC_SSH_OPTS $RSYNC_SSH_PROXY_CMD -p $PORT -i $TEMP_ACCESS_KEY" | ||
| + | |||
| + | if [ $? -ne 0 ] | ||
| + | then | ||
| + | log_err " | ||
| + | rm -rf " | ||
| + | exit 1 | ||
| + | fi | ||
| + | else | ||
| + | # Sleep for five seconds (a previous feed might have been synced a few seconds before) to prevent | ||
| + | # IP blocking due to network equipment in between keeping the previous connection too long open. | ||
| + | sleep 5 | ||
| + | log_notice "No Greenbone Security Feed access key found, falling back to Greenbone Community Feed" | ||
| + | eval " | ||
| + | if [ $? -ne 0 ] | ||
| + | then | ||
| + | log_err "rsync failed, aborting synchronization." | ||
| + | rm -rf " | ||
| + | exit 1 | ||
| + | fi | ||
| + | fi | ||
| + | |||
| + | FEED_VERSION_SERVER=`grep PLUGIN_SET $FEED_INFO_TEMP_DIR/ | ||
| + | |||
| + | if [ -z " | ||
| + | then | ||
| + | log_err "Could not determine server feed version." | ||
| + | rm -rf $FEED_INFO_TEMP_DIR | ||
| + | cleanup_temp_access_key | ||
| + | exit 1 | ||
| + | fi | ||
| + | # Check against FEED_VERSION | ||
| + | if [ $FEED_VERSION -lt $FEED_VERSION_SERVER ] ; then | ||
| + | FEED_CURRENT=0 | ||
| + | else | ||
| + | FEED_CURRENT=1 | ||
| + | fi | ||
| + | # Cleanup | ||
| + | rm -rf " | ||
| + | cleanup_temp_access_key | ||
| + | |||
| + | return $FEED_CURRENT | ||
| + | } | ||
| + | |||
| + | do_rsync_community_feed () { | ||
| + | # Sleep for five seconds (a previous feed might have been synced a few seconds before) to prevent | ||
| + | # IP blocking due to network equipment in between keeping the previous connection too long open. | ||
| + | sleep 5 | ||
| + | log_notice " | ||
| + | mkdir -p " | ||
| + | eval " | ||
| + | if [ $? -ne 0 ] ; then | ||
| + | log_err "rsync failed." | ||
| + | exit 1 | ||
| + | fi | ||
| + | # Sleep for five seconds (after the above rsync call) to prevent IP blocking due | ||
| + | # to network equipment in between keeping the previous connection too long open. | ||
| + | sleep 5 | ||
| + | eval " | ||
| + | if [ $? -ne 0 ] ; then | ||
| + | log_err "rsync failed." | ||
| + | exit 1 | ||
| + | fi | ||
| + | } | ||
| + | |||
| + | sync_nvts(){ | ||
| + | if [ $ENABLED -ne 1 ] | ||
| + | then | ||
| + | log_write "NVT synchronization is disabled, exiting." | ||
| + | exit 0 | ||
| + | fi | ||
| + | |||
| + | if [ -e $ACCESS_KEY ] | ||
| + | then | ||
| + | log_write " | ||
| + | if [ $FEED_PRESENT -eq 1 ] ; then | ||
| + | FEEDCOUNT=`grep -E " | ||
| + | log_write " | ||
| + | else | ||
| + | log_write " | ||
| + | fi | ||
| + | notsynced=1 | ||
| + | retried=0 | ||
| + | |||
| + | mkdir -p " | ||
| + | read feeduser < $ACCESS_KEY | ||
| + | custid=`awk -F@ 'NR > 1 { exit }; { print $1 }' $ACCESS_KEY` | ||
| + | if [ -z " | ||
| + | then | ||
| + | log_err "Could not determine credentials, | ||
| + | exit 1 | ||
| + | fi | ||
| + | |||
| + | setup_temp_access_key | ||
| + | |||
| + | while [ $notsynced -eq 1 ] | ||
| + | do | ||
| + | |||
| + | gsmproxy=$(get_value proxy_feed | sed -r -e ' | ||
| + | syncport=$(get_value syncport) | ||
| + | if [ " | ||
| + | then | ||
| + | PORT=" | ||
| + | fi | ||
| + | |||
| + | if [ " | ||
| + | then | ||
| + | RSYNC_SSH_PROXY_CMD="" | ||
| + | else | ||
| + | if [ -e $OPENVAS_SYSCONF_DIR/ | ||
| + | RSYNC_SSH_PROXY_CMD=" | ||
| + | else | ||
| + | RSYNC_SSH_PROXY_CMD=" | ||
| + | fi | ||
| + | fi | ||
| + | rsync -e "ssh $RSYNC_SSH_OPTS $RSYNC_SSH_PROXY_CMD -p $PORT -i $TEMP_ACCESS_KEY" | ||
| + | if [ $? -ne 0 ] ; then | ||
| + | log_err "rsync failed, aborting synchronization." | ||
| + | exit 1 | ||
| + | fi | ||
| + | rsync -e "ssh $RSYNC_SSH_OPTS $RSYNC_SSH_PROXY_CMD -p $PORT -i $TEMP_ACCESS_KEY" | ||
| + | if [ $? -ne 0 ] ; then | ||
| + | log_err "rsync failed, aborting synchronization." | ||
| + | exit 1 | ||
| + | fi | ||
| + | eval "cd \" | ||
| + | if [ $? -ne 0 ] ; then | ||
| + | if [ -n " | ||
| + | then | ||
| + | log_err "Feed integrity check failed twice, aborting synchronization." | ||
| + | cleanup_temp_access_key | ||
| + | exit 1 | ||
| + | else | ||
| + | log_write "The feed integrity check failed. This may be due to a concurrent feed update or other temporary issues." | ||
| + | log_write " | ||
| + | sleep 15 | ||
| + | retried=1 | ||
| + | fi | ||
| + | else | ||
| + | notsynced=0 | ||
| + | fi | ||
| + | done | ||
| + | cleanup_temp_access_key | ||
| + | log_write " | ||
| + | get_feed_info | ||
| + | if [ $FEED_PRESENT -eq 1 ] ; then | ||
| + | FEEDCOUNT=`grep -E " | ||
| + | log_write " | ||
| + | else | ||
| + | log_write " | ||
| + | fi | ||
| + | else | ||
| + | log_notice "No Greenbone Security Feed access key found, falling back to Greenbone Community Feed" | ||
| + | do_rsync_community_feed | ||
| + | fi | ||
| + | } | ||
| + | |||
| + | do_self_test () | ||
| + | { | ||
| + | MD5SUM_AVAIL=`command -v md5sum` | ||
| + | if [ $? -ne 0 ] ; then | ||
| + | SELFTEST_FAIL=1 | ||
| + | stderr_write "The md5sum binary could not be found." | ||
| + | fi | ||
| + | |||
| + | RSYNC_AVAIL=`command -v rsync` | ||
| + | if [ $? -ne 0 ] ; then | ||
| + | SELFTEST_FAIL=1 | ||
| + | stderr_write "The rsync binary could not be found." | ||
| + | fi | ||
| + | } | ||
| + | |||
| + | do_describe () | ||
| + | { | ||
| + | echo "This script synchronizes an NVT collection with the ' | ||
| + | echo "The ' | ||
| + | echo " | ||
| + | } | ||
| + | |||
| + | do_feedversion () { | ||
| + | if [ $FEED_PRESENT -eq 1 ] ; then | ||
| + | echo $FEED_VERSION | ||
| + | else | ||
| + | stderr_write "The file containing the feed version could not be found." | ||
| + | exit 1 | ||
| + | fi | ||
| + | } | ||
| + | |||
| + | do_sync () | ||
| + | { | ||
| + | do_self_test | ||
| + | if [ $SELFTEST_FAIL -ne 0 ] ; then | ||
| + | exit $SELFTEST_FAIL | ||
| + | fi | ||
| + | |||
| + | if [ $FEED_CURRENT -eq 1 ] | ||
| + | then | ||
| + | log_write "Feed is already current, skipping synchronization." | ||
| + | else | ||
| + | ( | ||
| + | chmod +660 $OPENVAS_FEED_LOCK_PATH | ||
| + | flock -n 9 | ||
| + | if [ $? -eq 1 ] ; then | ||
| + | log_warning " | ||
| + | exit 1 | ||
| + | fi | ||
| + | date > $OPENVAS_FEED_LOCK_PATH | ||
| + | sync_nvts | ||
| + | echo -n $OPENVAS_FEED_LOCK_PATH | ||
| + | )9>> | ||
| + | fi | ||
| + | } | ||
| + | |||
| + | do_help () { | ||
| + | echo "$0: Sync NVT data" | ||
| + | echo " --describe | ||
| + | echo " --feedcurrent | ||
| + | echo " --feedversion | ||
| + | echo " --help | ||
| + | echo " --identify | ||
| + | echo " --nvtdir dir set dir as NVT directory" | ||
| + | echo " --selftest | ||
| + | echo " --verbose | ||
| + | echo " --version | ||
| + | echo "" | ||
| + | echo "" | ||
| + | echo " | ||
| + | echo " | ||
| + | echo " | ||
| + | echo " | ||
| + | echo "Note that you can use standard ones as well (e.g. RSYNC_PROXY) for rsync" | ||
| + | echo "" | ||
| + | exit 0 | ||
| + | } | ||
| + | |||
| + | while test $# -gt 0; do | ||
| + | case " | ||
| + | --version) | ||
| + | echo $VERSION | ||
| + | exit 0 | ||
| + | ;; | ||
| + | --identify) | ||
| + | echo " | ||
| + | exit 0 | ||
| + | ;; | ||
| + | --selftest) | ||
| + | do_self_test | ||
| + | exit $SELFTEST_FAIL | ||
| + | ;; | ||
| + | --describe) | ||
| + | do_describe | ||
| + | exit 0 | ||
| + | ;; | ||
| + | --feedversion) | ||
| + | do_feedversion | ||
| + | exit 0 | ||
| + | ;; | ||
| + | --help) | ||
| + | do_help | ||
| + | exit 0 | ||
| + | ;; | ||
| + | --nvt-dir) | ||
| + | NVT_DIR=" | ||
| + | shift | ||
| + | ;; | ||
| + | --feedcurrent) | ||
| + | is_feed_current | ||
| + | exit $? | ||
| + | ;; | ||
| + | --verbose) | ||
| + | RSYNC_VERBOSE=" | ||
| + | ;; | ||
| + | esac | ||
| + | shift | ||
| + | done | ||
| + | |||
| + | do_sync | ||
| + | |||
| + | exit 0 | ||
| + | </ | ||
| + | |||
| + | Rendez le script exécutable : | ||
| + | |||
| + | < | ||
| + | [root@centos7 ~]# chmod +x greenbone-nvt-sync | ||
| + | </ | ||
| + | |||
| + | Déplacez le script vers **/ | ||
| + | |||
| + | < | ||
| + | [root@centos7 ~]# mv greenbone-nvt-sync /usr/sbin | ||
| + | mv: overwrite ‘/ | ||
| + | </ | ||
| + | |||
| + | Devenez l' | ||
| + | |||
| + | < | ||
| + | |||
| + | [root@centos7 ~]# su - trainee | ||
| + | Last login: Thu Mar 4 10:28:01 UTC 2021 from ns3072874.ip-79-137-68.eu on pts/0 | ||
| + | [trainee@centos7 ~]$ greenbone-nvt-sync | ||
| + | ... | ||
| + | [trainee@centos7 ~]$ exit | ||
| + | [root@centos7 ~]# | ||
| </ | </ | ||
| - | Dans le cas où cette commande retourne une erreur, procédez de la façon suivante pour mettre à jour les modules d' | + | Déplacez |
| < | < | ||
| - | [root@centos7 ~]# wget http://dl.greenbone.net/community-nvt-feed-current.tar.bz2 | + | [root@centos7 ~]# mv /home/trainee/@OPENVAS_NVT_DIR@/ |
| - | [root@centos7 ~]# tar xvf community-nvt-feed-current.tar.bz2 -C / | + | |
| </ | </ | ||
| - | Les modules d' | + | Vérifiez ensuite la réussite de la commande précédente |
| < | < | ||
| - | [root@centos7 ~]# ls / | + | [root@centos7 ~]# ls -l / |
| - | 2008 | + | total 36288 |
| - | 2009 | + | drwxr-xr-x |
| - | 2010 | + | drwxr-xr-x |
| - | 2011 | + | drwxr-xr-x |
| - | 2012 | + | drwxr-xr-x |
| - | 2013 | + | drwxr-xr-x |
| - | 2014 | + | drwxr-xr-x |
| - | 2015 | + | drwxr-xr-x |
| - | 2016 | + | drwxr-xr-x |
| - | 2017 | + | drwxr-xr-x |
| - | 2018 | + | drwxr-xr-x |
| - | 404.inc | + | drwxr-xr-x 289 trainee trainee |
| - | 404.inc.asc | + | drwxr-xr-x 214 trainee trainee |
| - | aas_detect.nasl | + | drwxr-xr-x 180 trainee trainee |
| - | aas_detect.nasl.asc | + | drwxr-xr-x |
| - | adaptbb_detect.nasl | + | -rw-r--r-- |
| - | adaptbb_detect.nasl.asc | + | -rw-r--r-- |
| - | AfterLogic_WebMail_Pro_detect.nasl | + | -rw-r--r-- |
| - | AfterLogic_WebMail_Pro_detect.nasl.asc | + | -rw-r--r-- |
| - | alcatel_backdoor_switch.nasl | + | -rw-r--r-- |
| - | alcatel_backdoor_switch.nasl.asc | + | -rw-r--r-- |
| - | amanda_detect.nasl | + | -rw-r--r-- |
| - | amanda_detect.nasl.asc | + | -rw-r--r-- |
| + | -rw-r--r-- | ||
| + | -rw-r--r-- | ||
| + | -rw-r--r-- | ||
| + | -rw-r--r-- | ||
| + | -rw-r--r-- | ||
| + | -rw-r--r-- | ||
| + | drwxr-xr-x | ||
| + | -rw-r--r-- | ||
| + | -rw-r--r-- | ||
| + | -rw-r--r-- | ||
| + | -rw-r--r-- | ||
| + | -rw-r--r-- | ||
| --More-- | --More-- | ||
| </ | </ | ||
| Ligne 598: | Ligne 1270: | ||
| </ | </ | ||
| - | Contruisez | + | Construisez |
| < | < | ||
| Ligne 665: | Ligne 1337: | ||
| </ | </ | ||
| - | La prochaine étape donc consiste à récupérer la base SCAP (Security Content Automation Protocol) : | + | La prochaine étape donc consiste à récupérer la base SCAP (Security Content Automation Protocol). |
| + | |||
| + | Téléchargez le script **greenbone-feed-sync** | ||
| < | < | ||
| - | [root@centos7 ~]# openvas-scapdata-sync | + | [root@centos7 ~]# wget https:// |
| + | |||
| + | [root@centos7 ~]# mv greenbone-nvt-sync? | ||
| + | </ | ||
| + | |||
| + | Si vous ne pouvez pas téléchargez le script **greenbone-feed-sync**, | ||
| + | |||
| + | < | ||
| + | [root@centos7 ~]# vi greenbone-feed-sync | ||
| + | [root@centos7 ~]# cat greenbone-feed-sync | ||
| + | #!/bin/sh | ||
| + | # Copyright (C) 2011-2020 Greenbone Networks GmbH | ||
| + | # | ||
| + | # SPDX-License-Identifier: | ||
| + | # | ||
| + | # This program is free software: you can redistribute it and/or modify | ||
| + | # it under the terms of the GNU Affero 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. | ||
| + | # GNU Affero General Public License for more details. | ||
| + | # | ||
| + | # You should have received a copy of the GNU Affero General Public License | ||
| + | # along with this program. | ||
| + | |||
| + | # This script synchronizes a GVM installation with the | ||
| + | # feed data from either the Greenbone Security Feed (in | ||
| + | # case a GSF access key is present) or else from the Greenbone | ||
| + | # Community Feed. | ||
| + | |||
| + | log_notice () { | ||
| + | $LOG_CMD -p daemon.notice " | ||
| + | } | ||
| + | |||
| + | |||
| + | ########## SETTINGS | ||
| + | ########## ======== | ||
| + | |||
| + | # PRIVATE_SUBDIR defines a subdirectory of the feed data directory | ||
| + | # where files not part of the feed or database will not be deleted by rsync. | ||
| + | if [ -z " | ||
| + | then | ||
| + | PRIVATE_SUBDIR=" | ||
| + | fi | ||
| + | |||
| + | # RSYNC_DELETE controls whether files which are not part of the repository will | ||
| + | # be removed from the local directory after synchronization. The default value | ||
| + | # for this setting is | ||
| + | # " | ||
| + | # which means that files which are not part of the feed, feed info or private | ||
| + | # directory will be deleted. | ||
| + | RSYNC_DELETE=" | ||
| + | |||
| + | # RSYNC_SSH_OPTS contains options which should be passed to ssh for the rsync | ||
| + | # connection to the repository. | ||
| + | RSYNC_SSH_OPTS=" | ||
| + | |||
| + | # RSYNC_COMPRESS specifies the compression level to use for the rsync connection. | ||
| + | RSYNC_COMPRESS=" | ||
| + | |||
| + | # PORT controls the outgoing TCP port for updates. If PAT/ | ||
| + | # not used, this should be " | ||
| + | # the value 22 (Standard SSH) is useful. Only change if you know what you are | ||
| + | # doing. | ||
| + | PORT=24 | ||
| + | |||
| + | # SCRIPT_NAME is the name the scripts will use to identify itself and to mark | ||
| + | # log messages. | ||
| + | SCRIPT_NAME=" | ||
| + | |||
| + | # LOG_CMD defines the command to use for logging. To have logger log to stderr | ||
| + | # as well as syslog, add " | ||
| + | LOG_CMD=" | ||
| + | |||
| + | # LOCK_FILE is the name of the file used to lock the feed during sync or update. | ||
| + | if [ -z " | ||
| + | then | ||
| + | LOCK_FILE=" | ||
| + | fi | ||
| + | |||
| + | |||
| + | ########## GLOBAL VARIABLES | ||
| + | ########## ================ | ||
| + | |||
| + | VERSION=@GVMD_VERSION@ | ||
| + | |||
| + | [ -r " | ||
| + | |||
| + | if [ -z " | ||
| + | DROP_USER=" | ||
| + | fi | ||
| + | |||
| + | ACCESSKEY=" | ||
| + | |||
| + | # Note when running as root or restart as $DROP_USER if defined | ||
| + | if [ $(id -u) -eq 0 ] | ||
| + | then | ||
| + | if [ -z " | ||
| + | then | ||
| + | log_notice " | ||
| + | else | ||
| + | log_notice " | ||
| + | su --shell /bin/sh --command "$0 $*" " | ||
| + | exit $? | ||
| + | fi | ||
| + | fi | ||
| + | |||
| + | # Determine whether a GSF access key is present. If yes, | ||
| + | # then use the Greenbone Security Feed. Else use the | ||
| + | # Greenbone Community Feed. | ||
| + | if [ -e $ACCESSKEY ] | ||
| + | then | ||
| + | RESTRICTED=1 | ||
| + | |||
| + | if [ -z " | ||
| + | FEED_VENDOR=" | ||
| + | fi | ||
| + | |||
| + | if [ -z " | ||
| + | FEED_HOME=" | ||
| + | fi | ||
| + | |||
| + | else | ||
| + | RESTRICTED=0 | ||
| + | |||
| + | if [ -z " | ||
| + | FEED_VENDOR=" | ||
| + | fi | ||
| + | |||
| + | if [ -z " | ||
| + | FEED_HOME=" | ||
| + | fi | ||
| + | |||
| + | fi | ||
| + | |||
| + | RSYNC=`command -v rsync` | ||
| + | |||
| + | # Current supported feed types (for --type parameter) | ||
| + | FEED_TYPES_SUPPORTED=" | ||
| + | |||
| + | ########## FUNCTIONS | ||
| + | ########## ========= | ||
| + | |||
| + | log_debug () { | ||
| + | $LOG_CMD -p daemon.debug " | ||
| + | } | ||
| + | |||
| + | log_info () { | ||
| + | $LOG_CMD -p daemon.info " | ||
| + | } | ||
| + | |||
| + | log_warning () { | ||
| + | $LOG_CMD -p daemon.warning " | ||
| + | } | ||
| + | |||
| + | log_err () { | ||
| + | $LOG_CMD -p daemon.err " | ||
| + | } | ||
| + | |||
| + | init_feed_type () { | ||
| + | if [ -z " | ||
| + | then | ||
| + | echo "No feed type given to --type parameter" | ||
| + | log_err "No feed type given to --type parameter" | ||
| + | exit 1 | ||
| + | elif [ " | ||
| + | then | ||
| + | [ -r " | ||
| + | |||
| + | FEED_TYPE_LONG=" | ||
| + | FEED_DIR=" | ||
| + | TIMESTAMP=" | ||
| + | SCRIPT_ID=" | ||
| + | |||
| + | if [ -z " | ||
| + | COMMUNITY_RSYNC_FEED=" | ||
| + | # An alternative syntax which might work if the above doesn' | ||
| + | # COMMUNITY_RSYNC_FEED=" | ||
| + | else | ||
| + | COMMUNITY_RSYNC_FEED=" | ||
| + | fi | ||
| + | |||
| + | GSF_RSYNC_PATH="/ | ||
| + | |||
| + | if [ -e $ACCESSKEY ]; then | ||
| + | if [ -z " | ||
| + | FEED_NAME=" | ||
| + | fi | ||
| + | else | ||
| + | if [ -z " | ||
| + | FEED_NAME=" | ||
| + | fi | ||
| + | fi | ||
| + | elif [ " | ||
| + | then | ||
| + | [ -r " | ||
| + | |||
| + | FEED_TYPE_LONG=" | ||
| + | FEED_DIR=" | ||
| + | TIMESTAMP=" | ||
| + | SCRIPT_ID=" | ||
| + | |||
| + | if [ -z " | ||
| + | COMMUNITY_RSYNC_FEED=" | ||
| + | # An alternative syntax which might work if the above doesn' | ||
| + | # COMMUNITY_RSYNC_FEED=" | ||
| + | else | ||
| + | COMMUNITY_RSYNC_FEED=" | ||
| + | fi | ||
| + | |||
| + | GSF_RSYNC_PATH="/ | ||
| + | |||
| + | if [ -e $ACCESSKEY ]; then | ||
| + | if [ -z " | ||
| + | FEED_NAME=" | ||
| + | fi | ||
| + | else | ||
| + | if [ -z " | ||
| + | FEED_NAME=" | ||
| + | fi | ||
| + | fi | ||
| + | elif [ " | ||
| + | then | ||
| + | [ -r " | ||
| + | |||
| + | FEED_TYPE_LONG=" | ||
| + | FEED_DIR=" | ||
| + | TIMESTAMP=" | ||
| + | SCRIPT_ID=" | ||
| + | |||
| + | if [ -z " | ||
| + | COMMUNITY_RSYNC_FEED=" | ||
| + | # An alternative syntax which might work if the above doesn' | ||
| + | # COMMUNITY_RSYNC_FEED=" | ||
| + | else | ||
| + | COMMUNITY_RSYNC_FEED=" | ||
| + | fi | ||
| + | |||
| + | GSF_RSYNC_PATH="/ | ||
| + | |||
| + | if [ -e $ACCESSKEY ]; then | ||
| + | if [ -z " | ||
| + | FEED_NAME=" | ||
| + | fi | ||
| + | else | ||
| + | if [ -z " | ||
| + | FEED_NAME=" | ||
| + | fi | ||
| + | fi | ||
| + | else | ||
| + | echo " | ||
| + | log_err " | ||
| + | exit 1 | ||
| + | fi | ||
| + | } | ||
| + | |||
| + | write_feed_xml () { | ||
| + | if [ -r $TIMESTAMP ] | ||
| + | then | ||
| + | FEED_VERSION=`cat $TIMESTAMP` | ||
| + | else | ||
| + | FEED_VERSION=0 | ||
| + | fi | ||
| + | |||
| + | mkdir -p $FEED_DIR | ||
| + | echo '< | ||
| + | echo "< | ||
| + | echo "< | ||
| + | echo "< | ||
| + | echo "< | ||
| + | echo "< | ||
| + | echo "< | ||
| + | echo "This script synchronizes a $FEED_TYPE collection with the ' | ||
| + | echo "The ' | ||
| + | echo " | ||
| + | echo "</ | ||
| + | echo "</ | ||
| + | } | ||
| + | |||
| + | create_tmp_key () { | ||
| + | KEYTEMPDIR=`mktemp -d` | ||
| + | cp " | ||
| + | TMPACCESSKEY=" | ||
| + | chmod 400 " | ||
| + | } | ||
| + | |||
| + | remove_tmp_key () { | ||
| + | rm -rf " | ||
| + | } | ||
| + | |||
| + | set_interrupt_trap () { | ||
| + | trap " | ||
| + | } | ||
| + | |||
| + | handle_interrupt () { | ||
| + | echo " | ||
| + | } | ||
| + | |||
| + | do_describe () { | ||
| + | echo "This script synchronizes a $FEED_TYPE collection with the ' | ||
| + | echo "The ' | ||
| + | echo " | ||
| + | } | ||
| + | |||
| + | do_feedversion () { | ||
| + | if [ -r $TIMESTAMP ]; then | ||
| + | cat $TIMESTAMP | ||
| + | fi | ||
| + | } | ||
| + | |||
| + | # This function uses gos-state-manager to get information about the settings. | ||
| + | # gos-state-manager is only available on a Greenbone OS. | ||
| + | # If gos-state-manager is missing the settings values can not be retrieved. | ||
| + | # | ||
| + | # Input: option | ||
| + | # Output: value as string or empty String if gos-state-manager is not installed | ||
| + | # or option not set | ||
| + | get_value () | ||
| + | { | ||
| + | value="" | ||
| + | key=$1 | ||
| + | if which gos-state-manager 1>/ | ||
| + | then | ||
| + | if gos-state-manager get " | ||
| + | then | ||
| + | value=" | ||
| + | fi | ||
| + | fi | ||
| + | echo " | ||
| + | } | ||
| + | |||
| + | is_feed_current () { | ||
| + | if [ -r $TIMESTAMP ] | ||
| + | then | ||
| + | FEED_VERSION=`cat $TIMESTAMP` | ||
| + | fi | ||
| + | |||
| + | if [ -z " | ||
| + | then | ||
| + | log_warning "Could not determine feed version." | ||
| + | FEED_CURRENT=0 | ||
| + | return $FEED_CURRENT | ||
| + | fi | ||
| + | |||
| + | FEED_INFO_TEMP_DIR=`mktemp -d` | ||
| + | |||
| + | if [ -e $ACCESSKEY ] | ||
| + | then | ||
| + | read feeduser < $ACCESSKEY | ||
| + | custid_at_host=`head -1 $ACCESSKEY | cut -d : -f 1` | ||
| + | |||
| + | if [ -z " | ||
| + | then | ||
| + | log_err "Could not determine credentials, | ||
| + | rm -rf " | ||
| + | exit 1 | ||
| + | fi | ||
| + | |||
| + | gsmproxy=$(get_value proxy_feed | sed -r -e ' | ||
| + | syncport=$(get_value syncport) | ||
| + | if [ " | ||
| + | then | ||
| + | PORT=" | ||
| + | fi | ||
| + | |||
| + | if [ -z " | ||
| + | then | ||
| + | RSYNC_SSH_PROXY_CMD="" | ||
| + | else | ||
| + | if [ -e $GVM_SYSCONF_DIR/ | ||
| + | RSYNC_SSH_PROXY_CMD=" | ||
| + | else | ||
| + | RSYNC_SSH_PROXY_CMD=" | ||
| + | fi | ||
| + | fi | ||
| + | create_tmp_key | ||
| + | rsync -e "ssh $RSYNC_SSH_OPTS $RSYNC_SSH_PROXY_CMD -p $PORT -i $TMPACCESSKEY" | ||
| + | if [ $? -ne 0 ] | ||
| + | then | ||
| + | log_err "rsync failed, aborting synchronization." | ||
| + | rm -rf " | ||
| + | remove_tmp_key | ||
| + | exit 1 | ||
| + | fi | ||
| + | remove_tmp_key | ||
| + | else | ||
| + | # Sleep for five seconds (a previous feed might have been synced a few seconds before) to prevent | ||
| + | # IP blocking due to network equipment in between keeping the previous connection too long open. | ||
| + | sleep 5 | ||
| + | log_notice "No Greenbone Security Feed access key found, falling back to Greenbone Community Feed" | ||
| + | eval " | ||
| + | if [ $? -ne 0 ] | ||
| + | then | ||
| + | log_err "rsync failed, aborting synchronization." | ||
| + | rm -rf " | ||
| + | exit 1 | ||
| + | fi | ||
| + | fi | ||
| + | |||
| + | FEED_VERSION_SERVER=`cat " | ||
| + | |||
| + | if [ -z " | ||
| + | then | ||
| + | log_err "Could not determine server feed version." | ||
| + | rm -rf " | ||
| + | exit 1 | ||
| + | fi | ||
| + | |||
| + | # Check against FEED_VERSION | ||
| + | if [ $FEED_VERSION -lt $FEED_VERSION_SERVER ]; then | ||
| + | FEED_CURRENT=0 | ||
| + | else | ||
| + | FEED_CURRENT=1 | ||
| + | fi | ||
| + | |||
| + | # Cleanup | ||
| + | rm -rf " | ||
| + | |||
| + | return $FEED_CURRENT | ||
| + | } | ||
| + | |||
| + | do_help () { | ||
| + | echo "$0: Sync feed data" | ||
| + | |||
| + | if [ -e $ACCESSKEY ] | ||
| + | then | ||
| + | echo "GSF access key found: Using Greenbone Security Feed" | ||
| + | else | ||
| + | echo "No GSF access key found: Using Community Feed" | ||
| + | fi | ||
| + | |||
| + | echo " --describe | ||
| + | echo " --feedversion | ||
| + | echo " --help | ||
| + | echo " --identify | ||
| + | echo " --selftest | ||
| + | echo " --type < | ||
| + | echo " --version | ||
| + | echo "" | ||
| + | exit 0 | ||
| + | } | ||
| + | |||
| + | do_rsync_community_feed () { | ||
| + | if [ -z " | ||
| + | log_err "rsync not found!" | ||
| + | else | ||
| + | # Sleep for five seconds (after is_feed_current) to prevent IP blocking due to | ||
| + | # network equipment in between keeping the previous connection too long open. | ||
| + | sleep 5 | ||
| + | log_notice "Using rsync: $RSYNC" | ||
| + | log_notice " | ||
| + | mkdir -p " | ||
| + | eval " | ||
| + | if [ $? -ne 0 ]; then | ||
| + | log_err "rsync failed. Your $FEED_TYPE_LONG might be broken now." | ||
| + | exit 1 | ||
| + | fi | ||
| + | fi | ||
| + | } | ||
| + | |||
| + | do_sync_community_feed () { | ||
| + | if [ -z " | ||
| + | log_err "rsync not found!" | ||
| + | log_err "No utility available in PATH environment variable to download Feed data" | ||
| + | exit 1 | ||
| + | else | ||
| + | log_notice "Will use rsync" | ||
| + | do_rsync_community_feed | ||
| + | fi | ||
| + | } | ||
| + | |||
| + | sync_feed_data(){ | ||
| + | if [ -e $ACCESSKEY ] | ||
| + | then | ||
| + | log_notice "Found Greenbone Security Feed subscription file, trying to synchronize with Greenbone $FEED_TYPE_LONG Repository ..." | ||
| + | notsynced=1 | ||
| + | |||
| + | mkdir -p " | ||
| + | read feeduser < $ACCESSKEY | ||
| + | custid_at_host=`head -1 $ACCESSKEY | cut -d : -f 1` | ||
| + | |||
| + | if [ -z " | ||
| + | then | ||
| + | log_err "Could not determine credentials, | ||
| + | exit 1 | ||
| + | fi | ||
| + | |||
| + | while [ 0 -ne " | ||
| + | do | ||
| + | |||
| + | gsmproxy=$(get_value proxy_feed | sed -r -e ' | ||
| + | syncport=$(get_value syncport) | ||
| + | if [ " | ||
| + | then | ||
| + | PORT=" | ||
| + | fi | ||
| + | |||
| + | if [ -z " | ||
| + | then | ||
| + | RSYNC_SSH_PROXY_CMD="" | ||
| + | else | ||
| + | if [ -e $GVM_SYSCONF_DIR/ | ||
| + | RSYNC_SSH_PROXY_CMD=" | ||
| + | else | ||
| + | RSYNC_SSH_PROXY_CMD=" | ||
| + | fi | ||
| + | fi | ||
| + | create_tmp_key | ||
| + | rsync -e "ssh $RSYNC_SSH_OPTS $RSYNC_SSH_PROXY_CMD -p $PORT -i $ACCESSKEY" | ||
| + | if [ 0 -ne " | ||
| + | log_err "rsync failed, aborting synchronization." | ||
| + | remove_tmp_key | ||
| + | exit 1 | ||
| + | fi | ||
| + | remove_tmp_key | ||
| + | notsynced=0 | ||
| + | done | ||
| + | log_notice " | ||
| + | else | ||
| + | log_notice "No Greenbone Security Feed access key found, falling back to Greenbone Community Feed" | ||
| + | do_sync_community_feed | ||
| + | fi | ||
| + | |||
| + | write_feed_xml | ||
| + | } | ||
| + | |||
| + | do_self_test () { | ||
| + | if [ -z " | ||
| + | then | ||
| + | SELFTEST_STDERR=0 | ||
| + | fi | ||
| + | |||
| + | if [ -z " | ||
| + | then | ||
| + | if [ 0 -ne $SELFTEST_STDERR ] | ||
| + | then | ||
| + | echo "rsync not found (required)." | ||
| + | fi | ||
| + | log_err "rsync not found (required)." | ||
| + | SELFTEST_FAIL=1 | ||
| + | fi | ||
| + | } | ||
| + | |||
| + | |||
| + | ########## START | ||
| + | ########## ===== | ||
| + | |||
| + | while test $# -gt 0; do | ||
| + | case " | ||
| + | " | ||
| + | if [ -z " | ||
| + | ACTION=" | ||
| + | fi | ||
| + | ;; | ||
| + | " | ||
| + | do_help | ||
| + | exit 0 | ||
| + | ;; | ||
| + | " | ||
| + | FEED_TYPE=$(echo " | ||
| + | shift | ||
| + | ;; | ||
| + | esac | ||
| + | shift | ||
| + | done | ||
| + | |||
| + | init_feed_type | ||
| + | |||
| + | write_feed_xml | ||
| + | |||
| + | case " | ||
| + | --version) | ||
| + | echo $VERSION | ||
| + | exit 0 | ||
| + | ;; | ||
| + | --identify) | ||
| + | echo " | ||
| + | exit 0 | ||
| + | ;; | ||
| + | --describe) | ||
| + | do_describe | ||
| + | exit 0 | ||
| + | ;; | ||
| + | --feedversion) | ||
| + | do_feedversion | ||
| + | exit 0 | ||
| + | ;; | ||
| + | --selftest) | ||
| + | SELFTEST_FAIL=0 | ||
| + | SELFTEST_STDERR=1 | ||
| + | do_self_test | ||
| + | exit $SELFTEST_FAIL | ||
| + | ;; | ||
| + | --feedcurrent) | ||
| + | is_feed_current | ||
| + | exit $? | ||
| + | ;; | ||
| + | esac | ||
| + | |||
| + | SELFTEST_FAIL=0 | ||
| + | do_self_test | ||
| + | if [ $SELFTEST_FAIL -ne 0 ] | ||
| + | then | ||
| + | exit 1 | ||
| + | fi | ||
| + | |||
| + | is_feed_current | ||
| + | if [ $FEED_CURRENT -eq 1 ] | ||
| + | then | ||
| + | log_notice "Feed is already current, skipping synchronization." | ||
| + | exit 0 | ||
| + | fi | ||
| + | ( | ||
| + | chmod +660 $LOCK_FILE | ||
| + | flock -n 9 | ||
| + | if [ $? -eq 1 ]; then | ||
| + | log_notice "Sync in progress, exiting." | ||
| + | exit 1 | ||
| + | fi | ||
| + | date > $LOCK_FILE | ||
| + | sync_feed_data | ||
| + | echo -n > $LOCK_FILE | ||
| + | ) 9>> | ||
| + | |||
| + | exit 0 | ||
| + | </ | ||
| + | |||
| + | Rendez le script exécutable : | ||
| + | |||
| + | < | ||
| + | [root@centos7 ~]# chmod +x greenbone-feed-sync | ||
| + | </ | ||
| + | |||
| + | Déplacez le script vers **/ | ||
| + | |||
| + | < | ||
| + | [root@centos7 ~]# mv greenbone-feed-sync / | ||
| + | </ | ||
| + | |||
| + | Devenez l' | ||
| + | |||
| + | < | ||
| + | [root@centos7 ~]# su - trainee | ||
| + | Last login: Fri Mar 5 07:35:08 UTC 2021 on pts/0 | ||
| + | [trainee@centos7 ~]$ greenbone-feed-sync --type SCAP | ||
| + | ... | ||
| + | [root@centos7 ~]# exit | ||
| </ | </ | ||
| Ligne 1906: | Ligne 3229: | ||
| Puis saisissez les requêtes et commandes suivantes : | Puis saisissez les requêtes et commandes suivantes : | ||
| + | |||
| + | < | ||
| + | CREATE DATABASE auth; | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | USE auth; | ||
| + | </ | ||
| + | |||
| < | < | ||
| Ligne 1921: | Ligne 3253: | ||
| IDENTIFIED BY ' | IDENTIFIED BY ' | ||
| </ | </ | ||
| + | |||
| + | Vous obtiendrez : | ||
| < | < | ||
| Ligne 3012: | Ligne 4346: | ||
| ----- | ----- | ||
| - | < | + | Copyright © 2024 Hugh Norris. |
| - | <div align=" | + | |
| - | Copyright © Hugh Norris.< | + | |
| - | </ | + | |
| - | </ | + | |