From d619de090c2c38b0bd21fb7d9ea1750c82f8e71b Mon Sep 17 00:00:00 2001 From: root Date: Fri, 29 Sep 2023 08:38:24 +0200 Subject: [PATCH 1/5] fichier config SNMP --- sio2/SISR/SNMP/snmp.conf | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 sio2/SISR/SNMP/snmp.conf diff --git a/sio2/SISR/SNMP/snmp.conf b/sio2/SISR/SNMP/snmp.conf new file mode 100644 index 0000000..22fa775 --- /dev/null +++ b/sio2/SISR/SNMP/snmp.conf @@ -0,0 +1,10 @@ +# As the snmp packages come without MIB files due to license reasons, loading +# of MIBs is disabled by default. If you added the MIBs you can reenable +# loading them by commenting out the following line. +mibs : + +# If you want to globally change where snmp libraries, commands and daemons +# look for MIBS, change the line below. Note you can set this for individual +# tools with the -M option or MIBDIRS environment variable. +# +# mibdirs /usr/share/snmp/mibs:/usr/share/snmp/mibs/iana:/usr/share/snmp/mibs/ietf From 5d16f39587a68b65fc3c31fff37f25d1939edd3c Mon Sep 17 00:00:00 2001 From: root Date: Fri, 29 Sep 2023 08:43:17 +0200 Subject: [PATCH 2/5] script snmpd.conf --- sio2/SISR/SNMP/snmp.conf | 10 ----- sio2/SISR/SNMP/snmpd.conf | 90 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 90 insertions(+), 10 deletions(-) delete mode 100644 sio2/SISR/SNMP/snmp.conf create mode 100644 sio2/SISR/SNMP/snmpd.conf diff --git a/sio2/SISR/SNMP/snmp.conf b/sio2/SISR/SNMP/snmp.conf deleted file mode 100644 index 22fa775..0000000 --- a/sio2/SISR/SNMP/snmp.conf +++ /dev/null @@ -1,10 +0,0 @@ -# As the snmp packages come without MIB files due to license reasons, loading -# of MIBs is disabled by default. If you added the MIBs you can reenable -# loading them by commenting out the following line. -mibs : - -# If you want to globally change where snmp libraries, commands and daemons -# look for MIBS, change the line below. Note you can set this for individual -# tools with the -M option or MIBDIRS environment variable. -# -# mibdirs /usr/share/snmp/mibs:/usr/share/snmp/mibs/iana:/usr/share/snmp/mibs/ietf diff --git a/sio2/SISR/SNMP/snmpd.conf b/sio2/SISR/SNMP/snmpd.conf new file mode 100644 index 0000000..e8b9085 --- /dev/null +++ b/sio2/SISR/SNMP/snmpd.conf @@ -0,0 +1,90 @@ +########################################################################### +# +# snmpd.conf +# An example configuration file for configuring the Net-SNMP agent ('snmpd') +# See snmpd.conf(5) man page for details +# +########################################################################### +# SECTION: System Information Setup +# + +# syslocation: The [typically physical] location of the system. +# Note that setting this value here means that when trying to +# perform an snmp SET operation to the sysLocation.0 variable will make +# the agent return the "notWritable" error code. IE, including +# this token in the snmpd.conf file will disable write access to +# the variable. +# arguments: location_string +sysLocation Sitting on the Dock of the Bay +sysContact Me + +# sysservices: The proper value for the sysServices object. +# arguments: sysservices_number +sysServices 72 + + + +########################################################################### +# SECTION: Agent Operating Mode +# +# This section defines how the agent will operate when it +# is running. + +# master: Should the agent operate as a master agent or not. +# Currently, the only supported master agent type for this token +# is "agentx". +# +# arguments: (on|yes|agentx|all|off|no) + +master agentx + +# agentaddress: The IP address and port number that the agent will listen on. +# By default the agent listens to any and all traffic from any +# interface on the default SNMP port (161). This allows you to +# specify which address, interface, transport type and port(s) that you +# want the agent to listen on. Multiple definitions of this token +# are concatenated together (using ':'s). +# arguments: [transport:]port[@interface/address],... + +#agentaddress 127.0.0.1,[::1] +agentAddress udp:161 + + + +########################################################################### +# SECTION: Access Control Setup +# +# This section defines who is allowed to talk to your running +# snmp agent. + +# Views +# arguments viewname included [oid] + +# system + hrSystem groups only +view systemonly included .1.3.6.1.2.1.1 +view systemonly included .1.3.6.1.2.1.25.1 + + +# rocommunity: a SNMPv1/SNMPv2c read-only access community name +# arguments: community [default|hostname|network/bits] [oid | -V view] + +# Read-only access to everyone to the systemonly view +rocommunity public default +rocommunity6 public default -V systemonly + +# SNMPv3 doesn't use communities, but users with (optionally) an +# authentication and encryption string. This user needs to be created +# with what they can view with rouser/rwuser lines in this file. +# +# createUser username (MD5|SHA|SHA-512|SHA-384|SHA-256|SHA-224) authpassphrase [DES|AES] [privpassphrase] +# e.g. +# createuser authPrivUser SHA-512 myauthphrase AES myprivphrase +# +# This should be put into /var/lib/snmp/snmpd.conf +# +# rouser: a SNMPv3 read-only access username +# arguments: username [noauth|auth|priv [OID | -V VIEW [CONTEXT]]] +rouser authPrivUser authpriv -V systemonly + +# include a all *.conf files in a directory +includeDir /etc/snmp/snmpd.conf.d From 7731dae2bb8f15fdbf229c1078d8739f7c73f533 Mon Sep 17 00:00:00 2001 From: "alhassane.kone" Date: Sun, 1 Oct 2023 19:47:22 +0200 Subject: [PATCH 3/5] Supprimer sio2/SISR/Nagios/test --- sio2/SISR/Nagios/test | 1 - 1 file changed, 1 deletion(-) delete mode 100644 sio2/SISR/Nagios/test diff --git a/sio2/SISR/Nagios/test b/sio2/SISR/Nagios/test deleted file mode 100644 index d86bac9..0000000 --- a/sio2/SISR/Nagios/test +++ /dev/null @@ -1 +0,0 @@ -OK From ce7de1abb00bb9bfae54d4ca0bac9f467555fa77 Mon Sep 17 00:00:00 2001 From: root Date: Sun, 1 Oct 2023 20:05:20 +0200 Subject: [PATCH 4/5] ajout fichier conf postfix --- sio2/CYBER/postfix/main.cf | 58 ++++++++++++++++++++++++++++++++++ sio2/CYBER/postfix/sasl_passwd | 1 + 2 files changed, 59 insertions(+) create mode 100644 sio2/CYBER/postfix/main.cf create mode 100644 sio2/CYBER/postfix/sasl_passwd diff --git a/sio2/CYBER/postfix/main.cf b/sio2/CYBER/postfix/main.cf new file mode 100644 index 0000000..149d13c --- /dev/null +++ b/sio2/CYBER/postfix/main.cf @@ -0,0 +1,58 @@ +# See /usr/share/postfix/main.cf.dist for a commented, more complete version + + +# Debian specific: Specifying a file name will cause the first +# line of that file to be used as the name. The Debian default +# is /etc/mailname. +#myorigin = /etc/mailname + +smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU) +biff = no + +# appending .domain is the MUA's job. +append_dot_mydomain = no + +# Uncomment the next line to generate "delayed mail" warnings +#delay_warning_time = 4h + +readme_directory = no + +# See http://www.postfix.org/COMPATIBILITY_README.html -- default to 3.6 on +# fresh installs. +compatibility_level = 3.6 + + + +# TLS parameters +smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem +smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key +smtpd_tls_security_level=may + +smtp_tls_CApath=/etc/ssl/certs +smtp_tls_security_level=may +smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache + + +smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination +myhostname = bookworm +alias_maps = hash:/etc/aliases +alias_database = hash:/etc/aliases +myorigin = /etc/mailname +mydestination = $myhostname, postfix.lan, bookworm, localhost.localdomain, localhost +relayhost = [smtp.gmail.com]:587 +mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 +mailbox_size_limit = 0 +recipient_delimiter = + +inet_interfaces = all +inet_protocols = all + +# Enable SASL authentication +smtp_sasl_auth_enable = yes +# Disallow methods that allow anonymous authentication +smtp_sasl_security_options = noanonymous +# Location of sasl_passwd +smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd +# Enable STARTTLS encryption +#smtp_tls_security_level = encrypt +# Location of CA certificates +smtp_tls_CAfile = /etc/postfix/ssl/cacert-smtp-gmail.pem diff --git a/sio2/CYBER/postfix/sasl_passwd b/sio2/CYBER/postfix/sasl_passwd new file mode 100644 index 0000000..129cb66 --- /dev/null +++ b/sio2/CYBER/postfix/sasl_passwd @@ -0,0 +1 @@ +[smtp.gmail.com]:587 akone.alhassane@gmail.com:clnbmfdicvcbvcvt From 8b71aef87b4b047ed08272699d1eaa9f6cf72c26 Mon Sep 17 00:00:00 2001 From: Votre Nom Date: Mon, 9 Oct 2023 17:11:49 +0200 Subject: [PATCH 5/5] TP python --- sio2/SISR/Python/analog | 27 +++++++++++++++++++++++++++ sio2/SISR/Python/creatusr | 19 +++++++++++++++++++ sio2/SISR/Python/remplace | 27 +++++++++++++++++++++++++++ 3 files changed, 73 insertions(+) create mode 100755 sio2/SISR/Python/analog create mode 100755 sio2/SISR/Python/creatusr create mode 100755 sio2/SISR/Python/remplace diff --git a/sio2/SISR/Python/analog b/sio2/SISR/Python/analog new file mode 100755 index 0000000..8080db6 --- /dev/null +++ b/sio2/SISR/Python/analog @@ -0,0 +1,27 @@ +#!/usr/bin/python3 +import sys +import re +#tab = [] +volume = {} + +regexp = "^(\S+) (\S+) (\S+) \[([^]]+)\] \"(\w+) (\S+).*\" (\d+) (\S+)" +for line in sys.stdin: # on lit sur l’entrée standard + line = line.rstrip () # on enleve le retour ligne + res = re.match (regexp, line) + if res: + (host, rfc931, user, date, request, url, status, byte) = res.groups() + host = res.group (1) + byte =int(res.group (8)) + if host in volume: + volume[host]= volume[host] + byte + else: + volume[host] = byte + +for host in volume.keys(): + print(host, ":", volume[host]) + + + + + + diff --git a/sio2/SISR/Python/creatusr b/sio2/SISR/Python/creatusr new file mode 100755 index 0000000..a2ecc08 --- /dev/null +++ b/sio2/SISR/Python/creatusr @@ -0,0 +1,19 @@ +#!/usr/bin/python3 + +try: + fh = open("user.txt", "r") +except: + print ("Fichier user.txt inconnu") +else: + line = fh.readline () + while line: + # use realine() to read next line + maligne = line.rstrip() + (login,complet)=maligne.split(":") + print(login , complet) + cmd = "useradd -m -c \""+ complet + "\" " + login + "-s /bin/bash/ "+login + print (cmd) + line = fh.readline() + + fh.close() + diff --git a/sio2/SISR/Python/remplace b/sio2/SISR/Python/remplace new file mode 100755 index 0000000..086fd9e --- /dev/null +++ b/sio2/SISR/Python/remplace @@ -0,0 +1,27 @@ +import re +import os + +def remplacer_avec_regex(nom_fichier, ancien_motif, nouveau_motif): + # Renommer le fichier d'origine + nouveau_nom = nom_fichier + ".old" + os.rename(nom_fichier, nouveau_nom) + + # Lire le contenu du fichier original + with open(nouveau_nom, 'r') as fichier_in: + contenu = fichier_in.read() + + # Utiliser une expression régulière pour effectuer le remplacement + contenu_modifie = re.sub(ancien_motif, nouveau_motif, contenu) + + # Écrire le contenu modifié dans le fichier d'origine + with open(nom_fichier, 'w') as fichier_out: + fichier_out.write(contenu_modifie) + +# Demander à l'utilisateur les informations nécessaires +nom_fichier = input("Entrez le nom du fichier : ") +ancien_motif = input("Entrez l'ancien motif à remplacer (expression régulière) : ") +nouveau_motif = input("Entrez le nouveau motif : ") + +# Appeler la fonction +remplacer_avec_regex(nom_fichier, ancien_motif, nouveau_motif) +