diff --git a/README.md b/README.md index e06d647..84e2113 100644 --- a/README.md +++ b/README.md @@ -54,17 +54,17 @@ pip install -r requirements.txt 1. Basic Network Scan: ```bash -python network_scanner.py 192.168.1.0/24 +python src/network_scanner.py 192.168.1.0/24 ``` 2. Advanced Scan with Custom Ports: ```bash -python network_scanner.py 192.168.1.0/24 -s 2 -p 80 443 3389 8080 +python src/network_scanner.py 192.168.1.0/24 -s 2 -p 80 443 3389 8080 ``` 3. Full Security Assessment: ```bash -python network_scanner.py 192.168.1.0/24 --security-check --format json +python src/network_scanner.py 192.168.1.0/24 --security-check --format json ``` ### Command Line Arguments diff --git a/requirements.txt b/requirements.txt index 834f1a1..b580954 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,3 +6,4 @@ tqdm>=4.66.1 colorama>=0.4.6 texttable>=1.7.0 argparse>=1.4.0 +cryptography>=3.4.7 diff --git a/network_scanner.py b/src/network_scanner.py similarity index 94% rename from network_scanner.py rename to src/network_scanner.py index 7b9b11b..b0f3c62 100644 --- a/network_scanner.py +++ b/src/network_scanner.py @@ -24,6 +24,7 @@ import random import os import shutil +from cryptography.fernet import Fernet # Initialize colorama for cross-platform colored output init() @@ -277,6 +278,27 @@ def save_results(self, format: str = "csv"): print(f"\n{Fore.GREEN}Results saved to: {filename}{Style.RESET_ALL}") + # Encrypt the results file + self.encrypt_file(filename) + + def encrypt_file(self, filename: str): + key = Fernet.generate_key() + cipher_suite = Fernet(key) + + with open(filename, 'rb') as file: + file_data = file.read() + + encrypted_data = cipher_suite.encrypt(file_data) + + with open(filename, 'wb') as file: + file.write(encrypted_data) + + key_filename = f"{filename}.key" + with open(key_filename, 'wb') as key_file: + key_file.write(key) + + print(f"\n{Fore.GREEN}Results encrypted. Encryption key saved to: {key_filename}{Style.RESET_ALL}") + def parse_arguments(): parser = argparse.ArgumentParser( description='Enhanced Network Scanner', diff --git a/scanner_logging.py b/src/scanner_logging.py similarity index 100% rename from scanner_logging.py rename to src/scanner_logging.py diff --git a/security_checks.py b/src/security_checks.py similarity index 99% rename from security_checks.py rename to src/security_checks.py index 2295ff9..674fdeb 100644 --- a/security_checks.py +++ b/src/security_checks.py @@ -6,6 +6,7 @@ import requests from concurrent.futures import ThreadPoolExecutor import nmap +from src.scanner_logging import SecurityLogger class SecurityChecker: def __init__(self, logger):