0a05f009e8
Core framework (8 files in core/) + BaseModule ABC (2 files in modules/): - bus.py: Multiprocess-safe pub/sub event bus using mp.Queue with background dispatcher thread, 20 canonical event types - state.py: SQLite persistent state with WAL mode, dedicated writer thread with 500ms coalesce, module status + generic key-value store - engine.py: Module lifecycle manager with multiprocess model, dependency resolution (topological sort), hardware tier detection (opi_zero3/pi_zero/generic), resource budgeting, scope enforcement, engagement phase gating - capture_bus.py: Single AF_PACKET socket packet demux with per-module subscriber queues, BPF filter matching, drop-oldest backpressure - tool_manager.py: Subprocess lifecycle for external tools (bettercap/tcpdump/Responder/mitmproxy/ntlmrelayx) with exponential backoff restart, /proc resource monitoring, process disguise via prctl, health check callbacks, graceful SIGTERM->SIGKILL shutdown - scheduler.py: Cron-like task scheduler with jitter, thread pool execution, enable/disable/run_now controls - resource_monitor.py: System + per-process RAM/CPU/disk/thermal monitoring, OOM kill lowest-priority module, thermal shedding at 70C - kill_switch.py: 7-phase wipe sequence (stop procs, corrective ARP, LUKS destroy, shred keys, zero-fill, clear RAM, reboot), boot flag for interrupted wipe resume, dead man's switch - modules/base.py: BaseModule ABC with start/stop/status/configure/health_check interface contract
58 lines
1.6 KiB
Python
58 lines
1.6 KiB
Python
#!/usr/bin/env python3
|
|
"""Abstract base class for all BigBrother modules."""
|
|
|
|
from abc import ABC, abstractmethod
|
|
|
|
|
|
class BaseModule(ABC):
|
|
"""Base class that all BigBrother modules must inherit from.
|
|
|
|
Each module runs as a separate process managed by the Engine.
|
|
"""
|
|
|
|
name: str = "unnamed"
|
|
module_type: str = "passive" # passive, active, stealth, intel, connectivity
|
|
priority: int = 100 # OOM priority (lower = more important)
|
|
dependencies: list = [] # Module names that must be running first
|
|
requires_root: bool = False
|
|
|
|
def __init__(self, bus, state, config, engine=None):
|
|
self.bus = bus
|
|
self.state = state
|
|
self.config = config
|
|
self.engine = engine
|
|
self._running = False
|
|
self._pid = None
|
|
self._start_time = None
|
|
|
|
@abstractmethod
|
|
def start(self) -> None:
|
|
"""Start the module. Called by the engine in the module's own process."""
|
|
...
|
|
|
|
@abstractmethod
|
|
def stop(self) -> None:
|
|
"""Stop the module gracefully."""
|
|
...
|
|
|
|
@abstractmethod
|
|
def status(self) -> dict:
|
|
"""Return module status dict.
|
|
|
|
Returns:
|
|
{"running": bool, "pid": int, "uptime": float, "ram_mb": float, "cpu_pct": float}
|
|
"""
|
|
...
|
|
|
|
@abstractmethod
|
|
def configure(self, config: dict) -> None:
|
|
"""Apply new configuration to a running module."""
|
|
...
|
|
|
|
def health_check(self) -> bool:
|
|
"""Check if the module is healthy. Override for custom checks."""
|
|
try:
|
|
return self.status().get("running", False)
|
|
except Exception:
|
|
return False
|