You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

100 lines
3.5 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#!/usr/bin/env bash
DESC="Tests"
SYSTEMS="distributeur client comanche castafiore appolo passerelle darkside brightside"
testConfigBase() {
tput reset
echo "[Test de la configuration de base]"
echo
echo "Tout doit être vert (après configAll) !"
echo
vdnTest "Serveur web sur brightside ... ?" 'vdn-ssh root@brightside "timeout 1 lynx -dump localhost &> /dev/null"'
vdnTest "Serveur web sur darkside ..... ?" 'vdn-ssh root@darkside "timeout 1 lynx -dump localhost &> /dev/null"'
vdnTest "Serveur web sur castafiore ... ?" 'vdn-ssh root@castafiore "timeout 1 lynx -dump localhost &> /dev/null"'
vdnTest "Serveur web sur comanche ..... ?" 'vdn-ssh root@comanche "timeout 1 lynx -dump localhost &> /dev/null"'
echo
vdnTest "Config distributeur .......... ?" 'vdn-ssh root@distributeur "systemctl status isc-dhcp-server.service &> /dev/null"'
vdnTest "Config passerelle ............ ?" 'vdn-ssh root@passerelle "timeout 1 cat /proc/sys/net/ipv4/ip_forward | grep -q 1"'
echoDone
}
testQ1() {
tput reset
echo "[Q1 : Pas daccès Internet (réseau local)]"
echo
vdnTest "client -> brightside ......... ?" 'vdn-ssh root@client "timeout 1 lynx -dump brightside 2> /dev/null | grep -q brightside"'
vdnTest "distributeur -> brightside .. ?" 'vdn-ssh root@distributeur "timeout 1 lynx -dump brightside 2> /dev/null | grep -q brightside"'
vdnTest "comanche -> brightside ....... ?" 'vdn-ssh root@comanche "timeout 1 lynx -dump brightside 2> /dev/null | grep -q brightside"'
echoDone
}
testQ2() {
tput reset
echo "[Q2 : appolo est aveugle]"
echo
vdnTest "appolo -> brightside ... ?" 'vdn-ssh root@appolo "timeout 1 lynx -dump brightside 2> /dev/null | grep -q brightside"'
echoDone
}
testQ3() {
tput reset
echo "[Q3 : Administration du serveur Web]"
echo
vdnTest "client -> castafiore ... ?" 'vdn-ssh root@client "nmap -p 22 castafiore 2>&1 | grep -q open"'
echoDone
}
testQ4() {
tput reset
echo "[Q4 : Serveur Web visible de lextérieur]"
echo
vdnTest "brightside -> castafiore ... ?" \
'vdn-ssh root@brightside "timeout 1 lynx -dump passerelle 2> /dev/null | grep -q castafiore"'
echoDone
}
testQ5() {
tput reset
echo "[Q5 : Défaut non direct et complexe]"
echo
vdnTest "client -> comanche ... ?" \
'vdn-ssh root@client "timeout 1 lynx -dump comanche 2> /dev/null | grep -q comanche"'
echoDone
}
testQ6() {
tput reset
echo "[Q6 : Trouvez le pirate]"
echo
vdnTest "blocage du pirate ... ?" \
'vdn-ssh root@client "timeout 1 nmap -p 22 darkside 2>1 | grep --line-buffered -q open && exit 1 || exit 0"'
echoDone
}
testQ7() {
tput reset
echo "[Q7 : La DMZ nest pas étanche]"
echo
vdnTest "Flux DMZ vers intranet bloqués .. ?" \
'vdn-ssh root@castafiore "timeout 1 nmap -p 22 client 2>1 | grep --line-buffered -q open && exit 1 || exit 0"'
echoDone
}
run() {
requireGuests $SYSTEMS
if ! echo ${BASH_ARGV[0]} | grep -q -i fast; then
echo "Cette temporisation pour vous décourager d'utiliser ce test comme debogueur !"
for i in $(seq 10 -1 0); do echo $i; sleep 1; done
fi
vdnExec testConfigBase testQ1 testQ2 testQ3 testQ4 testQ5 testQ6 testQ7
}