Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
80c1f1b
Intégration de AesCbcAnalyzer dans DetecteurCryptoOrchestrateur.
Eunock-web Aug 2, 2025
83cc501
Merge branch 'feature/consoleInterface' of https://github.com/mouwafi…
Eunock-web Aug 2, 2025
a41256c
Debut de l'implementation du code dans la classe principale avec le menu
Eunock-web Aug 2, 2025
cac3bf5
Suite de l'implementation du code dans la classe principale avec le menu
Eunock-web Aug 2, 2025
93fd27d
Update de l'option quitter
wesley-kami Aug 4, 2025
77102c5
Merge branch 'main' of https://github.com/mouwaficbdr/CryptoForensic-…
wesley-kami Aug 4, 2025
c1c0b22
Revu des fonctions pour une meilleure optimisation
Eunock-web Aug 5, 2025
abb4365
Merge branch 'feature/DetecteurCryptoOrchestrateur' of https://github…
wesley-kami Aug 5, 2025
b74715c
Ajout du guide d'utilisation
wesley-kami Aug 5, 2025
5c9e9bb
Merge branch 'main' of https://github.com/mouwaficbdr/CryptoForensic-…
wesley-kami Aug 5, 2025
3a51f8e
Merge branch 'main' of https://github.com/mouwaficbdr/CryptoForensic-…
wesley-kami Aug 6, 2025
a45afa0
mission1 + console prémices
wesley-kami Aug 6, 2025
5e5d7c0
Merge branch 'main' of https://github.com/mouwaficbdr/CryptoForensic-…
wesley-kami Aug 7, 2025
ced12b2
test
wesley-kami Aug 7, 2025
8a11839
Merge branch 'main' into feature/DetecteurCryptoOrchestrateur
wesley-kami Aug 7, 2025
d18e690
finalisation de l'intégration mission1 + console plus de stress
wesley-kami Aug 7, 2025
49082ed
Merge branch 'feature/DetecteurCryptoOrchestrateur' of https://github…
wesley-kami Aug 7, 2025
87ec604
Merge branch 'main' into feature/DetecteurCryptoOrchestrateur
wesley-kami Aug 8, 2025
07ecc0b
Merge branch 'main' of https://github.com/mouwaficbdr/CryptoForensic-…
e-mandy Aug 8, 2025
880d922
Intégration de l'AesGcmAnalyzer dans l'orchestrateur
e-mandy Aug 8, 2025
1bef18c
Initialisation des test de l'algo de blowfish
e-mandy Aug 8, 2025
87b58cd
Mise en place des tests unitaires en rapport avec l'analyzer Blowfish
e-mandy Aug 9, 2025
98be21d
Correction des erreurs liées au tests unitaires de l'analyzer Blowfish
e-mandy Aug 9, 2025
54e93dc
Commit 2spi
e-mandy Aug 11, 2025
8eca68d
Merge des changement apportés sur le main
e-mandy Aug 12, 2025
9fe04a5
Ajout de la documentation en rapport avec l'analyzer Blowfish
e-mandy Aug 12, 2025
62972c6
Fusion pour récupération des derniers tests
e-mandy Aug 12, 2025
c8f8c9c
Merge branch 'main' of https://github.com/mouwaficbdr/CryptoForensic-…
e-mandy Aug 12, 2025
b51a6de
New interface 2
e-mandy Aug 12, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/analyzers/blowfish_analyzer.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
import sys
import os
from ..utils import calculer_entropie
import hashlib
from src.crypto_analyzer import CryptoAnalyzer
from cryptography.hazmat.primitives.ciphers import algorithms, Cipher, modes
from src.crypto_analyzer import CryptoAnalyzer
from src.utils import calculer_entropie
import hashlib
import base64
import re
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
from cryptography.hazmat.primitives.padding import PKCS7
sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
class Blowfish_Analyzer(CryptoAnalyzer):
'''Détermine si l'algo blowfish est utilisé, génère des clés et tente de de déchffrer un fichier chiffré en utilisant les clés générées.

Expand Down Expand Up @@ -95,6 +102,12 @@ def __filtrer_dictionnaire_par_indices(self, chemin_dictionnaire: str) -> list[s
"""
Filtre le dictionnaire en se basant sur les indices de la mission 3.
L'indice pointe vers un format de clé "sha + nombre + chiffres simples".

Args:
chemin_dictionnaire (str): Chemin du dictionnaire sur lequel on effectue la recherche des potentielles mots clés

Return:
list[str]: La liste de tous les mots en chaine de caractères, susceptibles d'être des mots clés parmi ceux du dictionnaire fourni.
"""
mots_filtres: list[str] = []
prefixes = ("sha256", "sha384", "sha512", "sha1")
Expand Down
14 changes: 8 additions & 6 deletions src/interface_console.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,24 +112,26 @@ def menu_2(self):
self.dynamiqueText("Mission complète automatique","green")
self.dynamiqueText("Veuillez entrer le chemin du dossier :","white")
time.sleep(0.02)

chemin_dossier = self.prompt.ask("Veuillez entrer le chemin du dossier : ")
pad = 0
while pad < self.calc_center("data"):
print(" ",end='')
pad+=1

chemin_dossier = self.prompt.ask("")
resultat = DetecteurCryptoOrchestrateur().mission_complete_automatique(chemin_dossier, "keys/wordlist.txt")
print(line for line in resultat)
# self.console.clear()
self.dynamiqueText("Mission en cours...","green")
time.sleep(0.02)
# self.console.clear()
self.dynamiqueText("Mission terminée","green")

esc=input("Veuillez appuyer sur la touche entrer pour retourner au menu principal")
time.sleep(0.02)

if esc=="":
self.default_menu()
else : self.default_menu()

# self.default_menu()

def menu_3(self):
self.console.clear()
Expand Down
2 changes: 1 addition & 1 deletion src/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,4 +170,4 @@ def rangerDico() -> None:
print('Fichier non trouvé.')
# rangerDico()

# print(verifier_texte_dechiffre("je talk !a mamamia:?\n"))
# print(verifier_texte_dechiffre("je talk !a mamamia:?\n"))
Binary file modified tests/fichiers_pour_tests/aes_gcm_invalide.enc
Binary file not shown.
2 changes: 1 addition & 1 deletion tests/fichiers_pour_tests/fernet_invalide.enc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
gAAAAABom24z2UB76X6M0GTn1-vuLLV1lsnxXXsrQ4uOwMoTq-DN7TBUzu_UabYkm2lzQb5tc62SXzplAkZTpw95noj1FtLPsWb54dEXIPgUM8-7r-OaKz4Lr2g75FtQaMxNFw8XOcZgSpL_7vOxtBfg1YD_9dl-iQ==
gAAAAABom24z2UB76X6M0GTn1-vuLLV1lsnxXXsrQ4uOwMoTq-DN7TBUzu_UabYkm2lzQb5tc62SXzplAkZTpw95noj1FtLPsWb54dEXIPgUM8-7r-OaKz4Lr2g75FtQaMxNFw8XOcZgSpL_7vOxtBfg1YD_9dl-iQ==
Empty file.
1 change: 1 addition & 0 deletions tests/fichiers_pour_tests/mission3_valide.enc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
��%���)$OO�}�
49 changes: 49 additions & 0 deletions tests/test_analyzers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@
import sys
import hashlib
from cryptography.hazmat.primitives.ciphers.aead import ChaCha20Poly1305
from Crypto.Cipher import Blowfish
from struct import pack

from cryptography.hazmat.primitives.ciphers.aead import AESGCM
from cryptography.fernet import Fernet
from pathlib import Path
sys.path.append(os.path.join(os.path.dirname(__file__), '..'))

from src.analyzers.aes_cbc_analyzer import Aes_Cbc_Analyzer
from src.analyzers.chacha20_analyzer import ChaCha20_Analyzer
from src.analyzers.blowfish_analyzer import Blowfish_Analyzer
from src.analyzers.aes_gcm_analyzer import Aes_Gcm_Analyzer
from src.analyzers.fernet_analyzer import FernetAnalyzer

Expand Down Expand Up @@ -116,6 +120,51 @@ def test_chacha20_dechiffrer_fichier_non_existant(self):
cle_valide = self.cle_test_chacha
with self.assertRaises(FileNotFoundError):
self.analyser_chacha.dechiffrer("chemin_invalide.enc", cle_valide)


class BlowfishAnalyzerTester(TestCase):

"""
Cette classe contient les différents tests éffectués sur les méthodes en rapport avec l'analyzer Blowfish
"""

def setUp(self):
# Initialisation de la classe Blowfish_Analyzer pour les tests des méthodes de cette dernière
self.analyzer = Blowfish_Analyzer()
# Fichier invalide pour les tests d'exceptions et de résultat d'erreur
self.fichier_crypte_invalide = "tests/fichiers_pour_tests/mission3_invalide.enc"
self.fichier_crypte_valide = "tests/fichiers_pour_tests/mission3_valide.enc"
self.fichier_dictionnaire = "./keys/wordlist.txt"
self.key = b'This is 2 blowfish algorithm key'
self.mot_a_trouver = b'zertyuiopqsdfghjklmwxcvbn,;&1234567890iubdo,cap!=)"_'

# def test_identifier_algo(self):
# self.assertAlmostEqual(self.analyzer.identifier_algo(self.fichier_crypte_invalide), 0.0)
# self.assertAlmostEqual(self.analyzer.identifier_algo(self.fichier_crypte_valide), 0.7)

def test_generer_cles_candidates(self):
# Dans ce cas, on a un dictionnaire qui contient des valeurs qui ne cadrent pas
# avec notre fichier de test, donc la génération renverra une liste vide
self.assertNotEqual(self.analyzer.generer_cles_candidates(self.fichier_dictionnaire), [])

def test_dechiffrer_taille_cle_invalide(self):
# On tente de lever l'exception ValueError en renseignant une clé ne respectant
# l'intervalle pour la taille requise
invalide_key = b'\x00'
with self.assertRaises(ValueError):
self.analyzer.dechiffrer(self.fichier_crypte_valide, invalide_key)

def test_dechiffrer_fichier_introuvable(self):
# Vérification de l'exception FileNotFoundError
with self.assertRaises(FileNotFoundError):
self.analyzer.dechiffrer('dohi.txt', self.key)

def test_dechiffrer_fichier(self):
# Déchiffrement du fichier valide en utilisant la bonne clé
self.assertEqual(self.analyzer.dechiffrer(self.fichier_crypte_valide, self.key), self.mot_a_trouver)

# Cas où la valeur de sortie ne correspond à celle attendue
self.assertNotEqual(self.analyzer.dechiffrer(self.fichier_crypte_valide, self.key), b'Dohi 1 fois')

class AesGcmTester(TestCase) :
_wordlist = "keys/wordlist.txt"
Expand Down