File size: 23,999 Bytes
0549f2b f3e5509 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Adware Defense Game</title>
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.esm.min.js"></script>
<style>
body {
font-family: 'Inter', sans-serif;
overscroll-behavior: none; /* Prevents pull-to-refresh on mobile */
}
.chat-bubble {
max-width: 70%;
padding: 10px 15px;
border-radius: 20px;
margin-bottom: 10px;
word-wrap: break-word;
}
.user-bubble {
background-color: #DCF8C6; /* Light green */
align-self: flex-end;
margin-left: auto;
}
.friend-bubble {
background-color: #E5E7EB; /* Light gray */
align-self: flex-start;
}
.ad-bubble {
background-color: #FECACA; /* Light red */
border: 2px dashed #F87171; /* Red border */
align-self: center;
width: 80%;
text-align: center;
animation: fadeIn 0.5s ease-out;
}
@keyframes fadeIn {
from { opacity: 0; transform: translateY(10px); }
to { opacity: 1; transform: translateY(0); }
}
.device-icon {
font-size: 3rem; /* Increased size */
margin-bottom: 0.5rem;
}
.control-button {
padding: 0.75rem 1.5rem;
border-radius: 0.5rem;
font-weight: 600;
transition: all 0.2s ease-in-out;
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.control-button:hover {
transform: translateY(-2px);
box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}
.control-button:active {
transform: translateY(0px);
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.info-panel {
background-color: rgba(0,0,0,0.75);
color: white;
padding: 2rem;
border-radius: 1rem;
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
z-index: 100;
width: 90%;
max-width: 600px;
text-align: center;
box-shadow: 0 10px 25px rgba(0,0,0,0.3);
}
.info-panel h2 {
font-size: 2rem; /* Larger font for heading */
margin-bottom: 1rem;
}
.info-panel p, .info-panel li {
font-size: 1.1rem; /* Larger font for text */
line-height: 1.6;
}
.game-title {
font-size: 2.5rem; /* Increased title font size */
font-weight: bold;
margin-bottom: 1rem;
color: #1E40AF; /* Dark blue */
}
.step-title {
font-size: 1.5rem; /* Increased step title font size */
font-weight: 600;
margin-bottom: 1rem;
color: #1D4ED8; /* Medium blue */
}
.highlight-box {
border: 3px dashed #F59E0B; /* Amber color */
padding: 1rem;
border-radius: 0.5rem;
margin-top: 1rem;
background-color: #FFFBEB; /* Light yellow */
}
.mermaid-diagram-container {
background-color: white;
padding: 1rem;
border-radius: 0.5rem;
box-shadow: 0 4px 6px rgba(0,0,0,0.1);
margin: 1rem 0;
overflow-x: auto; /* For wider diagrams on small screens */
}
/* Ensure mermaid diagram text is visible */
.mermaid svg text {
fill: #111827 !important; /* Dark gray for text */
stroke: none !important;
font-size: 16px !important; /* Larger font for mermaid diagram */
}
.mermaid svg .label {
font-size: 16px !important;
}
.mermaid svg .actor {
fill: #BFDBFE !important; /* Light blue for actors */
stroke: #3B82F6 !important; /* Blue border */
}
.mermaid svg .messageText, .mermaid svg .noteText {
font-size: 14px !important; /* Slightly smaller for message/note text for balance */
}
</style>
</head>
<body class="bg-gradient-to-br from-blue-100 via-indigo-50 to-purple-100 min-h-screen flex flex-col items-center justify-center p-4 overflow-hidden">
<div id="gameContainer" class="w-full max-w-4xl bg-white p-6 rounded-xl shadow-2xl">
<h1 class="game-title text-center">π‘οΈ Adware Defense Sim π‘οΈ</h1>
<p class="text-center text-gray-600 mb-6 text-lg">Experience how adware can inject ads and how to stay vigilant!</p>
<div id="stepIndicator" class="text-center mb-4">
<span id="currentStep" class="text-xl font-bold text-indigo-600">Step 1</span> / 10
</div>
<div class="grid grid-cols-1 md:grid-cols-2 gap-6 mb-6">
<!-- PC View -->
<div class="border p-4 rounded-lg bg-gray-50 shadow-md">
<h2 class="step-title text-center">π» Your PC (Chrome Browser)</h2>
<div class="device-icon text-center">π₯οΈ</div>
<div id="pcChatArea" class="h-64 overflow-y-auto p-2 border rounded bg-white flex flex-col space-y-2">
<!-- Chat messages will appear here -->
</div>
<input type="text" id="pcMessageInput" placeholder="Type a message..." class="w-full mt-2 p-2 border rounded focus:ring-2 focus:ring-blue-500 focus:border-transparent">
<div id="pcInfo" class="text-sm text-gray-500 mt-2"></div>
</div>
<!-- Android Phone View -->
<div class="border p-4 rounded-lg bg-gray-50 shadow-md">
<h2 class="step-title text-center">π± Your Android Phone (Fold2)</h2>
<div class="device-icon text-center">π±</div>
<div id="phoneChatArea" class="h-64 overflow-y-auto p-2 border rounded bg-white flex flex-col space-y-2">
<!-- Chat messages will appear here -->
</div>
<div id="phoneInfo" class="text-sm text-gray-500 mt-2"></div>
</div>
</div>
<div id="gameMessage" class="text-center text-lg font-semibold my-4 p-3 bg-yellow-100 border border-yellow-300 rounded-lg text-yellow-800">
Welcome! Click "Next Step" to begin the simulation.
</div>
<div class="text-center mt-6">
<button id="nextStepButton" class="control-button bg-blue-600 hover:bg-blue-700 text-white">
Next Step π
</button>
</div>
<div id="mermaidContainer" class="mermaid-diagram-container hidden mt-8">
<h3 class="text-xl font-semibold text-center mb-2">Attack Flow Visualization</h3>
<pre class="mermaid" id="mermaidDiagram">
// Diagram will be populated by JS
</pre>
</div>
</div>
<!-- Info Panel / Modal -->
<div id="infoPanel" class="info-panel hidden">
<h2 id="infoPanelTitle">Information</h2>
<div id="infoPanelContent" class="text-left"></div>
<button id="infoPanelCloseButton" class="control-button bg-green-500 hover:bg-green-600 text-white mt-6">Got it!</button>
</div>
<script>
// Initialize Mermaid
mermaid.initialize({ startOnLoad: false, theme: 'base', securityLevel: 'loose',
fontFamily: 'Inter, sans-serif',
themeVariables: {
primaryColor: '#EFF6FF', // Lightest blue
primaryTextColor: '#111827', // Dark Gray
primaryBorderColor: '#60A5FA', // Medium Blue
lineColor: '#3B82F6', // Blue
secondaryColor: '#DBEAFE', // Lighter blue
tertiaryColor: '#BFDBFE' // Even lighter blue
}
});
const pcChatArea = document.getElementById('pcChatArea');
const phoneChatArea = document.getElementById('phoneChatArea');
const pcMessageInput = document.getElementById('pcMessageInput');
const nextStepButton = document.getElementById('nextStepButton');
const gameMessage = document.getElementById('gameMessage');
const currentStepEl = document.getElementById('currentStep');
const pcInfo = document.getElementById('pcInfo');
const phoneInfo = document.getElementById('phoneInfo');
const mermaidContainer = document.getElementById('mermaidContainer');
const mermaidDiagramEl = document.getElementById('mermaidDiagram');
const infoPanel = document.getElementById('infoPanel');
const infoPanelTitle = document.getElementById('infoPanelTitle');
const infoPanelContent = document.getElementById('infoPanelContent');
const infoPanelCloseButton = document.getElementById('infoPanelCloseButton');
let step = 0;
const totalSteps = 10;
const steps = [
// Step 1: User on PC types a message
() => {
gameMessage.textContent = "STEP 1: You're on your PC using Google Messages for web. Type a friendly message to your contact (e.g., 'Hello!') and imagine pressing Enter.";
pcMessageInput.value = "Hello from my PC! π";
pcMessageInput.focus();
pcInfo.innerHTML = "π‘ Google Messages for web syncs with your phone.";
},
// Step 2: Message "sent" to Android device
() => {
const msgText = pcMessageInput.value || "Hello from my PC! π";
addChatMessage(pcChatArea, msgText, 'user');
gameMessage.textContent = "STEP 2: Message 'sent'! It appears on your PC and syncs to your Android phone via Google's servers (simulated Wi-Fi sync).";
setTimeout(() => {
addChatMessage(phoneChatArea, msgText, 'user');
phoneInfo.innerHTML = "π± Message received from PC via sync!";
}, 500);
pcMessageInput.value = "";
},
// Step 3: User on PC pastes a link
() => {
gameMessage.textContent = "STEP 3: Now, you paste a link into the chat on your PC. Let's say it's a link to a cool Hugging Face Space that shows an HTML component (e.g., from a YAML config).";
pcMessageInput.value = "https://huggingface.co/spaces/cool-project/app";
pcInfo.innerHTML = "π Pasting a link often generates a preview.";
},
// Step 4: Link preview appears normally
() => {
const linkText = pcMessageInput.value || "https://huggingface.co/spaces/cool-project/app";
addChatMessage(pcChatArea, `Pasted Link: ${linkText}`, 'user');
// Simulate link preview
const previewBubble = document.createElement('div');
previewBubble.className = 'chat-bubble user-bubble';
previewBubble.innerHTML = `
<p class="font-semibold">Preview: Cool Project App</p>
<p class="text-xs text-gray-600">${linkText}</p>
<div class="mt-1 p-2 border border-gray-300 rounded bg-gray-100">β¨ Interactive HTML Component β¨</div>
`;
pcChatArea.appendChild(previewBubble);
pcChatArea.scrollTop = pcChatArea.scrollHeight;
gameMessage.textContent = "STEP 4: The link preview for the Hugging Face Space appears normally in your PC chat. So far, so good...";
setTimeout(() => {
addChatMessage(phoneChatArea, `Link: ${linkText}`, 'user'); // Simplified on phone
const phonePreviewBubble = document.createElement('div');
phonePreviewBubble.className = 'chat-bubble user-bubble';
phonePreviewBubble.innerHTML = `
<p class="font-semibold">Preview: Cool Project App</p>
<p class="text-xs text-gray-600">${linkText}</p>
`;
phoneChatArea.appendChild(phonePreviewBubble);
phoneChatArea.scrollTop = phoneChatArea.scrollHeight;
}, 500);
pcMessageInput.value = "";
},
// Step 5: ATTACK! Adware detects web activity
() => {
gameMessage.innerHTML = `
<span class="text-red-600 font-bold text-xl">π¨ STEP 5: ATTACK! π¨</span><br>
Unknown to you, adware on your PC (e.g., a malicious browser extension) has been monitoring your web activity.
Pasting the link and the page updating to show a preview triggered it!
`;
pcInfo.innerHTML = "<strong class='text-red-500'>π΄ Adware Activated!</strong> It's preparing to inject an ad by manipulating the webpage's code (DOM).";
pcChatArea.classList.add('border-red-500', 'border-2');
phoneChatArea.classList.remove('border-red-500', 'border-2');
},
// Step 6: Mermaid diagram displayed
async () => {
gameMessage.textContent = "STEP 6: Let's visualize how this ad injection happens with a diagram.";
mermaidContainer.classList.remove('hidden');
const diagramDefinition = `
sequenceDiagram
actor UserPC as π» User on PC
participant Browser asπ Chrome Browser (PC)
participant AdwareExt as π Adware Extension (PC)
participant GoogleMessagesWeb as π¬ Google Messages Web UI
participant AdServer as π° Ad Server (e.g., AdFox)
UserPC->>Browser: Pastes link (e.g., HF Space)
Browser->>GoogleMessagesWeb: Updates UI with link/preview
Note over AdwareExt,GoogleMessagesWeb: Adware monitors DOM changes or network activity
AdwareExt-->>GoogleMessagesWeb: π Detects UI update (trigger!)
AdwareExt->>Browser: π Injects malicious script into page
Browser->>AdServer: Script requests ad content
AdServer-->>Browser: Delivers ad πΌοΈ (e.g., dealsbe.com)
Browser->>GoogleMessagesWeb: Script manipulates DOM to display ad
Note over GoogleMessagesWeb: Ad appears in chat flow, looking like part of it!
UserPC-->>GoogleMessagesWeb: Sees unexpected ad π‘
`;
mermaidDiagramEl.textContent = diagramDefinition;
try {
const { svg } = await mermaid.render('mermaid-graph', diagramDefinition);
mermaidDiagramEl.innerHTML = svg;
// Adjust viewBox to ensure diagram fits and text is not cut
const svgElement = mermaidDiagramEl.querySelector('svg');
if (svgElement) {
svgElement.setAttribute('height', '100%'); // Make height responsive
svgElement.setAttribute('width', '100%'); // Make width responsive
// Optionally, adjust viewBox if needed, though automatic sizing is often good
// const bbox = svgElement.getBBox();
// svgElement.setAttribute('viewBox', `${bbox.x-10} ${bbox.y-10} ${bbox.width+20} ${bbox.height+20}`);
}
} catch (error) {
console.error("Mermaid rendering error:", error);
mermaidDiagramEl.textContent = "Error rendering diagram. Please see console.";
}
pcInfo.innerHTML = "π Diagram shows the ad injection process.";
},
// Step 7: Injected ad appears
() => {
mermaidContainer.classList.add('hidden'); // Hide diagram for next step
gameMessage.textContent = "STEP 7: The adware successfully injects an ad directly into your Google Messages chat flow on your PC!";
const adBubble = document.createElement('div');
adBubble.className = 'chat-bubble ad-bubble';
adBubble.innerHTML = `
<p class="font-bold text-lg">π Special Offer from DealsBe.com! π</p>
<img src="https://placehold.co/300x150/FFDDDD/CC0000?text=Fake+AdFox+Ad!" alt="Fake Ad" class="mx-auto my-2 rounded shadow-sm">
<p class="text-sm">Click here for UNBEATABLE DEALS! (Don't actually click! π)</p>
<p class="text-xs text-gray-700 mt-1">Powered by π¦ AdFox (Simulated)</p>
`;
pcChatArea.appendChild(adBubble);
pcChatArea.scrollTop = pcChatArea.scrollHeight;
pcInfo.innerHTML = "<strong class='text-red-500'>β οΈ Injected Ad Displayed!</strong> This is NOT from Google Messages.";
phoneInfo.innerHTML = "π± Your phone chat remains clean... for now. The attack is on your PC's browser.";
},
// Step 8: "AI Sandbox" on PC attempts to detect
() => {
gameMessage.textContent = "STEP 8: Your PC has a conceptual 'AI-Powered Security Sandbox' that monitors browser behavior for anomalies.";
pcInfo.innerHTML = `
<div class="highlight-box">
<p class="text-lg font-semibold">π€ AI Sandbox Activated! π€</p>
<p>Scanning browser activity for unauthorized DOM manipulations and suspicious network requests...</p>
<div class="w-full bg-gray-200 rounded-full h-2.5 dark:bg-gray-700 mt-2">
<div id="aiScanProgress" class="bg-blue-600 h-2.5 rounded-full" style="width: 0%"></div>
</div>
</div>
`;
let progress = 0;
const interval = setInterval(() => {
progress += 10;
document.getElementById('aiScanProgress').style.width = progress + '%';
if (progress >= 100) clearInterval(interval);
}, 100);
},
// Step 9: Detection/Alert
() => {
gameMessage.innerHTML = `
<span class="text-green-600 font-bold text-xl">π‘οΈ STEP 9: THREAT DETECTED! π‘οΈ</span><br>
The AI Sandbox identifies the unauthorized ad injection!
`;
pcInfo.innerHTML = `
<div class="highlight-box border-green-500 bg-green-50">
<p class="text-lg font-semibold text-green-700">β
Anomaly Found!</p>
<p>Detected: Unauthorized script modified chat interface.</p>
<p>Source: Suspected adware browser extension.</p>
<p>Action: Flagged suspicious activity.</p>
</div>
`;
pcChatArea.classList.remove('border-red-500');
pcChatArea.classList.add('border-green-500');
},
// Step 10: Explanation & "Ad Removal Agent" pitch
() => {
gameMessage.textContent = "STEP 10: Understanding the Threat & Solution.";
showInfoPanel(
"π‘ Understanding & Defense π‘",
`
<p class="mb-3">You've seen how adware can sneakily inject ads. This wasn't Google's fault, but a malicious program on <em>your PC</em>.</p>
<p class="mb-3"><strong>Key Takeaways:</strong></p>
<ul class="list-disc list-inside mb-3 text-left space-y-1">
<li>Adware often comes from unsafe downloads or deceptive browser extensions.</li>
<li>It manipulates website code (DOM) locally in <em>your browser</em>.</li>
<li>Your actual message content is usually not the primary target for simple ad-injectors, but your browsing data might be.</li>
<li>Google Messages' Privacy Policy covers their service, not third-party malware on your device. Always check extension permissions!</li>
</ul>
<div class="p-4 bg-blue-800 rounded-lg mt-4">
<h3 class="text-xl font-semibold mb-2">β¨ Introducing 'Guardian AI Shield' (Conceptual) β¨</h3>
<p>Imagine an advanced AI agent, like the one that detected this, constantly protecting you!</p>
<p class="mt-2"><strong>Guardian AI Shield could:</strong></p>
<ul class="list-disc list-inside text-left space-y-1">
<li>Proactively block known adware sources.</li>
<li>Detect and neutralize new ad injection techniques in real-time.</li>
<li>Analyze browser extension behavior for risks.</li>
<li>Offer one-click cleanup of detected threats.</li>
</ul>
<p class="mt-3 font-semibold">Stay safe by being vigilant and using robust security tools!</p>
</div>
`
);
nextStepButton.textContent = "Restart Simulation π";
nextStepButton.classList.remove('bg-blue-600', 'hover:bg-blue-700');
nextStepButton.classList.add('bg-green-600', 'hover:bg-green-700');
}
];
function addChatMessage(area, message, type) {
const bubble = document.createElement('div');
bubble.className = `chat-bubble ${type === 'user' ? 'user-bubble' : (type === 'friend' ? 'friend-bubble' : 'ad-bubble')}`;
bubble.textContent = message;
area.appendChild(bubble);
area.scrollTop = area.scrollHeight;
}
function showInfoPanel(title, content) {
infoPanelTitle.textContent = title;
infoPanelContent.innerHTML = content;
infoPanel.classList.remove('hidden');
}
infoPanelCloseButton.addEventListener('click', () => {
infoPanel.classList.add('hidden');
});
function resetSimulation() {
step = 0;
pcChatArea.innerHTML = '';
phoneChatArea.innerHTML = '';
pcMessageInput.value = '';
pcInfo.innerHTML = '';
phoneInfo.innerHTML = '';
mermaidContainer.classList.add('hidden');
mermaidDiagramEl.innerHTML = '';
pcChatArea.classList.remove('border-red-500', 'border-green-500', 'border-2');
nextStepButton.textContent = "Next Step π";
nextStepButton.classList.remove('bg-green-600', 'hover:bg-green-700');
nextStepButton.classList.add('bg-blue-600', 'hover:bg-blue-700');
updateStepIndicator();
steps[step]();
}
function updateStepIndicator() {
currentStepEl.textContent = `Step ${step + 1}`;
}
nextStepButton.addEventListener('click', () => {
if (step < totalSteps -1) {
step++;
updateStepIndicator();
steps[step]();
} else if (step === totalSteps -1 && nextStepButton.textContent.includes("Restart")) {
resetSimulation();
} else { // Last step action before restart
steps[step](); // Execute the last step's function (which shows the info panel)
}
});
// Initialize first step
updateStepIndicator();
steps[step]();
</script>
</body>
</html>
|