How akazayh/cyber-guard works
CyberGuard is a single Python 3.8+ security toolkit organized as a menu-driven CLI application. The repository is small but split into clear functional modules under CyberGuard/modules, with main.py acting as the entrypoint and orchestration layer.
1. Top-level architecture
- main.py is the user-facing controller: it presents the main menu, routes the user into one of the security tools, and likely coordinates return-to-menu behavior.
- The rest of the repo is a set of feature modules that are mostly independent: network scanning, IDS monitoring, log analysis, and firewall management.
2. Primary interaction model
- This is not a client-server app; it is an interactive local tool.
- The architecture is a command-dispatch loop: user input selects a subsystem, the subsystem performs privileged system/network actions, then results are shown in the terminal and/or written to files.
3. Network scanning subsystem
- modules/network_scaner.py encapsulates the Nmap-based scanning workflow.
- It handles different scan modes, port targeting, service/version detection, and more advanced scan styles such as stealth/aggressive/vulnerability-oriented scans.
- Its output is not only terminal text; scan results are persisted into an archive directory (Archives_Nmap/ per the README), which makes scanning both interactive and auditable.
4. Intrusion detection subsystem
- modules/ids.py is the live monitoring engine.
- It is responsible for real-time traffic observation on wired and wireless interfaces, classifying suspicious activity, and generating alerts for events like ARP/DNS spoofing, floods, port scanning, and some wireless attack patterns.
- This module appears to sit closest to raw network traffic, likely acting as the highest-privilege and most time-sensitive part of the system.
5. IDS output and logging flow
- The IDS does not just alert in memory; it also writes session data to logs and PCAP traces.
- That creates a clear pipeline: packet capture / observation -> detection logic -> live terminal alerts -> persisted forensic artifacts.
- Those artifacts become the input for the log analysis subsystem.
6. Log analysis subsystem
- modules/analyze_logs.py is the offline analysis layer.
- It consumes IDS-generated logs and possibly other supported log sources, then searches for patterns, anomalies, and notable security events.
- This is a boundary between live detection and retrospective investigation: unlike the IDS, it works on stored evidence rather than live traffic.
7. Firewall management subsystem
- modules/firewall_manger.py controls local firewall policy on the host.
- It exposes actions for blocking/unblocking IPs, managing ports and port ranges, and filtering protocols such as TCP, UDP, and ICMP.
- The README’s “rule persistence” implies this module also touches system configuration so rules survive reboots, making it a host-level enforcement component rather than just a temporary session tool.
8. Shared support code
- modules/utils.py is the cross-cutting support layer.
- In a repo like this, that typically means shared formatting, validation, I/O helpers, terminal presentation, and common state handling used by the feature modules.
- This module is the likely place where UI consistency and repeated logic are centralized so the four main tools remain decoupled.
9. External dependencies and runtime constraints
- The app is Linux-oriented and requires root/sudo privileges, which is a major architectural constraint.
- The README explicitly calls out nmap, iptables, and beep; those are system-level dependencies that directly influence how the modules operate.
- The tool is therefore tightly bound to the local OS networking stack and firewall, not just Python libraries.
10. Artifacts and persistence
- Key artifacts include Nmap archives, IDS logs, PCAP captures, and persistent firewall rules.
- These files form the project’s main data boundary: live system events are transformed into stored evidence, then later read back by the analyzer.
- That persistence is what makes the toolkit useful for both immediate response and later forensic review.
11. Security/privilege boundary
- CyberGuard is explicitly an authorized-admin tool, not a passive viewer.
- Its most sensitive operations cross from user-space Python into privileged system operations: packet monitoring, firewall rule changes, and network scanning with advanced techniques.
- For an architecture diagram, this is an important boundary to show between the CLI app and the host OS/network stack.
12. Overall system decomposition
- You can think of the repo as four user-facing capabilities wrapped by one CLI shell:
- active reconnaissance,
- live intrusion detection,
- offline log forensics,
- local firewall enforcement.
- The modules are connected mainly through shared UI conventions and persisted artifacts, not through a complex internal service graph.
Main entry points: main.py Main menu · ids.py IDS monitor · network_scaner.py Network scan · firewall_manger.py Firewall manager
Components 15
CLI shell
Interactive menu and shared presentation layer
- Main menu · Menu-driven controller that routes users to each tool
CyberGuard/main.py - Shared utils · Common formatting, validation, and I/O helpers shared across modules
CyberGuard/modules/utils.py - Terminal I/O · User-facing command loop and console output surface
Security tools
Core operational modules for scanning, detection, analysis, and enforcement
- Network scan · Nmap-based scanning workflows and scan modes
CyberGuard/modules/network_scaner.py - IDS monitor · Live network observation and suspicious-activity detection
CyberGuard/modules/ids.py - Log analysis · Offline analysis of IDS logs and related evidence
CyberGuard/modules/analyze_logs.py - Firewall manager · Host firewall actions for blocking, ports, and protocol filtering
CyberGuard/modules/firewall_manger.py
Artifacts
Persisted evidence and policy state produced or consumed by the tools
- Nmap archive · Persisted scan results for later review
- IDS logs · Session logs written by live monitoring
- PCAP traces · Packet capture files used for forensic review
- Firewall rules · Persisted host firewall configuration
Host stack
External system capabilities and OS-level dependencies
- OS network stack · Local kernel and networking facilities accessed by the toolkit
- Nmap · External scanner used by the network scan module
- iptables · External firewall control interface
- beep · Audible alert dependency used by monitoring workflows
Connections 22
- Main menu → Terminal I/O: drives · Presents menu and routes user choices
- Main menu → Network scan: dispatches · Launches the scanning workflow
- Main menu → IDS monitor: dispatches · Launches live monitoring
- Main menu → Log analysis: dispatches · Launches offline analysis
- Main menu → Firewall manager: dispatches · Launches firewall management
- Main menu → Shared utils: uses · Shares common helpers and UI conventions
- Network scan → Shared utils: uses · Shared formatting and input/output helpers
- IDS monitor → Shared utils: uses · Shared helpers for alerts and presentation
- Log analysis → Shared utils: uses · Shared helpers for reporting and parsing
- Firewall manager → Shared utils: uses · Shared helpers for host-policy actions
- Network scan → Nmap: invokes · Runs external scanning commands
- Network scan → Nmap archive: writes · Persists scan output for later review
- IDS monitor → OS network stack: observes · Monitors live traffic on the local network stack
- IDS monitor → IDS logs: writes · Stores detection sessions and alerts
- IDS monitor → PCAP traces: captures · Produces packet capture artifacts
- IDS monitor → beep: alerts · May emit audible warnings
- Log analysis → IDS logs: reads · Consumes IDS session logs
- Log analysis → PCAP traces: reads · Uses captured traces as forensic evidence
- Firewall manager → iptables: controls · Applies host firewall rules through system tooling
- Firewall manager → Firewall rules: persists · Maintains rule state across sessions or reboot
- Firewall manager → OS network stack: enforces · Interacts with kernel-level packet filtering
- Network scan → OS network stack: probes · Performs network reconnaissance against local interfaces and targets