Skip to content

Repository files navigation

Packet Defender Logo

๐Ÿ›ก๏ธ Packet Defender

A high-fidelity cyber defense simulation game built with Python & Pygame
Defend critical infrastructure against real-world cyber attacks in real time.

Python Pygame Scapy Platform License


๐Ÿ“– Overview

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.


โœจ Key Features

๐ŸŽฎ Core Gameplay

  • 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.json across sessions

๐Ÿ”ฅ Attack Simulation

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

๐Ÿ›ก๏ธ Defense Engine

  • 17 Toggleable Firewall Rules across 4 security tiers
  • Real iptables Integration โ€” 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

๐Ÿ“Š Advanced Monitoring

  • 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

๐Ÿ† Gamification

  • 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

๐ŸŒ Web Deployment

  • Pygbag Integration โ€” Play directly in the browser via WebAssembly (index.html)
  • Pre-built .apk and .tar.gz archives for web distribution

๐Ÿ“ Reporting & Logging

  • 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

๐Ÿ” Threat Intelligence

  • 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

๐Ÿ—๏ธ Architecture

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

๐Ÿš€ Getting Started

Prerequisites

Requirement Details
Python 3.10 or higher
OS Kali Linux (recommended for full features)
Root Access Required for real packet capture & iptables rule management

Installation

# 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 reportlab

Running the Game

๐ŸŽฎ Simulation Mode (Default โ€” No root required)

python main.py

Uses generated packets for a safe demo/presentation experience.

๐Ÿ”ฌ Real Capture Mode (Kali Linux)

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.

๐ŸŒ Play in Browser

Open index.html in a web server to play via Pygbag WebAssembly runtime.


๐ŸŽฎ Controls

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

๐ŸŽฏ How It Works

                    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
   Packets โ”€โ”€โ”€โ”€โ”€โ”€โ–บ  โ”‚  ROUTER  โ”‚
   (Real/Sim)       โ””โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”˜
                         โ”‚
                         โ–ผ
                    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                    โ”‚ FIREWALL โ”‚โ—„โ”€โ”€โ”€โ”€โ”‚ 17 Defense Rules โ”‚
                    โ””โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”˜     โ”‚ + Auto-Defense   โ”‚
                         โ”‚           โ”‚ + Manual Block   โ”‚
             โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
             โ”‚                  โ”‚
        โœ… Blocked         โŒ Passed
        (+Score)               โ”‚
                               โ–ผ
                          โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                          โ”‚  SERVER  โ”‚  โ—„โ”€โ”€ Health: 100 HP
                          โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                          (Takes Damage)
  1. Packets spawn from the left (real captured or simulated)
  2. Travel through network nodes โ€” Workstation โ†’ Router โ†’ Firewall โ†’ Server
  3. Firewall inspects each packet against enabled rules
  4. Blocked packets award score; leaked packets damage the server
  5. Server health reaches 0 โ†’ Game Over | All 3 waves cleared โ†’ Victory

๐Ÿ“ธ Game Screens

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

๐Ÿ› ๏ธ Configuration

All settings are centralized in config.py:

  • SIMULATION_MODE โ€” True for demo, False for real capture
  • DEBUG_MODE โ€” Enable verbose console output
  • NETWORK_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

๐Ÿงฐ Tech Stack

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

Team 7 โ€” CSI Project Expo


๐Ÿ“„ License

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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages