From da5c573366c08983e5e8526678657c50f560508b Mon Sep 17 00:00:00 2001 From: mouwaficbdr Date: Sun, 10 Aug 2025 17:20:44 +0100 Subject: [PATCH 1/3] Update gitignore --- .gitignore | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.gitignore b/.gitignore index 26c0be2..bbfc889 100644 --- a/.gitignore +++ b/.gitignore @@ -26,3 +26,7 @@ Thumbs.db .pytest_cache/ .coverage htmlcov/ + +# Mouwafic + +files/ \ No newline at end of file From e1773ef4e7418521be85f9943c8fb8b8fac01765 Mon Sep 17 00:00:00 2001 From: mouwaficbdr Date: Sun, 10 Aug 2025 17:21:40 +0100 Subject: [PATCH 2/3] add: Fichier run_tests.py qui run tous les tests et donne le feedback --- run_tests.py | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 run_tests.py diff --git a/run_tests.py b/run_tests.py new file mode 100644 index 0000000..8cad359 --- /dev/null +++ b/run_tests.py @@ -0,0 +1,65 @@ +#!/usr/bin/env python3 +""" +Script pour exécuter tous les tests du projet +""" + +import sys +import os +import subprocess + +def run_test_file(test_file): + """Exécute un fichier de test""" + print(f"\nExécution de {test_file}") + print("=" * 50) + + try: + # Ajouter le répertoire racine au path + sys.path.insert(0, os.path.dirname(__file__)) + + # Exécuter le test + result = subprocess.run([sys.executable, test_file], + capture_output=True, text=True, cwd=os.path.dirname(__file__)) + + if result.returncode == 0: + print("✅ Tests réussis") + print(result.stdout) + else: + print("❌ Tests échoués") + print(result.stdout) + print(result.stderr) + + return result.returncode == 0 + + except Exception as e: + print(f"❌ Erreur lors de l'exécution: {e}") + return False + +def main(): + """Exécute tous les tests disponibles""" + print("Lancement des tests du projet CryptoForensic") + print("=" * 60) + + tests = [ + "tests/test_global.py", + "tests/test_analyzers.py" + ] + + success_count = 0 + total_count = len(tests) + + for test_file in tests: + if os.path.exists(test_file): + if run_test_file(test_file): + success_count += 1 + else: + print(f"⚠️ Fichier de test non trouvé: {test_file}") + + print(f"\nRésumé: {success_count}/{total_count} tests réussis") + + if success_count == total_count: + print("Résultat:Tous les tests passent !") + else: + print("Résultat: Certains tests ont échoué") + +if __name__ == "__main__": + main() From f7e6858fd713370eaa41049f0143b0e2abc6e1a1 Mon Sep 17 00:00:00 2001 From: mouwaficbdr Date: Sun, 10 Aug 2025 17:22:20 +0100 Subject: [PATCH 3/3] =?UTF-8?q?fix:=20Standardisation=20uniforme=20de=20to?= =?UTF-8?q?us=20les=20imports=20pour=20uniformit=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/analyzers/aes_cbc_analyzer.py | 4 ++-- src/analyzers/aes_gcm_analyzer.py | 2 +- src/analyzers/blowfish_analyzer.py | 4 ++-- src/analyzers/chacha20_analyzer.py | 5 ++--- src/analyzers/fernet_analyzer.py | 2 +- src/detecteur_crypto.py | 12 ++++++------ tests/test_analyzers.py | 1 - 7 files changed, 14 insertions(+), 16 deletions(-) diff --git a/src/analyzers/aes_cbc_analyzer.py b/src/analyzers/aes_cbc_analyzer.py index 7512dcc..8c0b7ac 100644 --- a/src/analyzers/aes_cbc_analyzer.py +++ b/src/analyzers/aes_cbc_analyzer.py @@ -1,5 +1,5 @@ -from ..crypto_analyzer import CryptoAnalyzer -from ..utils import calculer_entropie +from src.crypto_analyzer import CryptoAnalyzer +from src.utils import calculer_entropie from cryptography.hazmat.primitives.kdf.pbkdf2 import PBKDF2HMAC from cryptography.hazmat.primitives import hashes from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes diff --git a/src/analyzers/aes_gcm_analyzer.py b/src/analyzers/aes_gcm_analyzer.py index 460f376..e74b1f7 100644 --- a/src/analyzers/aes_gcm_analyzer.py +++ b/src/analyzers/aes_gcm_analyzer.py @@ -1,4 +1,4 @@ -from ..crypto_analyzer import CryptoAnalyzer +from src.crypto_analyzer import CryptoAnalyzer from cryptography.hazmat.primitives.kdf.pbkdf2 import PBKDF2HMAC from cryptography.hazmat.primitives import hashes import re diff --git a/src/analyzers/blowfish_analyzer.py b/src/analyzers/blowfish_analyzer.py index 8188db5..0a1973a 100644 --- a/src/analyzers/blowfish_analyzer.py +++ b/src/analyzers/blowfish_analyzer.py @@ -1,5 +1,5 @@ -from ..detecteur_crypto import CryptoAnalyzer -from ..utils import calculer_entropie +from src.crypto_analyzer import CryptoAnalyzer +from src.utils import calculer_entropie import hashlib from cryptography.hazmat.primitives.ciphers import algorithms, Cipher, modes from cryptography.hazmat.primitives.padding import PKCS7 diff --git a/src/analyzers/chacha20_analyzer.py b/src/analyzers/chacha20_analyzer.py index 725e0dc..283dcc9 100644 --- a/src/analyzers/chacha20_analyzer.py +++ b/src/analyzers/chacha20_analyzer.py @@ -7,9 +7,8 @@ import sys from typing import List -sys.path.append(os.path.join(os.path.dirname(__file__), '..')) -from crypto_analyzer import CryptoAnalyzer -from utils import calculer_entropie +from src.crypto_analyzer import CryptoAnalyzer +from src.utils import calculer_entropie # Définition de la classe ChaCha20_Analyzer class ChaCha20_Analyzer(CryptoAnalyzer): diff --git a/src/analyzers/fernet_analyzer.py b/src/analyzers/fernet_analyzer.py index cf13bdf..8dbe747 100644 --- a/src/analyzers/fernet_analyzer.py +++ b/src/analyzers/fernet_analyzer.py @@ -5,7 +5,7 @@ from cryptography.fernet import Fernet from typing import List -from ..crypto_analyzer import CryptoAnalyzer +from src.crypto_analyzer import CryptoAnalyzer class FernetAnalyzer(CryptoAnalyzer): """ diff --git a/src/detecteur_crypto.py b/src/detecteur_crypto.py index 3dd1f5a..fb36344 100644 --- a/src/detecteur_crypto.py +++ b/src/detecteur_crypto.py @@ -4,14 +4,14 @@ from typing import List, Union # Import des modules d'analyse -from analyzers.aes_cbc_analyzer import Aes_Cbc_Analyzer -from crypto_analyzer import CryptoAnalyzer -from analyzers.chacha20_analyzer import ChaCha20_Analyzer -from analyzers.blowfish_analyzer import Blowfish_Analyzer -from analyzers.aes_gcm_analyzer import Aes_Gcm_Analyzer +from src.analyzers.aes_cbc_analyzer import Aes_Cbc_Analyzer +from src.crypto_analyzer import CryptoAnalyzer +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 # Import des modules utilitaries -from utils import est_dechiffre +from src.utils import est_dechiffre class ResultatAnalyse: """ diff --git a/tests/test_analyzers.py b/tests/test_analyzers.py index a7f5379..7205a78 100644 --- a/tests/test_analyzers.py +++ b/tests/test_analyzers.py @@ -5,7 +5,6 @@ from cryptography.hazmat.primitives.ciphers.aead import ChaCha20Poly1305 sys.path.append(os.path.join(os.path.dirname(__file__), '..')) -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