medienkompetenz-lernplattform/backend/lessons/modules/social-engineering-password/index.js
Marius Rometsch a439873394 Add lessons
2026-02-08 19:47:21 +01:00

195 lines
7.4 KiB
JavaScript

const LessonModule = require('../base/LessonModule');
/**
* Social Engineering Password Demo Lesson
* Demonstrates how personal information from social media leads to weak passwords
*/
class SocialEngineeringPasswordLesson extends LessonModule {
constructor(config) {
super(config);
this.correctPassword = 'bella2018';
this.attempts = new Map(); // Track attempts per participant
}
/**
* Validate password guess
* Called via executeLessonAction endpoint
* @param {string} participantId - Participant identifier
* @param {string} password - Password guess
* @param {number} eventLessonId - Event lesson ID for point awards
* @returns {Object} Validation result with German feedback
*/
async testPassword(participantId, password, eventLessonId) {
// Initialize attempt counter for this participant
if (!this.attempts.has(participantId)) {
this.attempts.set(participantId, 0);
}
const attemptCount = this.attempts.get(participantId) + 1;
this.attempts.set(participantId, attemptCount);
// Normalize input (case-insensitive, trim whitespace)
const normalizedInput = (password || '').toLowerCase().trim();
const isCorrect = normalizedInput === this.correctPassword;
// Award points for cracking the password
let pointsAwarded = 0;
if (isCorrect && participantId && eventLessonId) {
// Award bonus points based on attempts (fewer attempts = more points)
if (attemptCount <= 3) {
pointsAwarded = 60; // Expert: found quickly
} else if (attemptCount <= 5) {
pointsAwarded = 50; // Good: found with minimal hints
} else if (attemptCount <= 8) {
pointsAwarded = 40; // Average: needed some hints
} else {
pointsAwarded = 30; // Struggled: needed all hints
}
try {
await this.awardPoints(participantId, eventLessonId, pointsAwarded,
`Password cracked in ${attemptCount} attempts`);
} catch (error) {
console.error('Failed to award password points:', error);
}
}
// Progressive hints based on attempt count
let hint = null;
if (!isCorrect) {
if (attemptCount >= 8) {
hint = 'Tipp: Manche nutzer fügennoch ein Sonderzeichen an ihr schwaches Passwort (.,?,!,_)';
} else if (attemptCount >= 5) {
hint = 'Tipp: Kombinieren Sie den Namen des Hundes mit der Jahreszahl aus den Posts';
} else if (attemptCount >= 3) {
hint = 'Tipp: Achten Sie auf persönliche Details in den Social-Media-Posts';
}
}
return {
success: isCorrect,
attemptCount,
pointsAwarded,
message: isCorrect
? 'Passwort korrekt! Sie haben die Schwachstelle erfolgreich identifiziert.'
: 'Passwort falsch. Versuchen Sie es erneut.',
hint,
explanation: isCorrect
? 'Das Passwort "bella2018!" kombiniert den Hundenamen (Bella) mit dem Geburtsjahr der Zwillinge (2018). Dies ist ein häufiges und unsicheres Passwort-Muster, da diese Informationen leicht aus Social-Media-Profilen zu finden sind.'
: null,
securityTip: isCorrect
? 'Verwenden Sie niemals persönliche Informationen wie Haustiernamen, Geburtsdaten oder Namen von Familienmitgliedern in Passwörtern. Nutzen Sie stattdessen einen Passwort-Manager mit generierten Zufallspasswörtern.'
: null
};
}
/**
* Reset attempts for a participant (when using hint system)
* @param {string} participantId - Participant identifier
*/
resetAttempts(participantId) {
this.attempts.delete(participantId);
}
/**
* Get interactive data for social media demo step
* @param {string} stepId - Step identifier
* @returns {Object} Interactive component data
*/
async getInteractiveData(stepId) {
if (stepId === 'social-media-demo') {
return {
profile: {
name: 'Sophia Müller',
username: '@sophia.mueller',
bio: 'Mutter von Zwillingen 👶👶 | Hundeliebhaberin 🐕 | Fotografin 📸',
location: 'München, Deutschland',
joined: 'März 2016',
profileImage: '👤', // Placeholder emoji
followers: 342,
following: 198,
posts: [
{
id: 1,
type: 'photo',
caption: 'Unsere Zwillinge sind heute 6 Jahre alt geworden! 🎂🎉 Die Zeit vergeht so schnell! #2018Babies #Zwillinge #Geburtstag #StolzeMama',
imageDescription: '[Foto: Zwei Kinder vor einem Geburtstagskuchen mit "6" Kerzen, Dekoration zeigt "2018"]',
date: '2024-09-15',
likes: 89,
comments: 24,
timestamp: 'vor 5 Monaten'
},
{
id: 2,
type: 'photo',
caption: 'Bella liebt den Herbst! 🍂🐕 Unser Golden Retriever hat so viel Spaß beim Spielen in den Blättern. #BellaTheDog #GoldenRetriever #Herbstspaß #Hundeliebe',
imageDescription: '[Foto: Golden Retriever namens Bella spielt in Herbstlaub]',
date: '2024-10-12',
likes: 156,
comments: 31,
timestamp: 'vor 4 Monaten'
},
{
id: 3,
type: 'text',
content: 'Bella ist jetzt seit 8 Jahren meine beste Freundin ❤️🐾 Kann mir ein Leben ohne sie nicht mehr vorstellen!',
date: '2023-11-20',
likes: 203,
comments: 45,
timestamp: 'vor 1 Jahr'
},
{
id: 4,
type: 'photo',
caption: 'Familienausflug zum Starnberger See! ⛵️ Die Zwillinge lieben es hier. Bella auch! 🌊 #FamilyTime #Bayern #Wochenende',
imageDescription: '[Foto: Familie am See, zwei Kinder und ein Hund]',
date: '2024-07-22',
likes: 124,
comments: 18,
timestamp: 'vor 7 Monaten'
},
{
id: 5,
type: 'photo',
caption: 'Erster Schultag für Emma und Liam! 📚✏️ Meine Babys werden so groß! #Einschulung #Zwillinge #ProudMom',
imageDescription: '[Foto: Zwei Kinder mit Schultüten vor einer Schule]',
date: '2024-09-10',
likes: 267,
comments: 52,
timestamp: 'vor 5 Monaten'
}
]
},
loginForm: {
username: 'sophia.mueller@email.de',
correctPassword: 'bella2018!',
passwordHint: 'Versuchen Sie, das Passwort aus den Informationen im Profil zu erraten...',
hints: [
'Achten Sie auf Namen und Jahreszahlen in den Posts',
'Viele Menschen verwenden Namen von Haustieren in Passwörtern',
'Kombinationen aus Namen und Jahreszahlen sind häufig'
]
},
securityLessons: [
{
title: 'Offensichtliche Informationen',
description: 'Hundename (Bella) und Geburtsjahr der Kinder (2018) sind öffentlich sichtbar'
},
{
title: 'Vorhersagbares Muster',
description: 'Name + Jahreszahl ist ein sehr häufiges Passwort-Muster'
},
{
title: 'OSINT Risiko',
description: 'Open Source Intelligence (OSINT) ermöglicht das Sammeln solcher Informationen'
}
]
};
}
return await super.getInteractiveData(stepId);
}
}
module.exports = SocialEngineeringPasswordLesson;