-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjavascript.js
More file actions
85 lines (66 loc) · 2.9 KB
/
javascript.js
File metadata and controls
85 lines (66 loc) · 2.9 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
document.addEventListener('DOMContentLoaded', () => {
document.querySelectorAll('.hint-button').forEach(button => {
button.addEventListener('click', () => {
const hint = button.nextElementSibling;
hint.style.display = hint.style.display === 'none' ? 'block' : 'none';
});
});
const FLAG = "FLAG{XSS}";
const searchInput = document.getElementById('searchInput');
const searchButton = document.getElementById('searchButton');
const cards = document.querySelectorAll('.card');
if (searchButton) {
searchButton.addEventListener('click', () => {
const searchTerm = searchInput.value;
const hiddenDiv = document.createElement('div');
hiddenDiv.style.display = 'none';
hiddenDiv.innerHTML = searchTerm;
document.body.appendChild(hiddenDiv);
if (searchTerm.includes("<script>")) {
setTimeout(() => {
alert("Congratulations! You found the flag: " + FLAG);
}, 500);
}
cards.forEach(card => {
const searchTermElement = document.createElement('div');
searchTermElement.innerHTML = searchTerm;
const companyNameElement = card.querySelector('.card-body p:first-child strong');
const companyName = companyNameElement ? companyNameElement.textContent : '';
if (companyName.includes(searchTermElement.textContent)) {
card.style.display = 'block';
} else {
card.style.display = 'none';
}
});
});
}
document.querySelectorAll('.flag').forEach((flagContainer, index) => {
const input = flagContainer.querySelector('input[type="text"]');
const submitButton = flagContainer.querySelector('.submit-button');
const correctFlags = [
"FLAG{XSS}",
"FLAG{VoidSoup}",
"FLAG{Key}",
"server-status",
"172-31-16-136",
"Apache/2.4.58 (Ubuntu)"
];
submitButton.addEventListener('click', () => {
const enteredFlag = input.value.trim();
let existingMessage = flagContainer.querySelector('.flag-message');
if (existingMessage) {
existingMessage.remove();
}
const messageDiv = document.createElement('div');
messageDiv.classList.add('flag-message');
if (enteredFlag === correctFlags[index]) {
messageDiv.textContent = "Correct! Well done.";
messageDiv.style.color = "white";
} else {
messageDiv.textContent = "Incorrect Flag. Try again.";
messageDiv.style.color = "red";
}
flagContainer.appendChild(messageDiv);
});
});
});