Compare commits

...

10 Commits

Author SHA1 Message Date
d1d177dd38 Ajout des fichiers Python de la séance du matin, le 3 Octobre 2024-10-03 11:32:14 +02:00
727d25a1af Merge branch 'main' into test 2024-10-03 10:25:22 +02:00
efddb08c77 nouveau fichier : bts_annee_2/cyber2/wordpress-lamp/README.md
nouveau fichier : bts_annee_2/cyber2/wordpress-lamp/compte-rendu-2024-09-30
	nouveau fichier : bts_annee_2/cyber2/wordpress-lamp/compterendudistant.sh
	nouveau fichier : bts_annee_2/cyber2/wordpress-lamp/ferm.conf
	nouveau fichier : bts_annee_2/cyber2/wordpress-lamp/goss.yaml
	renommé :         bts_annee_2/sisr2/seance_03/README.md -> bts_annee_2/sisr2/heartbeat_repa_charge/README.md
	renommé :         bts_annee_2/sisr2/seance_03/hb1/inst-hb1.sh -> bts_annee_2/sisr2/heartbeat_repa_charge/hb1/inst-hb1.sh
	renommé :         bts_annee_2/sisr2/seance_03/hb2/inst-hb2.sh -> bts_annee_2/sisr2/heartbeat_repa_charge/hb2/inst-hb2.sh
	renommé :         bts_annee_2/sisr2/seance_03/vagrant/Vagrantfile_bookworm -> bts_annee_2/sisr2/heartbeat_repa_charge/vagrant/Vagrantfile_bookworm
	renommé :         bts_annee_2/sisr2/seance_03/vagrant/Vagrantfile_rsync -> bts_annee_2/sisr2/heartbeat_repa_charge/vagrant/Vagrantfile_rsync
	renommé :         bts_annee_2/sisr2/seance_04/README.md -> bts_annee_2/sisr2/lvs_haproxy/README.md
	renommé :         bts_annee_2/sisr2/seance_04/lvs/haproxy.cfg -> bts_annee_2/sisr2/lvs_haproxy/lvs/haproxy.cfg
	renommé :         bts_annee_2/sisr2/seance_04/lvs/ipvs.sh -> bts_annee_2/sisr2/lvs_haproxy/lvs/ipvs.sh
