forked from cliffe/BreakEscape
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-text-file-minigame.html
More file actions
364 lines (307 loc) · 12.7 KB
/
test-text-file-minigame.html
File metadata and controls
364 lines (307 loc) · 12.7 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Text File Minigame Test</title>
<link rel="stylesheet" href="css/main.css">
<link rel="stylesheet" href="css/minigames-framework.css">
<link rel="stylesheet" href="css/text-file-minigame.css">
<style>
body {
background: #000;
color: #00ff00;
font-family: 'Courier New', monospace;
margin: 0;
padding: 20px;
}
.test-container {
max-width: 800px;
margin: 0 auto;
}
.test-button {
background: rgba(0, 255, 0, 0.1);
border: 2px solid #00ff00;
color: #00ff00;
padding: 15px 30px;
margin: 10px;
border-radius: 5px;
cursor: pointer;
font-family: 'Courier New', monospace;
font-size: 14px;
transition: all 0.2s ease;
}
.test-button:hover {
background: rgba(0, 255, 0, 0.2);
box-shadow: 0 0 15px rgba(0, 255, 0, 0.3);
}
.test-info {
background: rgba(0, 255, 0, 0.05);
border: 1px solid #00ff00;
padding: 15px;
margin: 20px 0;
border-radius: 5px;
}
.test-info h3 {
margin-top: 0;
color: #00ff00;
}
.test-info p {
margin: 5px 0;
color: #ccc;
}
</style>
</head>
<body>
<div class="test-container">
<h1>📄 Text File Minigame Test</h1>
<div class="test-info">
<h3>Test Instructions:</h3>
<p>1. Click the test buttons below to launch different text file scenarios</p>
<p>2. Test the "Add to Notebook" functionality</p>
<p>3. Test copy and select all features</p>
<p>4. Test keyboard shortcuts (Ctrl+A, Ctrl+C, Escape)</p>
</div>
<button class="test-button" onclick="testBasicTextFile()">
📄 Test Basic Text File
</button>
<button class="test-button" onclick="testLongTextFile()">
📄 Test Long Text File
</button>
<button class="test-button" onclick="testCodeFile()">
💻 Test Code File
</button>
<button class="test-button" onclick="testEmptyFile()">
📄 Test Empty File
</button>
<button class="test-button" onclick="testCEOExfilFile()">
🎯 Test CEO Exfil File (from scenario)
</button>
<div class="test-info">
<h3>Expected Behavior:</h3>
<p>• Text file minigame should open with Mac-style window decorations</p>
<p>• VT323 font should be used for all text content</p>
<p>• Black text on white background (clean, readable interface)</p>
<p>• Window controls: close (red), minimize (yellow - closes window), maximize (green - toggles fullscreen)</p>
<p>• "Add to Notebook" button should work (if notes minigame is available)</p>
<p>• Copy and Select All buttons should function</p>
<p>• Escape key should close the minigame</p>
</div>
</div>
<!-- Minigame container -->
<div id="minigame-container" style="display: none;"></div>
<script type="module">
// Import the minigame framework and text file minigame
import { MinigameFramework } from './js/minigames/framework/minigame-manager.js';
import { TextFileMinigame } from './js/minigames/text-file/text-file-minigame.js';
// Initialize the framework
window.MinigameFramework = MinigameFramework;
MinigameFramework.registerScene('text-file', TextFileMinigame);
// Test data
const testFiles = {
basic: {
fileName: 'readme.txt',
fileContent: `Welcome to BreakEscape!
This is a test text file to demonstrate the text file minigame functionality.
Features:
- File content display
- Copy to clipboard
- Select all text
- Add to notebook
- Keyboard shortcuts
The minigame should handle this content properly and provide a good user experience.`,
fileType: 'text',
observations: 'A simple text file for testing purposes',
source: 'Test Environment'
},
long: {
fileName: 'security_report.txt',
fileContent: `SECURITY INCIDENT REPORT
================================
Date: ${new Date().toLocaleDateString()}
Time: ${new Date().toLocaleTimeString()}
Reporter: Security Team
Classification: CONFIDENTIAL
INCIDENT SUMMARY:
A potential security breach was detected in the main server room. Unauthorized access was attempted through the ventilation system. The intruder appears to have been familiar with the building layout and security protocols.
DETAILS:
- Time of incident: 02:30 AM
- Location: Server Room A, Floor 3
- Method: Physical intrusion via ventilation shaft
- Duration: Approximately 15 minutes
- Damage: None detected
- Evidence: Fingerprints on server rack, disturbed dust patterns
SUSPECT PROFILE:
- Height: Approximately 5'8" to 6'0"
- Build: Average to athletic
- Clothing: Dark clothing, possibly tactical gear
- Equipment: Professional lockpicking tools, small flashlight
- Knowledge: Familiar with building layout and security systems
EVIDENCE COLLECTED:
1. Fingerprint samples from server rack
2. Dust disturbance patterns
3. Security camera footage (partially obscured)
4. Tool marks on ventilation cover
RECOMMENDATIONS:
1. Increase security patrols in server room area
2. Install additional cameras in ventilation access points
3. Review and update access control procedures
4. Conduct security awareness training for all staff
5. Consider upgrading physical security measures
FOLLOW-UP ACTIONS:
- [ ] Review security camera footage
- [ ] Interview security personnel on duty
- [ ] Check access logs for any anomalies
- [ ] Coordinate with law enforcement if necessary
- [ ] Update incident response procedures
This incident highlights the need for enhanced physical security measures and regular security assessments. All personnel should remain vigilant and report any suspicious activity immediately.
END OF REPORT`,
fileType: 'text',
observations: 'Confidential security incident report',
source: 'Security Department'
},
code: {
fileName: 'access_control.py',
fileContent: `#!/usr/bin/env python3
"""
Access Control System
Handles authentication and authorization for the BreakEscape system
"""
import hashlib
import time
from datetime import datetime, timedelta
class AccessControl:
def __init__(self):
self.users = {}
self.sessions = {}
self.failed_attempts = {}
self.max_attempts = 3
self.lockout_duration = 300 # 5 minutes
def hash_password(self, password):
"""Hash password using SHA-256"""
return hashlib.sha256(password.encode()).hexdigest()
def authenticate(self, username, password):
"""Authenticate user with username and password"""
if username in self.failed_attempts:
if self.failed_attempts[username]['count'] >= self.max_attempts:
if time.time() - self.failed_attempts[username]['last_attempt'] < self.lockout_duration:
return False, "Account locked due to too many failed attempts"
if username in self.users:
hashed_password = self.hash_password(password)
if self.users[username]['password'] == hashed_password:
# Reset failed attempts on successful login
if username in self.failed_attempts:
del self.failed_attempts[username]
# Create session
session_id = self.create_session(username)
return True, session_id
else:
self.record_failed_attempt(username)
return False, "Invalid password"
else:
return False, "User not found"
def create_session(self, username):
"""Create a new session for the user"""
session_id = hashlib.md5(f"{username}{time.time()}".encode()).hexdigest()
self.sessions[session_id] = {
'username': username,
'created': time.time(),
'last_activity': time.time()
}
return session_id
def validate_session(self, session_id):
"""Validate if session is still active"""
if session_id in self.sessions:
session = self.sessions[session_id]
if time.time() - session['last_activity'] < 3600: # 1 hour timeout
session['last_activity'] = time.time()
return True, session['username']
else:
del self.sessions[session_id]
return False, "Session expired"
return False, "Invalid session"
def record_failed_attempt(self, username):
"""Record a failed login attempt"""
if username not in self.failed_attempts:
self.failed_attempts[username] = {'count': 0, 'last_attempt': 0}
self.failed_attempts[username]['count'] += 1
self.failed_attempts[username]['last_attempt'] = time.time()
def add_user(self, username, password, role='user'):
"""Add a new user to the system"""
if username in self.users:
return False, "User already exists"
self.users[username] = {
'password': self.hash_password(password),
'role': role,
'created': time.time()
}
return True, "User created successfully"
# Example usage
if __name__ == "__main__":
ac = AccessControl()
# Add some test users
ac.add_user("admin", "admin123", "admin")
ac.add_user("user1", "password123", "user")
# Test authentication
success, result = ac.authenticate("admin", "admin123")
if success:
print(f"Login successful! Session ID: {result}")
else:
print(f"Login failed: {result}")`,
fileType: 'python',
observations: 'Python code for access control system',
source: 'Development Team'
},
empty: {
fileName: 'empty.txt',
fileContent: '',
fileType: 'text',
observations: 'An empty text file',
source: 'Test Environment'
},
ceoExfil: {
fileName: 'Private',
fileContent: 'Closet keypad code: 7391 - Must move evidence to safe before audit',
fileType: 'text',
observations: 'Private file found on reception computer',
source: 'Reception Computer'
}
};
// Test functions
window.testBasicTextFile = function() {
startTextFileMinigame(testFiles.basic);
};
window.testLongTextFile = function() {
startTextFileMinigame(testFiles.long);
};
window.testCodeFile = function() {
startTextFileMinigame(testFiles.code);
};
window.testEmptyFile = function() {
startTextFileMinigame(testFiles.empty);
};
window.testCEOExfilFile = function() {
startTextFileMinigame(testFiles.ceoExfil);
};
function startTextFileMinigame(fileData) {
const container = document.getElementById('minigame-container');
container.style.display = 'block';
const minigameParams = {
title: `Text File - ${fileData.fileName}`,
fileName: fileData.fileName,
fileContent: fileData.fileContent,
fileType: fileData.fileType,
observations: fileData.observations,
source: fileData.source,
onComplete: (success, result) => {
console.log('Text file minigame completed:', success, result);
container.style.display = 'none';
}
};
MinigameFramework.startMinigame('text-file', container, minigameParams);
}
console.log('Text File Minigame Test Page Loaded');
console.log('Available test functions:', Object.keys(window).filter(key => key.startsWith('test')));
</script>
</body>
</html>