« Atelier SysRes SE4 2025/2026 E5 » : différence entre les versions

De wiki-se.plil.fr
Aller à la navigation Aller à la recherche
(j'ai fais le rapport)
 
 
(49 versions intermédiaires par un autre utilisateur non affichées)
Ligne 4 : Ligne 4 :
ssh root@capbreton
ssh root@capbreton


Mot de passe : g0llum_fr0d0
Mot de passe :


==== Etape 2 : Créer un fichier dans le répertoire /etc/network/interfaces.d du Dom0 aux noms du binôme concerné ====
==== Etape 2 : Créer un fichier dans le répertoire /etc/network/interfaces.d du Dom0 aux noms du binôme concerné ====
Ligne 34 : Ligne 34 :
===== Nos résultats : =====
===== Nos résultats : =====
CachyOS : <syntaxhighlight lang="shell">
CachyOS : <syntaxhighlight lang="shell">
Installation Summary
Installation Summary
---------------------
---------------------
Hostname        :  SE4.CachyOS
Hostname        :  SE4.CachyOS
Ligne 40 : Ligne 40 :
MAC Address    :  00:16:3E:8B:45:EC
MAC Address    :  00:16:3E:8B:45:EC
IP Address(es)  :  dynamic
IP Address(es)  :  dynamic
SSH Fingerprint :  SHA256:B0Jej6oBYnqo6BNAkuT73+1FRTAu7w+ynwLcL9MUw84 (DSA)
SSH Fingerprint :  SHA256:p+nECGSXOPvFjDjk+/x8adAn8JxTTPjuknCTcFZxJNk (DSA)
SSH Fingerprint :  SHA256:Ko3kxxNtx498I5wyPFzNF2StKYL4tOvV0vHbRyggX6g (ECDSA)
SSH Fingerprint :  SHA256:YaNMhK5ZFF/TshemMHSmt08R9uBPAnhNK134XEZ0CuY (ECDSA)
SSH Fingerprint :  SHA256:QPTYZy5CwrYDXRgiQsx/suQfg6af4dqxzA5ySj35/k4 (ED25519)
SSH Fingerprint :  SHA256:qQNuBNfAoySUPOFPplDh8p0ZPtxRulz/vbOq+Pm4gwM (ED25519)
SSH Fingerprint :  SHA256:Z3zPgtowyJ1xXzc4MS2Iugy2rsO/7Gsmwm93OLV3yUE (RSA)
SSH Fingerprint :  SHA256:psWV2TNuHsZcRelqipM7TJ/mE4cvFI+oxndg6nvCpCk (RSA)
Root Password  :  FDigbGcTyh86QnvLWyT8wh3
Root Password  :  X
 
</syntaxhighlight>Manjaro : <syntaxhighlight lang="shell">
</syntaxhighlight>Manjaro : <syntaxhighlight lang="shell">


Ligne 57 : Ligne 58 :
SSH Fingerprint :  SHA256:AJLfxk4Zz8BZflWYOS8mifapH+uAFgGKA3WSj6rN0NA (ED25519)
SSH Fingerprint :  SHA256:AJLfxk4Zz8BZflWYOS8mifapH+uAFgGKA3WSj6rN0NA (ED25519)
SSH Fingerprint :  SHA256:/6iWOWoii0nJsbScwVYIGQAbuTI1/YIpaRyRdBl8mwE (RSA)
SSH Fingerprint :  SHA256:/6iWOWoii0nJsbScwVYIGQAbuTI1/YIpaRyRdBl8mwE (RSA)
Root Password  :  PgvMbhYvgtksg8tmiJnVZnQ
Root Password  :  Y
</syntaxhighlight>LinusTorvalds :<syntaxhighlight lang="shell">
</syntaxhighlight>LinusTorvalds :<syntaxhighlight lang="shell">
  Installation Summary
  Installation Summary
Ligne 69 : Ligne 70 :
SSH Fingerprint :  SHA256:FbqBOG+0bBjuQBOlAytAlbMV/9VoJ8BAlFadG/VaGD4 (ED25519)
SSH Fingerprint :  SHA256:FbqBOG+0bBjuQBOlAytAlbMV/9VoJ8BAlFadG/VaGD4 (ED25519)
SSH Fingerprint :  SHA256:FCEtQGUhMhN9DDtTmt5zts/9PeC7ahnmJA7UOhMnGeg (RSA)
SSH Fingerprint :  SHA256:FCEtQGUhMhN9DDtTmt5zts/9PeC7ahnmJA7UOhMnGeg (RSA)
Root Password  :  ekrmCSKb3ZAxXSYvNpjbiSK
Root Password  :  Z
</syntaxhighlight>
</syntaxhighlight>


Ligne 90 : Ligne 91 :


==== Etape 5 : Partition ====
==== Etape 5 : Partition ====
On ajoute les deux lignes "phy" dans /etc/xen/SE4.CachyOS.cfg et  /etc/xen/SE4.Manjaro.cfg :<syntaxhighlight lang="shell">
 
===== Sur capbreton =====
 
On partionne avec cette commande :<syntaxhighlight lang="shell">
lvcreate -n SE4.CachyOS.var -L 10G virtual
</syntaxhighlight>
On éteint notre machine : <syntaxhighlight lang="shell">
xen shutdown SE4.CachyOS
</syntaxhighlight>
Et on modifie :<syntaxhighlight lang="shell">
vim /etc/xen/SE4.CachyOS.cfg
</syntaxhighlight>
 
Et on ajoute ceci :<syntaxhighlight lang="shell">
disk = [
disk = [
             'file:/usr/local/xen/domains/SE4.CachyOS/disk.img,xvda2,w',
             [...],
            'file:/usr/local/xen/domains/SE4.CachyOS/swap.img,xvda1,w',
             'phy:/dev/virtual/SE4.CachyOS.home,xvda3,w',
             'phy:/dev/virtual/SE4.CachyOS.home,xvda3,w',
             'phy:/dev/virtual/SE4.CachyOS.var,xvdb1,w'
             'phy:/dev/virtual/SE4.CachyOS.var,xvdb1,w'
Ligne 99 : Ligne 112 :
</syntaxhighlight>
</syntaxhighlight>


===== Sur la machine mandataire =====
Nous ajoutons les partitions dans '''''/etc/fstab''''' : <syntaxhighlight lang="shell">
/dev/xvda3 /var ext4 defaults 0 2
/dev/xvdb1 /home ext4 defaults 0 2
</syntaxhighlight>
Nous formatons les partitions avant de les utiliser : <syntaxhighlight lang="shell">
mkfs -t ext4 /dev/xvda3
mkfs -t ext4 /dev/xvdb1
</syntaxhighlight>
Nous copions le contenu de '''/var''' : <syntaxhighlight lang="shell">
mount /dev/xvda3 /mnt
mv /var/* /mnt
umount /mnt
</syntaxhighlight>
Nous montons ensuite automatiquement les partitions définies dans '''/etc/fstab''' : <syntaxhighlight lang="shell">
mount -a
</syntaxhighlight>
===== De nouveaux sur capbreton =====
On redémarre notre machine : <syntaxhighlight lang="shell">
xen create /etc/xen/SE4.CachyOS.cfg
</syntaxhighlight>
Ensuite on se connecte à notre VM via :<syntaxhighlight lang="shell">
xen console SE4.CachyOS
</syntaxhighlight>
===== Machines de Service - CachyOS & Manjaro =====
Dans notre VM :
On modifie  :<syntaxhighlight lang="shell">
vim /etc/network/interfaces
</syntaxhighlight>
Et on ajoute ceci :<syntaxhighlight lang="shell">
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
    address 192.168.10.3/24
    gateway 192.168.10.1
# Pour l'ipv6
auto eth1
iface eth1 inet6 auto
</syntaxhighlight>
* 172.60.0.3 est l'adresse IPV4 de la VM CachyOS
===== Machine Mandataire - LinusTorvalds =====
La machine mandataire agit comme passerelle IPv4 pour les machines de services. Voici sa configuration réseau :
La machine mandataire va posséder trois adresses. Une adresse IPv6 routée, une adresse IPv4 routée et une adresse IPv4 pour le réseau privé avec ces deux machines de services. Pour ce faire, nous devons au préalable configurer une nouvelle interface eth1 pour y intégrer la seconde adresse IPv4.
Sur capbreton, depuis <code>/etc/xen/SE4.CachyOS.cfg :</code><syntaxhighlight lang="shell">
vif = [[...], 'mac=00:16:3E:8B:45:ED,bridge=SE4']
</syntaxhighlight>Pour l'adresse mac on prend celui existant et on fait +1.
Depuis <code>/etc/resolv.conf </code>:<syntaxhighlight lang="shell">
nameserver 8.8.8.8
</syntaxhighlight>
==== SSH  476  ssh   -oKexAlgorithms=+diffie-hellman-group14-sha1   -oHostKeyAlgorithms=+ssh-rsa    -oCiphers=+aes128-cbc   admin@172.27.0.3 ====
<syntaxhighlight lang="shell">
apt update
apt upgrade
apt install ssh
apt install bind9
apt install apache2
</syntaxhighlight>(Dans TOUTES les VMs)
On active le SSH en ajoutant dans <code>/etc/ssh/sshd_config</code> :<syntaxhighlight lang="shell">
PermitRootLogin yes
</syntaxhighlight>Pour redemarrer le service ssh :<syntaxhighlight lang="shell">
/etc/init.d/ssh restart
</syntaxhighlight>Pour la machine mandataire, ensuite après avoir reboot on peut faire dans nos machines de services :<syntaxhighlight lang="shell">
iptables -t nat -A POSTROUTING -j MASQUERADE -s 192.168.10.0/24
</syntaxhighlight>
==== Mascarade ====
Sur la mandataire : <syntaxhighlight lang="shell">
iptables -t nat -A PREROUTING -p tcp --dport 2202 -j DNAT --to-destination 192.168.10.3:22
iptables-save
</syntaxhighlight>Et on décommente cette ligne dans <code>/etc/sysctl.conf</code> : <syntaxhighlight lang="shell">
net.ipv4.ip_forward=1
</syntaxhighlight>Et maintenant nous pouvons nous connecter à notre machine de service en ssh : <syntaxhighlight lang="shell">
#IPV4
ssh root@193.48.57.166 -p 2202
# IPV6
ssh root@2001:660:4401:60a0:216:3eff:fe8b:45ed
</syntaxhighlight>
==== DNS ====
Tout d'abord, il faut modifier <code>/etc/bind/named.conf.local</code> : <syntaxhighlight lang="shell">
zone "archlinuxbtw.lol" {
type master;
file "/etc/bind/myZones/db.archlinuxbtw.lol";
allow-transfer{secondaries;};
notify yes;
};
acl "secondaries"{
192.168.10.2;
2001:660:4401:60a0:216:3eff:fe36:79d9;
};
zone "archlinux.lol" {
type secondary;
file "/etc/bind/backup/db.archlinux.lol";
primaries{2001:660:4401:60a0:216:3eff:fe36:79d9;};
};
</syntaxhighlight>J'ai ensuite créée un dossier myZones puis j'ai créer db.archlinuxbtw.lol et j'y ai ajouter :<syntaxhighlight lang="shell">
$TTL 400
@ IN SOA ns.archlinuxbtw.lol admin.archlinuxbtw.lol (
          3609    ; Numero de version
          21600    ; Rafraichissement (6h)
          3600    ; Re-tentative (1h)
        2592000    ; Expiration (30j)
        86400    ; Cache negatif (24h)
);
IN NS ns.archlinuxbtw.lol.
IN NS ns.archlinux.lol.
@ IN A 193.48.57.166
@ IN AAAA 2001:660:4401:60a0:216:3eff:fe8b:45ed
ns IN A 193.48.57.166
ns IN AAAA 2001:660:4401:60a0:216:3eff:fe8b:45ed
www IN CNAME archlinuxbtw.lol
</syntaxhighlight>Ensuite on restart le service via : <code>service named restart</code>
Création d'une clé<syntaxhighlight lang="shell">
openssl req -nodes -newkey rsa:2048 -sha256 -keyout archlinuxbtw.lol.key -out archlinuxbtw.csr
</syntaxhighlight>
[[Fichier:DNS Check.png|centré|vignette|452x452px|DNS Checker ]]
Notre DNS est bien reconnu et la commande  <code>dig @8.8.8.8 archlinuxbtw.lol</code> c'est grâce au Glue records.
Génération des clés
Changement nom machine <code>nano /etc/hostname : CachyOS</code>
Et dans /etc/hosts:
127.0.1.1    archlinuxbtw.lol SE4.CachyOS
==== DNSSEC ====
Afin de protéger notre DNS contre des possibles attaques nous utiliserons DNSSEC. Ici nous utiliserons la politique DNSSEC : <code>"dnspol"</code>
Ensuite on crée le dossier keys et on donne les droits a bind d'écrire dedans avec :<syntaxhighlight lang="shell">
mkdir /etc/bind/keys
chown bind:bind /etc/bind/keys
chmod 750 /etc/bind/keys
</syntaxhighlight>Pour ce faire, dans <code>named.conf.local</code> il faut rajouter les 3 lignes à partir de "key-directory" :<syntaxhighlight lang="shell">
  key-directory "/etc/bind/keys";
  dnssec-policy "dnspol";  // DNSSEC automatique
  inline-signing yes;
 
  [...]
 
  dnssec-policy "dnspol" {
  keys {
      ksk key-directory lifetime unlimited algorithm 13;
      zsk key-directory lifetime unlimited algorithm 13;
  };
  nsec3param;
};
</syntaxhighlight>Pour l'activer, il faut restart bind9 avec <code>systemctl restart bind9</code>
Il ne reste qu'à ajouter la clé KSK sur Gandi et ensite on peut voir s'il fonctionne bien grace au site suivant : <nowiki>https://dnsviz.net</nowiki>
[[Fichier:DNSSec.png|centré|vignette|DNSSec]]
Et on peut voir que nos clefs on bien été générer : <syntaxhighlight lang="shell">
root@CachyOS:/etc/bind# ls keys/
Karchlinuxbtw.lol.+013+24458.key      Karchlinuxbtw.lol.+013+56682.key
Karchlinuxbtw.lol.+013+24458.private  Karchlinuxbtw.lol.+013+56682.private
Karchlinuxbtw.lol.+013+24458.state    Karchlinuxbtw.lol.+013+56682.state
</syntaxhighlight>
==== Apache ====
Dans ce repertoire <code>/etc/apache2/sites-availab</code>le  : touch archlinuxbtw.lol.conf
Je genere un crt via la commande :
openssl x509 -req -days 365 -in archlinuxbtw.csr -signkey archlinuxb
tw.lol.key -out archlinuxbtw.lol.crt
Et je deplace mes fichiers dans :
root@CachyOS:~# mv archlinuxbtw.lol.crt /etc/ssl/certs/
root@CachyOS:~# mv archlinuxbtw.lol.key /etc/ssl/private/
root@CachyOS:~# chmod 600 /etc/ssl/private/archlinuxbtw.lol.key
Pour arreter le service par defaut : a2dissite 000-default.conf
Et on verifie avec la commande :  apache2ctl -S
Iptable pour atteindres les ports https : <code># HTTP iptables -t nat -A PREROUTING -p tcp --dport 80 -j DNAT --to-destination 192.168.10.3:80 # HTTPS iptables -t nat -A PREROUTING -p tcp --dport 443 -j DNAT --to-destination 192.168.10.3:443 iptables-save</code>
iptables -A FORWARD -p tcp -d 192.168.10.3 --dport 80 -j ACCEPT
iptables -A FORWARD -p tcp -d 192.168.10.3 --dport 443 -j ACCEPT
==== Effraction WiFi ====
===== Cassage WEP =====
Il faut tout faire sur la zabeth13 comme on avait tester sur 4 machines dans la semaine avec mon binome les cartes réseaux des autres machines ne marchent pas.
Avec ip link je vois que l'interface wifi se nomme <code>wlx40a5ef0f679b</code>.
On peut alors recuperer le bssid de notre réseau wifi a crack. Je suis le numéro 5 donc je dois crack la cracotte05 :
<code>sudo airodump-ng wlx40a5ef0f679b</code>
Je recupere :
<code>BSSID              PWR  Beacons    #Data, #/s  CH   MB   ENC CIPHER  AUTH ESSID</code>
<code>04:DA:D2:9C:50:54  -63       27        5    0   4   54e. WEP  WEP         cracotte05</code> 
Je peux alors dump correctement en filtrant seulement le bon bssid et le bon channel via cette commande :
<code>sudo airodump-ng wlx40a5ef0f679b --write airodump --bssid 04:DA:D2:9C:50:54 -c4</code>
Et en parallele on lance ceci jusqu'a ce que la clef soit trouvé :
<code>aircrack-ng airodump-01.cap</code><syntaxhighlight lang="shell">
                                                                                    Aircrack-ng 1.7
                                                                      [00:26:11] Tested 835 keys (got 68980 IVs)
                                                                                Got 70001 out of 70000 IVsStarting PTW attack with 70001 ivs.
  KB    depth  byte(vote)
    0    0/ 13  FF(97024) A3(79616) D9(79360) C5(78848) 3A(78592) E3(78592) 29(78336) D1(78336) E9(78080) 7C(77568) DF(77568) 34(76800) 85(76800) D8(76544) 24(76032)
    1    0/  1  CA(108544) CB(80128) B5(79104) EB(78336) 10(77824) A8(77312) E5(76800) F8(76800) E7(76544) EE(76544) 27(76288) 4C(76288) 68(76288) CC(76288) E6(76288)
    2    2/  2  A4(80128) 3A(78336) 14(76800) 5A(76544) D2(76544) 98(76032) 08(75776) 1D(75776) 40(75776) 99(75776) E4(75776) F2(75776) CD(75520) F7(75520) 56(75008)
    3    0/  1  D1(100608) 89(79872) 22(77568) 11(77056) A0(77056) 9E(76800) B0(76800) 98(76544) A9(76544) 5A(76032) AB(76032) CD(76032) 9A(75776) 4D(75520) 51(75264)
    4    7/  4  43(77312) 4E(76800) 0F(76544) 29(76544) BA(76544) 3E(76032) 61(75776) A6(75776) C6(75776) 89(75264) 21(75008) 5A(75008) 65(75008) C8(75008) DD(75008)
            KEY FOUND! [ FF:FF:FF:FF:FA:BC:06:CB:AE:EE:EE:EE:EE ]
Decrypted correctly: 100%
</syntaxhighlight>
===== Cassage WPA-PKS =====
Ce script python permet de creer un dictionnaire :<syntaxhighlight lang="python">
with open("dictionnaire_8_chiffres.txt", "w") as f:
    for i in range(100000000):  # Pour générer des nombres de 00000000 à 99999999
        f.write(f"{i:08d}\n")  # Écrit le nombre avec 8 chiffres
</syntaxhighlight>ou alors avec crunch :


A COMPLETER
<code>crunch 8 8 0123456789 -o dictionnaire_8_chiffres.txt</code>
 
Ensuite après execution nous pouvons recuperer le fichier .txt créer.
 
On récuperer le dump comme precedemment pour cette borne pour mon cas :
 
<code>BSSID              PWR  Beacons    #Data, #/s  CH   MB   ENC CIPHER  AUTH ESSID</code>
 
<code>44:AD:D9:5F:87:04  -43        3        5    2  13   54e. WPA2 CCMP   PSK  kracotte05</code>  
 
Je peux alors dump correctement en filtrant seulement le bon bssid et le bon channel via cette commande :<code>sudo airodump-ng wlx40a5ef0f679b --write airodumpWPA --bssid 44:AD:D9:5F:87:04 -c13</code>
 
Et ensuite après avoir récuperer 1 data minimum :
 
<code>aircrack-ng airodump-01.cap</code>
 
 
Et enfin on attend (c'est long si vous vous demander... tres looong faite la suite en attendant :<syntaxhighlight lang="bash">
                              Aircrack-ng 1.7
 
      [00:35:36] 66631280/100000000 keys tested (30842.35 k/s)
 
      Time left: 18 minutes, 1 second                          66.63%
 
                          KEY FOUND! [ 66685666 ]
 
 
      Master Key    : EF 69 DE 33 B4 7F AA 9E 20 AB 3C AF F1 F7 3E A8
                      61 7C 80 F2 3C A9 FE B6 9A 72 98 B3 20 B3 2A A6
 
      Transient Key  : 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
                      00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
                      00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
                      00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 
      EAPOL HMAC    : AD 95 F2 4D 5A 3F 4A 57 CD D8 0E EA A6 14 8B 1A
 
 
</syntaxhighlight>
 
==== Sécurisation WiFi par WPA2-EAP ====
Depuis notre machine de service on va se connecter sur notre borne wifi, ici on prend l'IP de la E304 :
 
<code>ssh -oKexAlgorithms=+diffie-hellman-group11-sha1 -oHostKeyAlgorithms=+ssh-rsa -oCiphers=+aes128-cbc admin@172.27.0.4</code>
 
<syntaxhighlight lang="bash">
conf t
 
aaa new-model
aaa authentication login eap_student5 group radius_student5
radius-server host 192.168.10.3 auth-port 1812 acct-port 1813 key secret_student5       
aaa group server radius radius_student5                     
server 192.168.10.3 auth-port 1812 acct-port 1813       
exit
 
dot11 ssid VM_SERVICES_5     
vlan 15       
authentication open eap eap_student5
authentication network-eap eap_student5
authentication key-management wpa
mbssid guest-mode
exit
 
interface Dot11Radio0
encryption vlan 15 mode ciphers aes-ccm                 
exit
 
interface Dot11Radio0.15
encapsulation dot1Q 15
bridge-group 15
exit
 
interface GigabitEthernet0.15
encapsulation dot1Q 15
bridge-group 15
exit
 
interface Dot11Radio0
ssid VM_SERVICES_5
exit
 
 
</syntaxhighlight>
 
 
 
et l'IP de la E305 :
 
<code>ssh -oKexAlgorithms=+diffie-hellman-group14-sha1 -oHostKeyAlgorithms=+ssh-rsa -oCiphers=+aes128-cbc admin@172.27.0.3</code>
 
 
Et ensuite sur le routeur :<syntaxhighlight lang="shell">
conf t
 
ip dhcp pool PoolCedric
network 10.60.5.0 255.255.255.0
dns-server 193.48.57.166
default-router 10.60.5.254
exit
 
exit
write
</syntaxhighlight><syntaxhighlight lang="shell">
interface Vlan15
description "VLAN personnel de Cedric PAYET (E5) - WPA2-EAP"
ip address 10.60.5.2 255.255.255.0
ipv6 address 2001:660:4401:60a5::2/64
vrrp 15 address-family ipv4
  priority 110
  address 10.60.5.1 primary
  exit-vrrp
end
 
</syntaxhighlight><syntaxhighlight lang="shell">
conf t
vlan 15
name E5-Cedric
exit
exit
write
</syntaxhighlight><syntaxhighlight lang="shell">
wifi-E306(config)#interface GigabitEthernet0.15
wifi-E306(config-subif)#encapsulation dot1Q 15
wifi-E306(config-subif)#bridge-group 15
wifi-E306(config-subif)#bridge-group 15 spanning-disabled
wifi-E306(config-subif)#no bridge-group 15 source-learning
wifi-E306(config-subif)#exit
wifi-E306(config)#exit
 
</syntaxhighlight><syntaxhighlight lang="shell">
wifi-E306(config)#int dot11radio0
wifi-E306(config-if)#encryption vlan 5 mode ciphers aes-ccm
wifi-E306(config-if)#ssid VM_SERVICES_5
wifi-E306(config-if)#exit
wifi-E306(config)#exit
wifi-E306#sh run
 
</syntaxhighlight><syntaxhighlight lang="shell">
interface Dot11Radio0.15
encapsulation dot1Q 15
bridge-group 15
bridge-group 15 subscriber-loop-control
bridge-group 15 spanning-disabled
bridge-group 15 block-unknown-source
no bridge-group 15 source-learning
no bridge-group 15 unicast-flooding
 
</syntaxhighlight>
 
=== Utiles ===
 
=== XEN ===
''<u>Liste des VMs allumées :</u>'' <syntaxhighlight lang="shell">
xen list
</syntaxhighlight>
 
''<u>Se connecter à la VM :</u>''<syntaxhighlight lang="shell">
xen console <nomMachine>
</syntaxhighlight>nomMachine : dans notre cas soit SE4.Manjaro | SE4.CachyOS | SE4.LinusTorvalds
''<u>Sortir de la console xen :</u>''<syntaxhighlight lang="shell">
Ctrl + Shift + 5
</syntaxhighlight>''<u>Eteindre une VM :</u>'' <syntaxhighlight lang="shell">
xen shutdown <nomMachine>
</syntaxhighlight>nomMachine : dans notre cas soit SE4.Manjaro | SE4.CachyOS | SE4.LinusTorvalds
 
''<u>Allumer une VM :</u>''<syntaxhighlight lang="shell">
xen create /etc/xen/<nomMachine>.cfg
</syntaxhighlight>

Version actuelle datée du 21 février 2026 à 21:02

Compte rendu des commandes effectués

Etape 1 : Connexion SSH

ssh root@capbreton

Mot de passe :

Etape 2 : Créer un fichier dans le répertoire /etc/network/interfaces.d du Dom0 aux noms du binôme concerné

On se déplace à ce répertoire :

 cd /etc/network/interfaces.d/

On créer ensuite ensuite un fichier aux noms de notre binôme et on l'édite :

touch SE42026_cpayet_tdelobel
vim SE42026_cpayet_tdelobel

Puis on donne un nom au bridge, ici c'est `pont_pacman`et on met dans le fichier ceci :

auto pont_pacman
iface pont_pacman inet manual
    bridge_ports none
    up ip link set $IFACE up
    down ip link set $IFACE down

Une fois le pont créer, il faut le démarrer :

ifup pont_pacman

Etape 3 : Création des VMs

xen-create-image --hostname=SE4.CachyOS         --dhcp --bridge=pont_pacman --dir=/usr/local/xen --size=10G --dist=daedalus --memory=2048M --force
xen-create-image --hostname=SE4.Manjaro         --dhcp --bridge=pont_pacman --dir=/usr/local/xen --size=10G --dist=daedalus --memory=2048M --force
xen-create-image --hostname=SE4.LinusTorvalds   --dhcp --bridge=pont_pacman --dir=/usr/local/xen --size=10G --dist=daedalus --memory=2048M --force

On adapte les hostnames en fonction des nom de nos machines.

IMPORTANT : Les résultats des commandes sont à noter car ellles contiennent les mots de passe et autres informations importantes.

Nos résultats :

CachyOS :

Installation Summary
---------------------
Hostname        :  SE4.CachyOS
Distribution    :  daedalus
MAC Address     :  00:16:3E:8B:45:EC
IP Address(es)  :  dynamic
SSH Fingerprint :  SHA256:p+nECGSXOPvFjDjk+/x8adAn8JxTTPjuknCTcFZxJNk (DSA)
SSH Fingerprint :  SHA256:YaNMhK5ZFF/TshemMHSmt08R9uBPAnhNK134XEZ0CuY (ECDSA)
SSH Fingerprint :  SHA256:qQNuBNfAoySUPOFPplDh8p0ZPtxRulz/vbOq+Pm4gwM (ED25519)
SSH Fingerprint :  SHA256:psWV2TNuHsZcRelqipM7TJ/mE4cvFI+oxndg6nvCpCk (RSA)
Root Password   :  X

Manjaro :

Installation Summary
---------------------
Hostname        :  SE4.Manjaro
Distribution    :  daedalus
MAC Address     :  00:16:3E:36:79:D8
IP Address(es)  :  dynamic
SSH Fingerprint :  SHA256:n+ojtWyKBODRtEppjCvAp6nd2cjL/Ily54j0cM03lMc (DSA)
SSH Fingerprint :  SHA256:K+Qa9NAU3JIGsMy3LEYCgFbfL3ozuiRKG+U3XsbV5ow (ECDSA)
SSH Fingerprint :  SHA256:AJLfxk4Zz8BZflWYOS8mifapH+uAFgGKA3WSj6rN0NA (ED25519)
SSH Fingerprint :  SHA256:/6iWOWoii0nJsbScwVYIGQAbuTI1/YIpaRyRdBl8mwE (RSA)
Root Password   :  Y

LinusTorvalds :

 Installation Summary
---------------------
Hostname        :  SE4.LinusTorvalds
Distribution    :  daedalus
MAC Address     :  00:16:3E:AA:BF:EF
IP Address(es)  :  dynamic
SSH Fingerprint :  SHA256:ouY/2dce0YI/mJD9Qw68oKU0xdw6Cs9ybgJxRm/FKiI (DSA)
SSH Fingerprint :  SHA256:p5lZznE0q8j6c68YTF5toYgBugOkc0IopTO+Ce9SiZ8 (ECDSA)
SSH Fingerprint :  SHA256:FbqBOG+0bBjuQBOlAytAlbMV/9VoJ8BAlFadG/VaGD4 (ED25519)
SSH Fingerprint :  SHA256:FCEtQGUhMhN9DDtTmt5zts/9PeC7ahnmJA7UOhMnGeg (RSA)
Root Password   :  Z

Etape 4 :

PHRASE MANQUANTE

xen create /etc/xen/SE4.Manjaro.cfg
xen create /etc/xen/SE4.CachyOS.cfg
xen create /etc/xen/SE4.LinusTorvalds.cfg

On vérifie la liste des machines lancées via :

xen list
Nos résultats :
Name                                        ID   Mem VCPUs    State    Time(s)
SE4.CachyOS                                 83  2048     1     -b----       5.6
SE4.Manjaro                                 85  2048     1     -b----       5.8
SE4.LinusTorvalds                           87  2048     1     -b----       5.3

Etape 5 : Partition

Sur capbreton

On partionne avec cette commande :

lvcreate -n SE4.CachyOS.var -L 10G virtual

On éteint notre machine :

xen shutdown SE4.CachyOS

Et on modifie :

vim /etc/xen/SE4.CachyOS.cfg

Et on ajoute ceci :

disk = [
            [...],
            'phy:/dev/virtual/SE4.CachyOS.home,xvda3,w',
            'phy:/dev/virtual/SE4.CachyOS.var,xvdb1,w'
        ]
Sur la machine mandataire

Nous ajoutons les partitions dans /etc/fstab :

/dev/xvda3 /var ext4 defaults 0 2
/dev/xvdb1 /home ext4 defaults 0 2

Nous formatons les partitions avant de les utiliser :

mkfs -t ext4 /dev/xvda3
mkfs -t ext4 /dev/xvdb1

Nous copions le contenu de /var :

mount /dev/xvda3 /mnt
mv /var/* /mnt
umount /mnt

Nous montons ensuite automatiquement les partitions définies dans /etc/fstab :

mount -a
De nouveaux sur capbreton

On redémarre notre machine :

xen create /etc/xen/SE4.CachyOS.cfg

Ensuite on se connecte à notre VM via :

xen console SE4.CachyOS
Machines de Service - CachyOS & Manjaro

Dans notre VM :

On modifie  :

vim /etc/network/interfaces

Et on ajoute ceci :

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
    address 192.168.10.3/24
    gateway 192.168.10.1

# Pour l'ipv6
auto eth1
iface eth1 inet6 auto
  • 172.60.0.3 est l'adresse IPV4 de la VM CachyOS
Machine Mandataire - LinusTorvalds

La machine mandataire agit comme passerelle IPv4 pour les machines de services. Voici sa configuration réseau :

La machine mandataire va posséder trois adresses. Une adresse IPv6 routée, une adresse IPv4 routée et une adresse IPv4 pour le réseau privé avec ces deux machines de services. Pour ce faire, nous devons au préalable configurer une nouvelle interface eth1 pour y intégrer la seconde adresse IPv4.

Sur capbreton, depuis /etc/xen/SE4.CachyOS.cfg :

vif = [[...], 'mac=00:16:3E:8B:45:ED,bridge=SE4']

Pour l'adresse mac on prend celui existant et on fait +1. Depuis /etc/resolv.conf :

nameserver 8.8.8.8

SSH  476  ssh   -oKexAlgorithms=+diffie-hellman-group14-sha1   -oHostKeyAlgorithms=+ssh-rsa    -oCiphers=+aes128-cbc   admin@172.27.0.3

apt update
apt upgrade

apt install ssh
apt install bind9
apt install apache2

(Dans TOUTES les VMs) On active le SSH en ajoutant dans /etc/ssh/sshd_config :

PermitRootLogin yes

Pour redemarrer le service ssh :

/etc/init.d/ssh restart

Pour la machine mandataire, ensuite après avoir reboot on peut faire dans nos machines de services :

iptables -t nat -A POSTROUTING -j MASQUERADE -s 192.168.10.0/24

Mascarade

Sur la mandataire :

iptables -t nat -A PREROUTING -p tcp --dport 2202 -j DNAT --to-destination 192.168.10.3:22
iptables-save

Et on décommente cette ligne dans /etc/sysctl.conf :

net.ipv4.ip_forward=1

Et maintenant nous pouvons nous connecter à notre machine de service en ssh :

#IPV4
ssh root@193.48.57.166 -p 2202
# IPV6
ssh root@2001:660:4401:60a0:216:3eff:fe8b:45ed

DNS

Tout d'abord, il faut modifier /etc/bind/named.conf.local :

zone "archlinuxbtw.lol" {
	type master;
	file "/etc/bind/myZones/db.archlinuxbtw.lol";
	allow-transfer{secondaries;};
	notify yes;
};

acl "secondaries"{
	192.168.10.2;
	2001:660:4401:60a0:216:3eff:fe36:79d9;
};

zone "archlinux.lol" {
	type secondary;
	file "/etc/bind/backup/db.archlinux.lol";
	primaries{2001:660:4401:60a0:216:3eff:fe36:79d9;};
};

J'ai ensuite créée un dossier myZones puis j'ai créer db.archlinuxbtw.lol et j'y ai ajouter :

$TTL 400

@ IN SOA ns.archlinuxbtw.lol admin.archlinuxbtw.lol (
          3609     ; Numero de version
          21600     ; Rafraichissement (6h)
           3600     ; Re-tentative (1h)
        2592000     ; Expiration (30j)
         86400     ; Cache negatif (24h)
);

	IN	NS	ns.archlinuxbtw.lol.
	IN	NS	ns.archlinux.lol.
@	IN	A	193.48.57.166
@	IN	AAAA	2001:660:4401:60a0:216:3eff:fe8b:45ed
ns	IN	A	193.48.57.166
ns	IN	AAAA	2001:660:4401:60a0:216:3eff:fe8b:45ed

www IN CNAME archlinuxbtw.lol

Ensuite on restart le service via : service named restart


Création d'une clé

openssl req -nodes -newkey rsa:2048 -sha256 -keyout archlinuxbtw.lol.key -out archlinuxbtw.csr
DNS Checker

Notre DNS est bien reconnu et la commande dig @8.8.8.8 archlinuxbtw.lol c'est grâce au Glue records.


Génération des clés


Changement nom machine nano /etc/hostname : CachyOS

Et dans /etc/hosts:

127.0.1.1    archlinuxbtw.lol SE4.CachyOS

DNSSEC

Afin de protéger notre DNS contre des possibles attaques nous utiliserons DNSSEC. Ici nous utiliserons la politique DNSSEC : "dnspol"

Ensuite on crée le dossier keys et on donne les droits a bind d'écrire dedans avec :

mkdir /etc/bind/keys 
chown bind:bind /etc/bind/keys 
chmod 750 /etc/bind/keys

Pour ce faire, dans named.conf.local il faut rajouter les 3 lignes à partir de "key-directory" :

  key-directory "/etc/bind/keys";
  dnssec-policy "dnspol";   // DNSSEC automatique
  inline-signing yes;
  
  [...]
  
  dnssec-policy "dnspol" {
   keys {
       ksk key-directory lifetime unlimited algorithm 13;
       zsk key-directory lifetime unlimited algorithm 13;
   };
   nsec3param;
};

Pour l'activer, il faut restart bind9 avec systemctl restart bind9

Il ne reste qu'à ajouter la clé KSK sur Gandi et ensite on peut voir s'il fonctionne bien grace au site suivant : https://dnsviz.net

DNSSec


Et on peut voir que nos clefs on bien été générer :

root@CachyOS:/etc/bind# ls keys/
Karchlinuxbtw.lol.+013+24458.key      Karchlinuxbtw.lol.+013+56682.key
Karchlinuxbtw.lol.+013+24458.private  Karchlinuxbtw.lol.+013+56682.private
Karchlinuxbtw.lol.+013+24458.state    Karchlinuxbtw.lol.+013+56682.state

Apache

Dans ce repertoire /etc/apache2/sites-available  : touch archlinuxbtw.lol.conf


Je genere un crt via la commande :

openssl x509 -req -days 365 -in archlinuxbtw.csr -signkey archlinuxb

tw.lol.key -out archlinuxbtw.lol.crt


Et je deplace mes fichiers dans :

root@CachyOS:~# mv archlinuxbtw.lol.crt /etc/ssl/certs/

root@CachyOS:~# mv archlinuxbtw.lol.key /etc/ssl/private/

root@CachyOS:~# chmod 600 /etc/ssl/private/archlinuxbtw.lol.key

Pour arreter le service par defaut : a2dissite 000-default.conf

Et on verifie avec la commande : apache2ctl -S

Iptable pour atteindres les ports https : # HTTP iptables -t nat -A PREROUTING -p tcp --dport 80 -j DNAT --to-destination 192.168.10.3:80 # HTTPS iptables -t nat -A PREROUTING -p tcp --dport 443 -j DNAT --to-destination 192.168.10.3:443 iptables-save


iptables -A FORWARD -p tcp -d 192.168.10.3 --dport 80 -j ACCEPT

iptables -A FORWARD -p tcp -d 192.168.10.3 --dport 443 -j ACCEPT

Effraction WiFi

Cassage WEP

Il faut tout faire sur la zabeth13 comme on avait tester sur 4 machines dans la semaine avec mon binome les cartes réseaux des autres machines ne marchent pas.

Avec ip link je vois que l'interface wifi se nomme wlx40a5ef0f679b.

On peut alors recuperer le bssid de notre réseau wifi a crack. Je suis le numéro 5 donc je dois crack la cracotte05 :

sudo airodump-ng wlx40a5ef0f679b


Je recupere :

BSSID              PWR  Beacons    #Data, #/s  CH   MB   ENC CIPHER  AUTH ESSID

04:DA:D2:9C:50:54  -63       27        5    0   4   54e. WEP  WEP         cracotte05

Je peux alors dump correctement en filtrant seulement le bon bssid et le bon channel via cette commande :

sudo airodump-ng wlx40a5ef0f679b --write airodump --bssid 04:DA:D2:9C:50:54 -c4

Et en parallele on lance ceci jusqu'a ce que la clef soit trouvé :

aircrack-ng airodump-01.cap

                                                                                     Aircrack-ng 1.7 


                                                                       [00:26:11] Tested 835 keys (got 68980 IVs)
                                                                                Got 70001 out of 70000 IVsStarting PTW attack with 70001 ivs.
   KB    depth   byte(vote)
    0    0/ 13   FF(97024) A3(79616) D9(79360) C5(78848) 3A(78592) E3(78592) 29(78336) D1(78336) E9(78080) 7C(77568) DF(77568) 34(76800) 85(76800) D8(76544) 24(76032) 
    1    0/  1   CA(108544) CB(80128) B5(79104) EB(78336) 10(77824) A8(77312) E5(76800) F8(76800) E7(76544) EE(76544) 27(76288) 4C(76288) 68(76288) CC(76288) E6(76288) 
    2    2/  2   A4(80128) 3A(78336) 14(76800) 5A(76544) D2(76544) 98(76032) 08(75776) 1D(75776) 40(75776) 99(75776) E4(75776) F2(75776) CD(75520) F7(75520) 56(75008) 
    3    0/  1   D1(100608) 89(79872) 22(77568) 11(77056) A0(77056) 9E(76800) B0(76800) 98(76544) A9(76544) 5A(76032) AB(76032) CD(76032) 9A(75776) 4D(75520) 51(75264) 
    4    7/  4   43(77312) 4E(76800) 0F(76544) 29(76544) BA(76544) 3E(76032) 61(75776) A6(75776) C6(75776) 89(75264) 21(75008) 5A(75008) 65(75008) C8(75008) DD(75008) 

             KEY FOUND! [ FF:FF:FF:FF:FA:BC:06:CB:AE:EE:EE:EE:EE ] 
	Decrypted correctly: 100%
Cassage WPA-PKS

Ce script python permet de creer un dictionnaire :

with open("dictionnaire_8_chiffres.txt", "w") as f:
    for i in range(100000000):  # Pour générer des nombres de 00000000 à 99999999
        f.write(f"{i:08d}\n")  # Écrit le nombre avec 8 chiffres

ou alors avec crunch :

crunch 8 8 0123456789 -o dictionnaire_8_chiffres.txt

Ensuite après execution nous pouvons recuperer le fichier .txt créer.

On récuperer le dump comme precedemment pour cette borne pour mon cas :

BSSID              PWR  Beacons    #Data, #/s  CH   MB   ENC CIPHER  AUTH ESSID

44:AD:D9:5F:87:04  -43        3        5    2  13   54e. WPA2 CCMP   PSK  kracotte05  

Je peux alors dump correctement en filtrant seulement le bon bssid et le bon channel via cette commande :sudo airodump-ng wlx40a5ef0f679b --write airodumpWPA --bssid 44:AD:D9:5F:87:04 -c13

Et ensuite après avoir récuperer 1 data minimum :

aircrack-ng airodump-01.cap


Et enfin on attend (c'est long si vous vous demander... tres looong faite la suite en attendant :

                               Aircrack-ng 1.7 

      [00:35:36] 66631280/100000000 keys tested (30842.35 k/s) 

      Time left: 18 minutes, 1 second                           66.63%

                           KEY FOUND! [ 66685666 ]


      Master Key     : EF 69 DE 33 B4 7F AA 9E 20 AB 3C AF F1 F7 3E A8 
                       61 7C 80 F2 3C A9 FE B6 9A 72 98 B3 20 B3 2A A6 

      Transient Key  : 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
                       00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
                       00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
                       00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 

      EAPOL HMAC     : AD 95 F2 4D 5A 3F 4A 57 CD D8 0E EA A6 14 8B 1A

Sécurisation WiFi par WPA2-EAP

Depuis notre machine de service on va se connecter sur notre borne wifi, ici on prend l'IP de la E304 :

ssh -oKexAlgorithms=+diffie-hellman-group11-sha1 -oHostKeyAlgorithms=+ssh-rsa -oCiphers=+aes128-cbc admin@172.27.0.4

conf t

aaa new-model
aaa authentication login eap_student5 group radius_student5
radius-server host 192.168.10.3 auth-port 1812 acct-port 1813 key secret_student5        
aaa group server radius radius_student5                      
server 192.168.10.3 auth-port 1812 acct-port 1813        
exit

dot11 ssid VM_SERVICES_5       
vlan 15         
authentication open eap eap_student5 
authentication network-eap eap_student5
authentication key-management wpa
mbssid guest-mode
exit

interface Dot11Radio0
encryption vlan 15 mode ciphers aes-ccm                  
exit

interface Dot11Radio0.15
encapsulation dot1Q 15
bridge-group 15
exit

interface GigabitEthernet0.15
encapsulation dot1Q 15
bridge-group 15
exit

interface Dot11Radio0
ssid VM_SERVICES_5
exit


et l'IP de la E305 :

ssh -oKexAlgorithms=+diffie-hellman-group14-sha1 -oHostKeyAlgorithms=+ssh-rsa -oCiphers=+aes128-cbc admin@172.27.0.3


Et ensuite sur le routeur :

conf t

ip dhcp pool PoolCedric
network 10.60.5.0 255.255.255.0
dns-server 193.48.57.166
default-router 10.60.5.254
exit

exit
write
interface Vlan15
 description "VLAN personnel de Cedric PAYET (E5) - WPA2-EAP"
 ip address 10.60.5.2 255.255.255.0
 ipv6 address 2001:660:4401:60a5::2/64
 vrrp 15 address-family ipv4
  priority 110
  address 10.60.5.1 primary
  exit-vrrp
end
conf t
vlan 15
name E5-Cedric
exit
exit
write
wifi-E306(config)#interface GigabitEthernet0.15
wifi-E306(config-subif)#encapsulation dot1Q 15
wifi-E306(config-subif)#bridge-group 15
wifi-E306(config-subif)#bridge-group 15 spanning-disabled
wifi-E306(config-subif)#no bridge-group 15 source-learning
wifi-E306(config-subif)#exit
wifi-E306(config)#exit
wifi-E306(config)#int dot11radio0 
wifi-E306(config-if)#encryption vlan 5 mode ciphers aes-ccm 
wifi-E306(config-if)#ssid VM_SERVICES_5
wifi-E306(config-if)#exit
wifi-E306(config)#exit
wifi-E306#sh run
interface Dot11Radio0.15
 encapsulation dot1Q 15
 bridge-group 15
 bridge-group 15 subscriber-loop-control
 bridge-group 15 spanning-disabled
 bridge-group 15 block-unknown-source
 no bridge-group 15 source-learning
 no bridge-group 15 unicast-flooding

Utiles

XEN

Liste des VMs allumées :

xen list

Se connecter à la VM :

xen console <nomMachine>

nomMachine : dans notre cas soit SE4.Manjaro | SE4.CachyOS | SE4.LinusTorvalds Sortir de la console xen :

Ctrl + Shift + 5

Eteindre une VM :

xen shutdown <nomMachine>

nomMachine : dans notre cas soit SE4.Manjaro | SE4.CachyOS | SE4.LinusTorvalds Allumer une VM :

xen create /etc/xen/<nomMachine>.cfg