2024-10-03 10:22:26 +02:00
bcbd0ae9ef Merge pull request 'Suppression de la syntaxe Markdown.' (#31) from test into main
Reviewed-on: #31
2024-09-16 17:50:06 +02:00
7d2f5d2074 Merge branch 'main' into test 2024-09-16 17:49:58 +02:00
b89b138cc5 Merge branch 'test' of https://gitea.lyc-lecastel.fr/guillaume.emorine/siotp into test 2024-09-16 17:48:42 +02:00
8d32373041 Sppression de la syntaxe markdown. 2024-09-16 17:47:54 +02:00
0adc0b54ed Merge pull request 'Ajout de syntaxe markdown.' (#30) from test into main
Reviewed-on: #30
2024-09-16 17:47:38 +02:00
599dd574f6 Merge branch 'main' into test 2024-09-16 17:47:29 +02:00
1d61707ccd Merge pull request 'Ajout des fichiers demandés par le professeur.' (#29) from test into main
Reviewed-on: #29
2024-09-16 17:35:03 +02:00
20 changed files with 319 additions and 1 deletions

View File

@ -1,4 +1,4 @@
# Dépôt de fichiers personnels provenant de machines virtuelles utilisées en TP.
Dépôt de fichiers personnels provenant de machines virtuelles utilisées en TP.
Ce Gitea contient aussi un script d'automatisation du processus de push et de pull, adaptés aux deux branches.

View File

@ -0,0 +1 @@
Dossier avec les fichiers de configuration du pare-feu, le fichier de test goss et le script de récupération des informations sur le serveur Web Wordpress.

View File

@ -0,0 +1,100 @@
# Scan des ports ouverts visibles depuis le poste physique
lun. 30 sept. 2024 16:45:55 CEST
Starting Nmap 7.93 ( https://nmap.org ) at 2024-09-30 16:45 CEST
Nmap scan report for 172.16.0.152
Host is up (0.00069s latency).
Not shown: 997 filtered tcp ports (no-response)
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 9.2p1 Debian 2+deb12u3 (protocol 2.0)
| ssh-hostkey:
| 256 507a12ddb833cec5b87c576702e1682a (ECDSA)
|_ 256 c3bbd552f31fbd2d9fdd9e11ca521cbc (ED25519)
80/tcp open http Apache httpd 2.4.62 ((Debian))
|_http-title: Did not follow redirect to https://172.16.0.152/
|_http-server-header: Apache/2.4.62 (Debian)
443/tcp open ssl/http Apache httpd 2.4.62 ((Debian))
|_http-server-header: Apache/2.4.62 (Debian)
| tls-alpn:
|_ http/1.1
|_http-title: Apache2 Debian Default Page: It works
| ssl-cert: Subject: commonName=wordpress-ge/organizationName=Lyc\xC3\x83\xC2\xA9e Le Castel/stateOrProvinceName=Bourgogne/countryName=FR
| Not valid before: 2024-09-26T13:11:27
|_Not valid after: 2025-09-26T13:11:27
|_ssl-date: TLS randomness does not represent time
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 23.30 seconds
# Affichage des règles du pare-feu
# Generated by iptables-save v1.8.9 on Mon Sep 30 16:46:17 2024
*filter
:INPUT DROP [30889:1853067]
:FORWARD DROP [0:0]
:OUTPUT ACCEPT [142:9272]
-A INPUT -m state --state INVALID -j DROP
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -p tcp -m tcp --dport 22 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 443 -j ACCEPT
-A FORWARD -m state --state INVALID -j DROP
-A FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT
-A OUTPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
COMMIT
# Completed on Mon Sep 30 16:46:17 2024
# Scan des ports UDP ouverts sur le serveur Web
State Recv-Q Send-Q Local Address:Port Peer Address:PortProcess
UNCONN 0 0 127.0.0.54:53 0.0.0.0:* users:(("systemd-resolve",pid=267,fd=19))
UNCONN 0 0 127.0.0.53%lo:53 0.0.0.0:* users:(("systemd-resolve",pid=267,fd=17))
UNCONN 0 0 0.0.0.0:5355 0.0.0.0:* users:(("systemd-resolve",pid=267,fd=11))
# Scan des ports TCP ouverts sur le serveur Web
State Recv-Q Send-Q Local Address:Port Peer Address:PortProcess
LISTEN 0 4096 0.0.0.0:5355 0.0.0.0:* users:(("systemd-resolve",pid=267,fd=12))
LISTEN 0 128 0.0.0.0:22 0.0.0.0:* users:(("sshd",pid=404,fd=3))
LISTEN 0 100 0.0.0.0:25 0.0.0.0:* users:(("master",pid=778,fd=13))
LISTEN 0 4096 127.0.0.54:53 0.0.0.0:* users:(("systemd-resolve",pid=267,fd=20))
LISTEN 0 80 127.0.0.1:3306 0.0.0.0:* users:(("mariadbd",pid=462,fd=20))
LISTEN 0 4096 127.0.0.53%lo:53 0.0.0.0:* users:(("systemd-resolve",pid=267,fd=18))
# Résultats des tests Goss
1..31
ok 1 - Package: apache2: installed: matches expectation: true
ok 2 - Package: apache2: version: matches expectation: ["2.4.62-1~deb12u1"]
ok 3 - Package: mariadb-server: installed: matches expectation: true
ok 4 - Package: mariadb-server: version: matches expectation: ["1:10.11.6-0+deb12u1"]
ok 5 - Process: apache2: running: matches expectation: true
ok 6 - Service: sshd: enabled: matches expectation: true
ok 7 - Service: sshd: running: matches expectation: true
ok 8 - Process: sshd: running: matches expectation: true
ok 9 - Port: tcp:22: listening: matches expectation: true
ok 10 - Port: tcp:22: ip: matches expectation: ["0.0.0.0"]
ok 11 - Port: tcp6:22: listening: matches expectation: true
ok 12 - Port: tcp6:22: ip: matches expectation: ["::"]
ok 13 - User: sshd: exists: matches expectation: true
ok 14 - User: sshd: uid: matches expectation: 103
ok 15 - User: sshd: gid: matches expectation: 65534
ok 16 - User: sshd: home: matches expectation: "/run/sshd"
ok 17 - User: sshd: groups: matches expectation: ["nogroup"]
ok 18 - User: sshd: shell: matches expectation: "/usr/sbin/nologin"
ok 19 - Port: tcp6:80: listening: matches expectation: true
ok 20 - Port: tcp6:80: ip: matches expectation: ["::"]
ok 21 - Interface: eth0: exists: matches expectation: true
ok 22 - Interface: eth0: addrs: matches expectation: ["172.16.0.152/24","fe80::be24:11ff:fe76:ac6f/64"]
ok 23 - Interface: eth0: mtu: matches expectation: 1500
ok 24 - Port: tcp6:443: listening: matches expectation: true
ok 25 - Port: tcp6:443: ip: matches expectation: ["::"]
ok 26 - Service: ssh: enabled: matches expectation: true
ok 27 - Service: ssh: running: matches expectation: true
ok 28 - Service: apache2: enabled: matches expectation: true
ok 29 - Service: apache2: running: matches expectation: true
ok 30 - HTTP: http://172.16.0.152/wordpress: status: matches expectation: 200
ok 31 - HTTP: http://172.16.0.152/wordpress: Body: matches expectation: ["engagement"]

View File

@ -0,0 +1,13 @@
#!/bin/bash
DATE=$(date -I)
echo "Scan nmap et comptes-rendus en cours de création, veuillez patienter..."
echo -ne "# Scan des ports ouverts visibles depuis le poste physique\n\n" > compte-rendu-$DATE
(date ; nmap -A 172.16.0.152 ) >> compte-rendu-$DATE
echo -ne "\n# Affichage des règles du pare-feu\n\n" >> compte-rendu-$DATE
ssh debian@172.16.0.152 "sudo iptables-legacy-save" >> compte-rendu-$DATE
echo -ne "\n# Scan des ports UDP ouverts sur le serveur Web\n\n" >> compte-rendu-$DATE
ssh debian@172.16.0.152 "sudo ss -lnu4p" >> compte-rendu-$DATE
echo -ne "\n# Scan des ports TCP ouverts sur le serveur Web\n\n" >> compte-rendu-$DATE
ssh debian@172.16.0.152 "sudo ss -lnt4p" >> compte-rendu-$DATE
echo -ne "\n# Résultats des tests Goss\n\n" >> compte-rendu-$DATE
ssh debian@172.16.0.152 "sudo goss v -f tap" >> compte-rendu-$DATE

View File

@ -0,0 +1,43 @@
# -*- shell-script -*-
#
# Configuration file for ferm(1).
#
domain (ip) {
table filter {
chain INPUT {
policy DROP;
# connection tracking
mod state state INVALID DROP;
mod state state (ESTABLISHED RELATED) ACCEPT;
# allow local packet
interface lo ACCEPT;
# respond to ping
proto icmp ACCEPT;
# allow SSH connections
proto tcp dport ssh ACCEPT;
# autorise les connexions HTTP et HTTPS
proto tcp dport (http https) ACCEPT;
}
chain OUTPUT {
policy ACCEPT;
# connection tracking
#mod state state INVALID DROP;
mod state state (ESTABLISHED RELATED) ACCEPT;
}
chain FORWARD {
policy DROP;
# connection tracking
mod state state INVALID DROP;
mod state state (ESTABLISHED RELATED) ACCEPT;
}
}
}
@include ferm.d/;

View File

@ -0,0 +1,73 @@
package:
apache2:
installed: true
versions:
- 2.4.62-1~deb12u1
mariadb-server:
installed: true
versions:
- 1:10.11.6-0+deb12u1
port:
tcp:22:
listening: true
ip:
- 0.0.0.0
tcp6:22:
listening: true
ip:
- '::'
tcp6:80:
listening: true
ip:
- '::'
tcp6:443:
listening: true
ip:
- '::'
service:
apache2:
enabled: true
running: true
ssh:
enabled: true
running: true
sshd:
enabled: true
running: true
user:
sshd:
exists: true
uid: 103
gid: 65534
groups:
- nogroup
home: /run/sshd
shell: /usr/sbin/nologin
process:
apache2:
running: true
sshd:
running: true
interface:
eth0:
exists: true
addrs:
- 172.16.0.152/24
- fe80::be24:11ff:fe76:ac6f/64
mtu: 1500
http:
http://172.16.0.152/wordpress:
status: 200
allow-insecure: true
no-follow-redirects: false
timeout: 5000
body:
- engagement
https:
https://172.16.0.152/wordpress:
status: 200
allow-insecure: true
no-follow-redirects: false
timeout: 5000
body:
- engagement

View File

@ -0,0 +1,2 @@
Dépôt des fichiers Python faits lors de la séance du 3 Octobre, le matin.
Le fichier users.txt est celui utilisé pour la création des comptes, pour l'exercice 4.

View File

@ -0,0 +1,26 @@
#!/usr/bin/python3
import os
import sys
def create_user(login, full_name):
try:
os.system(f'sudo useradd -m -c "{full_name}" {login}')
print(f"Utilisateur {login} créé avec succès.")
except Exception as e:
print(f"Erreur lors de la création de l'utilisateur {login}: {e}")
def main(filename):
try:
with open(filename, 'r') as file:
for line in file:
line = line.strip()
if line:
login, full_name = line.split(':')
create_user(login.strip(), full_name.strip())
except FileNotFoundError:
print(f"Le fichier {filename} n'a pas été trouvé.")
except Exception as e:
print(f"Erreur lors de la lecture du fichier {filename}: {e}")
if __name__ == "__main__":
if len(sys.argv) != 2:
print("Usage: python creatusr.py <nom_du_fichier>")
else:
main(sys.argv[1])

View File

@ -0,0 +1,18 @@
#!/usr/bin/python3
# Demander à l'utilisateur de saisir une phrase
phrase = input("Entrez une phrase : ")
# Convertir la phrase en liste de mots
mots = phrase.split()
# Crée un dictionnaire pour stocker les occurrences des mots
occurrences = {}
# Compter les occurrences de chaque mot
for mot in mots:
if mot in occurrences:
occurrences[mot] += 1
else:
occurrences[mot] = 1
# Afficher les mots et leurs occurrences
print("Occurrences des mots :")
for mot, count in occurrences.items():
print(f"{mot} : {count}"

View File

@ -0,0 +1,6 @@
#!/usr/bin/python3
# Récupération de la valeur du rayon
rayon=int(input("Quel est le rayon du cercle ? "))
# Calcul et affichage
perim=(2*3.141592*rayon)
print("Le périmètre vaut:",perim)

View File

@ -0,0 +1,31 @@
#!/usr/bin/python3
# Les variables:
tableau=[]
i=0
avg=0
# Boucle while pour l'input et le remplissage du tableau
while i < 4:
x=int(input("Entrez un chiffre : "))
tableau.append(x)
x=0
i=i+1
# Fin de la boucle while, déclaration de variables pour la suite
mini=tableau[0]
maxi=tableau[0]
# Boucle for pour obtenir les valeurs minimales et maximales
for y in range (i):
if tableau[y] > maxi:
maxi=tableau[y]
if tableau[y] < mini:
mini=tableau[y]
avg=avg+tableau[y]
# Affichage de chaque élément du tableau
print(tableau[y])
# Calcul de la moyenne
avg=avg/i
# Affichage final
print("La plus grande valeur du tableau est: ",maxi)
print("La plus petite valeur du tableau est: ",mini)
print("La moyenne du tableau final est: ",avg)
# On aurait pu faire ça 100x plus vite, mais faut se compliquer la vie.

View File

@ -0,0 +1,5 @@
adupont:Albert Dupont
jduroy:Jeannette Duroy
gemorine:Guillaume Emorine
jpauchet:Jarod Pauchet
ngenret:Nathan Genret