CyberGuard - Cybersecurity Awareness Game
A free, interactive educational game to test and improve your cybersecurity awareness. Three engaging mini-games teach you about WiFi security, ethical hacking laws, and attack identification.
Features
Mobile & Desktop Optimized - Responsive design works perfectly on all devices No Backend Required - Pure client-side React application Three Educational Games:
- Free WiFi, Free Problems - Learn about public WiFi security
- Ethical Hacker or Jail - Understand cybersecurity laws in India
- Who Hacked You? - Identify different types of attacks
Completely Free - Host it anywhere, share with anyone
Debugging:
- Press F12 to open Developer Tools
- Go to Console tab to see errors
- Use
console.log()in the code to debug - Elements tab shows HTML structure
- Network tab shows file loads
How Each Game Works
Game 1: Free WiFi, Free Problems
Logic Flow:
1. Display WiFi location scenario
2. Show 2-3 WiFi network choices (some safe, some dangerous)
3. User clicks one choice
4. All consequences displayed with highlights:
- GREEN [SAFE] = Correct answer
- RED [DANGEROUS] = Wrong answer
5. User selected choice highlighted with yellow ring
6. 10 points awarded ONLY if they picked [SAFE]
7. Move to next location
Scoring: 4 questions × 10 points = 40 max points
Game 2: Ethical Hacker or Jail
Logic Flow:
1. Display ethical/legal scenario
2. User chooses: LEGAL or ILLEGAL
3. Show consequence + relevant Indian law
4. 15 points ONLY if they picked the right answer
5. Move to next scenario
Scoring: 5 questions × 15 points = 75 max points
Laws Covered:
- IT Act 2000 (Sections 63, 66, 66B, 66C)
- Copyright Act 1957
Key Files to Edit:
- Line ~230:
const ethicsGame = { scenarios: [ ... ] }
Game 3: Who Hacked You?
Logic Flow:
1. Display attack scenario
2. User selects attack type:
- Phishing
- Malware
- Keylogger
- Social Engineering
3. Show explanation + whether they're right
4. 20 points ONLY if correct
5. Move to next situation
Scoring: 5 questions × 20 points = 100 max points
Attack Types:
- Phishing: Fake websites/emails to steal credentials
- Malware: Malicious software on your device
- Keylogger: Software that records keystrokes
- Social Engineering: Human manipulation to get info
Component Reference
CyberGuardGame (Main Container)
- Job: Manages all game state and screen transitions
- Key Functions:
startGame()- Initialize gamehandleWifiChoice()- WiFi answer handlerhandleEthicsChoice()- Ethics answer handlerhandleHackingChoice()- Hacking answer handlerresetToHome()- Reset entire game
HomeScreen
- Job: Main menu, shows 3 game cards
- Props:
startGamefunction
WiFiGameScreen
- Job: Display WiFi scenario and choices
- Props:
location,score,maxScore,onChoice,onNext - State: Highlights selected choice with yellow ring
EthicsGameScreen
- Job: Display scenario, ask LEGAL/ILLEGAL
- Props:
scenario,score,maxScore,onChoice,onNext
HackingGameScreen
- Job: Display situation, ask attack type
- Props:
situation,score,maxScore,onChoice,onNext
EndScreen
- Job: Show final score, percentage, message
- Props:
score,maxScore,gameName - Calculates: Percentage and message based on score
Deployment After Changes
After editing main.html:
GitHub Pages:
git add main.html
git commit -m "Add new questions to WiFi game"
git push
# Wait 1-2 minutes, changes are live!
Vercel:
git add main.html
git commit -m "Bug fixes"
git push
# Check vercel.com, auto-deploys in 30 seconds!
Understanding the Code
The entire game is built in a single HTML file (main.html) using React and Tailwind CSS. No build process needed!
Code Structure:
main.html
├── <head>
│ ├── Meta tags & libraries (React, Babel, Tailwind)
│ └── <style> CSS styling
│
└── <body>
└── <script type="text/babel">
├── Game Data (wifiGame, ethicsGame, hackingGame)
├── Components
│ ├── CyberGuardGame (main controller)
│ ├── HomeScreen
│ ├── GameCard
│ ├── WiFiGameScreen
│ ├── EthicsGameScreen
│ ├── HackingGameScreen
│ └── EndScreen
└── ReactDOM render
Game Data Objects:
WiFi Game:
wifiGame = {
locations: [
{
id: 1,
name: "Cafe WiFi",
scenario: "...",
choices: [
{ text: "...", correct: true/false, consequence: "..." }
]
}
]
}
Ethics Game:
ethicsGame = {
scenarios: [
{
id: 1,
scenario: "...",
legal: true/false,
law: "Law reference",
consequenceRight: "...",
consequenceWrong: "..."
}
]
}
Hacking Game:
hackingGame = {
situations: [
{
id: 1,
situation: "...",
correctAnswer: "Attack Type",
options: ["Option1", "Option2", ...],
explanation: {
"Option1": "Explanation...",
"Option2": "Explanation..."
}
}
]
}
State Management (React Hooks):
const [screen, setScreen] = useState('home'); // Current screen
const [currentGame, setCurrentGame] = useState(null); // wifi/ethics/hacking
const [score, setScore] = useState(0); // Current score
const [maxScore, setMaxScore] = useState(0); // Total possible score
const [gameState, setGameState] = useState({}); // Current question index
const [showFeedback, setShowFeedback] = useState(false); // Show answer feedback
How the Game Works:
- User picks a game →
startGame(gameType)called - Sets maxScore based on game type (4×10=40 for WiFi, 5×15=75 for Ethics, 5×20=100 for Hacking)
- Displays current question from game data array
- User selects answer → Handler function (
handleWifiChoice,handleEthicsChoice,handleHackingChoice) called - Feedback shown with explanation
- Points awarded only if answer is correct
- Next question displayed or end screen if last question
- Final score shown as "Score/MaxScore" with percentage
Scoring System:
| Game | Per Correct | Max Score | Questions |
|---|---|---|---|
| WiFi | 10 points | 40 | 4 |
| Ethics | 15 points | 75 | 5 |
| Hacking | 20 points | 100 | 5 |
Points only awarded for correct answers only.
🔧 Customization
Change Game Content:
Edit the game data objects in main.html:
wifiGame.locations- WiFi scenariosethicsGame.scenarios- Ethics questionshackingGame.situations- Attack scenarios
Example: Add a new WiFi location:
{
id: 5,
name: "Library WiFi",
scenario: "You're studying at the public library...",
choices: [
{ text: "Connect to library WiFi", correct: false, consequence: "Hacker recorded your keystrokes." },
{ text: "Use VPN first", correct: true, consequence: "VPN protects you." }
]
}
Example: Add a new Ethics scenario:
{
id: 6,
scenario: "You found someone's password written on a note...",
legal: false,
law: "IT Act 2000",
consequenceWrong: "You're arrested.",
consequenceRight: "Report it to security."
}
Example: Add a new Hacking situation:
{
id: 6,
situation: "Someone sent you a file that looks suspicious...",
correctAnswer: "Malware",
options: ["Malware", "Phishing", "Keylogger", "Social Engineering"],
explanation: {
Malware: "CORRECT. Suspicious files often contain malware.",
Phishing: "Wrong. No fake login involved."
// ... etc
}
}
Change Colors:
Search for these in the <style> section:
#ffffff- White (main color)#000000- Black (background)#1a1a1a- Dark gray (buttons)
Change Game Names:
In HomeScreen component or EndScreen, modify:
<h1>CYBERGUARD</h1> // Main title
<h2>Cybersecurity Awareness Game</h2> // Subtitle
Change Messages:
In EndScreen, modify the scoring messages:
if (percentage >= 80) {
message = 'ELITE DEFENDER'; // Change this
}
Game Statistics
- 3 Games
- 4 WiFi locations
- 5 Ethics scenarios
- 5 Hacking situations
- 10+ questions per game
- Scoring system included
Want to add more features?
- Edit the game data arrays
- Modify React components
- Re-deploy (auto on Vercel)
📄 License
Free to use, modify, and share. No attribution required.
🎓 Educational Value
This game teaches:
- ✅ Public WiFi security best practices
- ✅ Indian cybersecurity laws (IT Act 2000)
- ✅ Attack identification and prevention
- ✅ Ethical hacking principles
Perfect for:
- School projects
- College courses
- Corporate training
- Personal learning
Made with ❤️ for cybersecurity awareness