A high-fidelity cyber defense simulation game built with Python & Pygame
Defend critical infrastructure against real-world cyber attacks in real time.
Packet Defender puts you in the role of a Network Security Officer tasked with defending a simulated corporate network against waves of sophisticated cyber attacks. The game features real-time packet visualization, a configurable firewall engine with real iptables integration, and an engaging educational experience that bridges the gap between interactive gaming and cybersecurity training.
โก Built for the CSI Project Expo Competition โ designed to educate, engage, and demonstrate core cybersecurity concepts in a gamified environment.
- 3-Wave Campaign โ Progressive difficulty across Initial Probe, Coordinated Strike, and Advanced Threat waves
- Manual Click-to-Block โ Intercept hostile packets in real time by clicking them
- Auto-Defense Mode โ Toggle AI-assisted blocking (uses CPU resources)
- Resource Management โ Monitor CPU and RAM to prevent system overload
- Score & Combo System โ Earn points, chain combos, and unlock multipliers
- High Score Persistence โ Scores saved to
scores.jsonacross sessions
| Attack Type | Protocol | Severity |
|---|---|---|
| SYN Flood | TCP | ๐ด Critical |
| DDoS | Multi | ๐ด Critical |
| Port Scan | TCP | ๐ก Medium |
| Brute Force | SSH | ๐ High |
| DNS Spoofing | UDP | ๐ High |
| SQL Injection | HTTP | ๐ High |
| Ping Flood | ICMP | ๐ก Medium |
| Malware Delivery | TCP | ๐ด Critical |
| Slowloris | HTTP | ๐ก Medium |
| DNS Amplification | UDP | ๐ High |
- 17 Toggleable Firewall Rules across 4 security tiers
- Real
iptablesIntegration โ When running as root on Linux, rules are applied to the actual system firewall - Smart Suggestion Engine โ Real-time tips based on current threats and disabled rules
- IP Blacklist/Whitelist System โ Pre-configured threat and trusted IP databases
- Live Threat Graph โ Real-time line graph tracking threat levels over time
- Network Heartbeat (ECG Monitor) โ Visual pulse monitor reflecting network health, with BPM and flatline detection
- Cyber News Ticker โ Scrolling breaking news feed with simulated threat alerts
- Live Terminal Feed โ Real-time security event log with color-coded entries
- Adaptive Threat Indicator โ Dynamic threat level display
- Boss Battle System โ Face named bosses like DDoS Lord, Malware King, and Botnet Queen
- Power-Up Collectibles โ Heal, 2x Score, Network Purge, Slow-Mo, and Auto-Block Satellite
- Intel Collectibles โ Gather intelligence items for bonus points
- Achievement System โ Unlock achievements for blocking milestones, wave clears, and more
- Post-Wave Reports โ Detailed performance breakdown after each wave
- Victory & Game Over Screens โ Comprehensive session statistics and replay option
- Pygbag Integration โ Play directly in the browser via WebAssembly (
index.html) - Pre-built
.apkand.tar.gzarchives for web distribution
- Session Logging โ All events timestamped and saved to
logs/directory - TXT & PDF Report Generation โ Professional post-session security reports via
reportlab - Crash Reports โ Automatic error logging to
crash_report.txt
- IP Reputation Checking โ Local database + optional AbuseIPDB API integration
- Geolocation Analysis โ IP-to-location mapping for threat visualization
- Result Caching โ Smart cache with TTL to minimize API calls
- Rate Limiter โ Prevents API rate limit violations
Packet Defender/
โโโ main.py # ๐ฎ Game engine & state machine (Menu โ Briefing โ Play โ Report โ Victory)
โโโ firewall.py # ๐ก๏ธ Defense engine, iptables controller, attack database, suggestion engine
โโโ packet_sniffer.py # ๐ก Real packet capture (Scapy) + simulation mode, IP classification
โโโ attack_simulator.py # ๐ Attack pattern generation (DDoS, SYN Flood, Brute Force, etc.)
โโโ sprites.py # ๐จ Packet sprites, network nodes, connection animators, particle effects
โโโ ui_components.py # ๐ฅ๏ธ Full UI system โ menus, HUD, panels, encyclopedia, reports (2300+ lines)
โโโ config.py # โ๏ธ Global settings, IP lists, color codes, protocol definitions
โโโ logger.py # ๐ Event logging with session management and file rotation
โโโ report_generator.py # ๐ TXT & PDF report generation with stats and achievements
โโโ threat_intel.py # ๐ IP reputation, caching, rate limiting, geolocation
โโโ advanced_features.py # ๐
Boss battles, power-up system, live threat graph
โโโ unique_features.py # ๐ Network heartbeat monitor, cyber news ticker
โโโ game_enhancements.py # ๐ฏ Wave system, score/combo mechanics, achievement tracking
โโโ index.html # ๐ Pygbag web deployment template
โโโ favicon.png # ๐ผ๏ธ Application icon
โโโ team-7.apk # ๐ฆ Pre-built web archive
โโโ team-7.tar.gz # ๐ฆ Compressed web archive
| Requirement | Details |
|---|---|
| Python | 3.10 or higher |
| OS | Kali Linux (recommended for full features) |
| Root Access | Required for real packet capture & iptables rule management |
# Clone the repository
git clone https://github.com/YOUR_USERNAME/Team-7.git
cd Team-7
# Install dependencies
pip install pygame scapy
# Optional: for PDF report generation
pip install reportlabpython main.pyUses generated packets for a safe demo/presentation experience.
Edit config.py and set SIMULATION_MODE = False, then:
# Kali Linux (run as root)
sudo python3 main.py
Captures real network traffic using Scapy and applies real iptables rules.
Open index.html in a web server to play via Pygbag WebAssembly runtime.
| Key | Action |
|---|---|
Click |
Block hostile packets / Collect items |
Space |
Pause / Resume |
F |
Open Firewall Configuration Panel |
I |
Open Attack Encyclopedia |
A |
Toggle Auto-Defense Mode |
Q |
Manual Block (all hostile packets) |
E |
Heal Server (+25 HP) |
C |
Network Purge (clear all packets) |
R |
Restart (on Victory/Game Over) |
Esc |
Close panels / Quit |
Scroll |
Scroll through logs and panels |
โโโโโโโโโโโโ
Packets โโโโโโโบ โ ROUTER โ
(Real/Sim) โโโโโโฌโโโโโโ
โ
โผ
โโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ
โ FIREWALL โโโโโโโ 17 Defense Rules โ
โโโโโโฌโโโโโโ โ + Auto-Defense โ
โ โ + Manual Block โ
โโโโโโโโโโโโโดโโโโโโโ โโโโโโโโโโโโโโโโโโโ
โ โ
โ
Blocked โ Passed
(+Score) โ
โผ
โโโโโโโโโโโโ
โ SERVER โ โโโ Health: 100 HP
โโโโโโโโโโโโ
(Takes Damage)
- Packets spawn from the left (real captured or simulated)
- Travel through network nodes โ Workstation โ Router โ Firewall โ Server
- Firewall inspects each packet against enabled rules
- Blocked packets award score; leaked packets damage the server
- Server health reaches 0 โ Game Over | All 3 waves cleared โ Victory
| Screen | Description |
|---|---|
| Main Menu | Start game with animated UI and packet legend |
| Mission Briefing | Wave objectives, attack types, and strategic hints |
| Gameplay HUD | Health bar, threat indicator, wave progress, stats, terminal, and action buttons |
| Firewall Panel | Toggle 17 rules across 4 tiers with effectiveness ratings |
| Attack Encyclopedia | Detailed info on each attack type with counters and explanations |
| Post-Wave Report | Damage taken, packets blocked, intel gathered, rules active |
| Victory Report | Final score, high score, stats breakdown |
| Game Over | Mission failure summary with replay option |
All settings are centralized in config.py:
SIMULATION_MODEโTruefor demo,Falsefor real captureDEBUG_MODEโ Enable verbose console outputNETWORK_INTERFACEโ Set your network adapter (eth0,wlan0,Wi-Fi, etc.)- IP Lists โ Customize
WHITELISTED_IPS,BLACKLISTED_IPS,SUSPICIOUS_IPS,SERVER_IPS - Packet Rates โ Tune
NORMAL_PACKET_RATE,ATTACK_PACKET_RATE,MAX_PACKET_RATE - Colors & Themes โ Full RGB color palette for protocols, threat levels, and UI
| Technology | Purpose |
|---|---|
| Python 3.10+ | Core language |
| Pygame | Game engine, rendering, input handling |
| Scapy | Real network packet capture and analysis |
| iptables | Linux firewall rule management |
| Pygbag | WebAssembly compilation for browser play |
| ReportLab | PDF report generation |
| Threading | Background packet capture |
Team 7 โ CSI Project Expo
This project was developed for educational and competition purposes as part of the CSI Project Expo.
โญ Star this repo if you found it interesting!
Built with ๐ป and โ by Team 7