IctAchievers's picture
Upload 19 files
43ecebd verified
"""
Network Intrusion Detection System
"""
import time
import random
from datetime import datetime
class NetworkIntrusionDetector:
def __init__(self):
self.initialized = False
self.monitoring = False
... def initialize(self):
... """Initialize NIDS"""
... print("Initializing Network Intrusion Detection System...")
... time.sleep(1) # Simulate initialization
... self.initialized = True
... print("NIDS initialized successfully")
...
... def monitor(self):
... """Monitor network traffic for suspicious activity"""
... if not self.initialized:
... return []
...
... # Simulate network events
... events = []
...
... # Random chance of generating events
... if random.random() < 0.1: # 10% chance per check
... event_type = random.choice(['network_traffic', 'suspicious_connection', 'port_scan'])
...
... if event_type == 'network_traffic':
... events.append({
... 'type': 'network_traffic',
... 'timestamp': datetime.now().isoformat(),
... 'interface': random.choice(['eth0', 'wlan0']),
... 'traffic_mbps': random.randint(50, 500),
... 'destination_ip': f"192.168.1.{random.randint(1, 254)}"
... })
... elif event_type == 'suspicious_connection':
... events.append({
... 'type': 'suspicious_connection',
... 'timestamp': datetime.now().isoformat(),
... 'source_ip': f"10.0.0.{random.randint(1, 254)}",
... 'destination_ip': f"192.168.1.{random.randint(1, 254)}",
... 'port': random.randint(1024, 65535),
... 'protocol': random.choice(['TCP', 'UDP'])
... })
...
... return events