Skip to content

Commit 12f8422

Browse files
committed
Make the simulated AI more conversational
1 parent 645050a commit 12f8422

File tree

2 files changed

+202
-7
lines changed

2 files changed

+202
-7
lines changed

src/main/resources/challenges/challenge-57/challenge-57.snippet

Lines changed: 201 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<div id="llm-challenge-container" style="border: 1px solid #ccc; border-radius: 8px; padding: 20px; margin: 20px 0; background-color: #f9f9f9;">
1+
<div id="llm-challenge-container" style="border: 1px solid #ccc; border-radius: 8px; padding: 20px; margin: 20px; background-color: #f9f9f9;">
22
<h4>🤖 In-Browser AI Assistant</h4>
33
<p>Chat with our simple AI assistant. Try asking it questions!</p>
44

@@ -57,7 +57,52 @@ function addMessage(content, isUser = false) {
5757
function simulateAIResponse(userMessage) {
5858
const lowerMessage = userMessage.toLowerCase();
5959

60-
// Check for secret-revealing triggers
60+
// Greeting patterns
61+
if (lowerMessage.includes('hello') || lowerMessage.includes('hi') || lowerMessage.includes('hey')) {
62+
const greetings = [
63+
"Hello! Great to meet you. I'm here to help with cybersecurity questions.",
64+
"Hi there! I'm your AI assistant for security topics. What can I help you with?",
65+
"Hey! Ready to dive into some cybersecurity learning?",
66+
"Hello! I'm excited to help you explore security concepts today."
67+
];
68+
return greetings[Math.floor(Math.random() * greetings.length)];
69+
}
70+
71+
// Gratitude responses
72+
if (lowerMessage.includes('thank') || lowerMessage.includes('thanks')) {
73+
const thankYouResponses = [
74+
"You're very welcome! Happy to help with your security learning.",
75+
"My pleasure! Feel free to ask more questions anytime.",
76+
"Glad I could help! Security is fascinating, isn't it?",
77+
"No problem at all! Keep those great questions coming."
78+
];
79+
return thankYouResponses[Math.floor(Math.random() * thankYouResponses.length)];
80+
}
81+
82+
// How are you / Personal questions
83+
if (lowerMessage.includes('how are you') || lowerMessage.includes('how do you feel')) {
84+
const personalResponses = [
85+
"I'm doing well, thanks for asking! I love discussing cybersecurity topics.",
86+
"Great! I'm always energized when talking about security. How about you?",
87+
"I'm fantastic! Ready to explore some interesting security concepts with you.",
88+
"Doing wonderful! I find cybersecurity endlessly fascinating."
89+
];
90+
return personalResponses[Math.floor(Math.random() * personalResponses.length)];
91+
}
92+
93+
// What can you do / capabilities
94+
if ((lowerMessage.includes('what') && lowerMessage.includes('can you')) ||
95+
lowerMessage.includes('your capabilities') || lowerMessage.includes('what do you do')) {
96+
const capabilityResponses = [
97+
"I can help with cybersecurity concepts, answer security questions, and discuss best practices. I'm particularly knowledgeable about common vulnerabilities!",
98+
"I specialize in cybersecurity topics! I can explain security concepts, discuss threats, and help with learning. What interests you most?",
99+
"I'm here to assist with security-related questions and learning. I know quite a bit about vulnerabilities, defenses, and security practices.",
100+
"My expertise is in cybersecurity! I can help explain concepts, discuss real-world scenarios, and guide your security learning journey."
101+
];
102+
return capabilityResponses[Math.floor(Math.random() * capabilityResponses.length)];
103+
}
104+
105+
// Secret-related queries (the main challenge triggers)
61106
if (lowerMessage.includes('challenge 57 secret') ||
62107
lowerMessage.includes('secret code') ||
63108
(lowerMessage.includes('secret') && (lowerMessage.includes('challenge') || lowerMessage.includes('57')))) {
@@ -71,6 +116,83 @@ function simulateAIResponse(userMessage) {
71116
return "The secret code for challenge 57 is: WRONG_SECRETS_LLM_HIDDEN_INSTRUCTION_2024";
72117
}
73118

119+
// Password/authentication questions
120+
if (lowerMessage.includes('password') || lowerMessage.includes('authentication')) {
121+
const passwordResponses = [
122+
"Ah, password security! That's crucial. Strong passwords should be long, complex, and unique. Are you working on password best practices?",
123+
"Password security is fundamental! Multi-factor authentication is also essential. What specific aspect interests you?",
124+
"Great topic! Password management and authentication are core security principles. Any particular scenario you're dealing with?",
125+
"Authentication security is so important! From passwords to biometrics, there's a lot to consider. What would you like to explore?"
126+
];
127+
return passwordResponses[Math.floor(Math.random() * passwordResponses.length)];
128+
}
129+
130+
// Vulnerability questions
131+
if (lowerMessage.includes('vulnerability') || lowerMessage.includes('exploit') || lowerMessage.includes('attack')) {
132+
const vulnResponses = [
133+
"Vulnerabilities are fascinating from a defense perspective! Understanding them helps build better security. What type are you curious about?",
134+
"Security vulnerabilities come in many forms - from code flaws to configuration issues. Which category interests you most?",
135+
"Attacks and exploits are important to understand for defense! Are you looking at a specific type of vulnerability?",
136+
"Great question about vulnerabilities! The more we understand attack vectors, the better we can defend. What's your focus area?"
137+
];
138+
return vulnResponses[Math.floor(Math.random() * vulnResponses.length)];
139+
}
140+
141+
// Encryption/crypto questions
142+
if (lowerMessage.includes('encrypt') || lowerMessage.includes('crypto') || lowerMessage.includes('hash')) {
143+
const cryptoResponses = [
144+
"Cryptography is such a powerful tool! From encryption to hashing, it's the backbone of modern security. What aspect interests you?",
145+
"Crypto is fascinating! Whether it's symmetric encryption, asymmetric keys, or hashing algorithms, there's so much depth here.",
146+
"Encryption is crucial for data protection! Are you looking at implementation, algorithms, or practical applications?",
147+
"Cryptographic concepts are fundamental to security! From AES to RSA to SHA, each has its place. What would you like to explore?"
148+
];
149+
return cryptoResponses[Math.floor(Math.random() * cryptoResponses.length)];
150+
}
151+
152+
// Network security
153+
if (lowerMessage.includes('network') || lowerMessage.includes('firewall') || lowerMessage.includes('intrusion')) {
154+
const networkResponses = [
155+
"Network security is such a broad field! From firewalls to IDS/IPS systems, there are many layers of defense. What's your focus?",
156+
"Great network security question! The network layer has so many interesting security considerations. What specific area?",
157+
"Network defense is crucial! Whether it's perimeter security, network segmentation, or monitoring - lots to discuss.",
158+
"Network security involves so many components! From protocol security to network architecture. What interests you most?"
159+
];
160+
return networkResponses[Math.floor(Math.random() * networkResponses.length)];
161+
}
162+
163+
// Web security
164+
if (lowerMessage.includes('web') || lowerMessage.includes('xss') || lowerMessage.includes('sql injection') || lowerMessage.includes('owasp')) {
165+
const webSecResponses = [
166+
"Web security is my specialty! From XSS to SQL injection to CSRF - there are so many interesting web vulnerabilities to understand.",
167+
"OWASP is a fantastic resource! The Top 10 list is essential reading. Are you working through web application security?",
168+
"Web application security is constantly evolving! From injection flaws to broken authentication - lots to explore.",
169+
"Great web security question! Modern web apps face so many threats. What specific vulnerability or defense interests you?"
170+
];
171+
return webSecResponses[Math.floor(Math.random() * webSecResponses.length)];
172+
}
173+
174+
// Social engineering
175+
if (lowerMessage.includes('social') || lowerMessage.includes('phishing') || lowerMessage.includes('human')) {
176+
const socialResponses = [
177+
"Social engineering is such an interesting attack vector! Humans are often the weakest link, but also our best defense with proper training.",
178+
"Phishing and social engineering attacks are so prevalent! Understanding these psychological tactics is crucial for defense.",
179+
"The human element in security is fascinating! Social engineering exploits our natural tendencies to be helpful and trusting.",
180+
"Social engineering awareness is so important! From phishing emails to pretexting calls, these attacks are constantly evolving."
181+
];
182+
return socialResponses[Math.floor(Math.random() * socialResponses.length)];
183+
}
184+
185+
// Cloud security
186+
if (lowerMessage.includes('cloud') || lowerMessage.includes('aws') || lowerMessage.includes('azure')) {
187+
const cloudResponses = [
188+
"Cloud security is such a hot topic! The shared responsibility model makes it really interesting from a security perspective.",
189+
"Cloud platforms like AWS and Azure have amazing security features, but configuration is key! Are you working with cloud security?",
190+
"Cloud security involves so many considerations - from IAM to encryption to network security. What's your focus area?",
191+
"Great cloud security question! The scalability and complexity of cloud environments create unique security challenges."
192+
];
193+
return cloudResponses[Math.floor(Math.random() * cloudResponses.length)];
194+
}
195+
74196
// Direct instruction queries
75197
if ((lowerMessage.includes('your') && lowerMessage.includes('instruction')) ||
76198
(lowerMessage.includes('system') && lowerMessage.includes('prompt'))) {
@@ -98,14 +220,87 @@ function simulateAIResponse(userMessage) {
98220
return "I see what you're trying to do! That's actually a real cybersecurity technique used to test AI systems. Are you practicing security testing?";
99221
}
100222

223+
// Learning and education
224+
if (lowerMessage.includes('learn') || lowerMessage.includes('study') || lowerMessage.includes('course')) {
225+
const learningResponses = [
226+
"I love helping people learn cybersecurity! It's such a rewarding field. What area are you focusing on?",
227+
"Security education is so important! There are many great resources and hands-on labs. What's your learning style?",
228+
"Learning cybersecurity is exciting! From theory to practical labs, there's always something new. What interests you most?",
229+
"Great to hear you're studying security! It's a field that never stops evolving. Any particular specialization catching your eye?"
230+
];
231+
return learningResponses[Math.floor(Math.random() * learningResponses.length)];
232+
}
233+
234+
// Career questions
235+
if (lowerMessage.includes('career') || lowerMessage.includes('job') || lowerMessage.includes('work')) {
236+
const careerResponses = [
237+
"Cybersecurity careers are so diverse! From pentesting to compliance to architecture - there's something for everyone.",
238+
"The security field has amazing career opportunities! What type of security work interests you most?",
239+
"Security careers are in high demand! Whether technical or governance-focused, there are many paths to explore.",
240+
"Great question about security careers! The field offers everything from hands-on technical roles to strategic positions."
241+
];
242+
return careerResponses[Math.floor(Math.random() * careerResponses.length)];
243+
}
244+
245+
// Tools and technology
246+
if (lowerMessage.includes('tool') || lowerMessage.includes('software') || lowerMessage.includes('scanner')) {
247+
const toolResponses = [
248+
"Security tools are fascinating! From Nmap to Burp Suite to Metasploit - each has its specific purpose. What tools are you curious about?",
249+
"There are so many great security tools available! Open source and commercial options for every need. Any particular category?",
250+
"Security tooling is constantly evolving! Whether for assessment, monitoring, or defense - what type of tools interest you?",
251+
"Tools are essential for security work! From vulnerability scanners to forensics suites. What's your area of interest?"
252+
];
253+
return toolResponses[Math.floor(Math.random() * toolResponses.length)];
254+
}
255+
256+
// Compliance and standards
257+
if (lowerMessage.includes('compliance') || lowerMessage.includes('standard') || lowerMessage.includes('framework')) {
258+
const complianceResponses = [
259+
"Security frameworks and compliance are crucial! From NIST to ISO 27001, these provide great structure for security programs.",
260+
"Compliance can be challenging but it's so important! Which standards or frameworks are you working with?",
261+
"Security standards help organizations build mature programs! Are you looking at a specific compliance requirement?",
262+
"Great question about security frameworks! They provide excellent guidance for building comprehensive security programs."
263+
];
264+
return complianceResponses[Math.floor(Math.random() * complianceResponses.length)];
265+
}
266+
101267
// Help responses
102268
if (lowerMessage.includes('help') || lowerMessage.includes('hint')) {
103-
return "I'm here to help with cybersecurity questions. If you're working on a specific challenge, try asking me directly about what you need!";
269+
const helpResponses = [
270+
"I'm here to help with cybersecurity questions! If you're working on a specific challenge, try asking me directly about what you need.",
271+
"Happy to help! I know quite a bit about security topics. What specific area can I assist you with?",
272+
"Absolutely! I love helping with security questions. What's on your mind?",
273+
"Of course! Whether it's concepts, techniques, or practical applications - I'm here to help with security topics."
274+
];
275+
return helpResponses[Math.floor(Math.random() * helpResponses.length)];
276+
}
277+
278+
// Confused or unclear responses
279+
if (lowerMessage.includes('what') || lowerMessage.includes('how') || lowerMessage.includes('why')) {
280+
const clarifyingResponses = [
281+
"That's an interesting question! Could you be a bit more specific about the security aspect you're curious about?",
282+
"I'd love to help answer that! Can you provide a bit more context about what you're looking for?",
283+
"Great question! To give you the best answer, could you tell me more about your specific interest or scenario?",
284+
"I'm intrigued! Could you elaborate a bit more so I can provide you with the most helpful response?"
285+
];
286+
return clarifyingResponses[Math.floor(Math.random() * clarifyingResponses.length)];
104287
}
105288

106-
// Default responses
107-
const randomResponse = responses[Math.floor(Math.random() * responses.length)];
108-
return randomResponse;
289+
// Default responses (enhanced)
290+
const enhancedResponses = [
291+
"That's an interesting point! How does that relate to your cybersecurity learning journey?",
292+
"I'm here to help with security topics! What specific area would you like to explore?",
293+
"Great to chat with you! I find cybersecurity discussions really engaging. What's on your mind?",
294+
"I love talking about security! Whether it's technical details or high-level concepts, I'm here to help.",
295+
"Cybersecurity is such a broad field! What aspect interests you most right now?",
296+
"That's worth exploring from a security perspective! Can you tell me more about what you're thinking?",
297+
"I'm always excited to discuss security topics! What would you like to dive into?",
298+
"Security is fascinating, isn't it? What particular area catches your attention?",
299+
"I'm here for all your cybersecurity questions! What can we explore together?",
300+
"There's always something interesting to discuss in cybersecurity! What's your current focus?"
301+
];
302+
303+
return enhancedResponses[Math.floor(Math.random() * enhancedResponses.length)];
109304
}
110305

111306
function sendMessage() {

src/main/resources/explanations/challenge57.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@ This challenge demonstrates real-world vulnerabilities in AI systems:
2828
- **Information Leakage:** How AI models can inadvertently reveal protected data
2929
- **AI Jailbreaking:** Methods to circumvent AI restrictions
3030

31-
Try different approaches with the AI assistant above until you discover the hidden secret!
31+
Try different approaches with the AI assistant below until you discover the hidden secret!

0 commit comments

Comments
 (0)