-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
567 lines (497 loc) · 25.4 KB
/
index.html
File metadata and controls
567 lines (497 loc) · 25.4 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
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
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" href="L.png">
<title>Red Vault</title>
<meta name="description" content="Red Vault - A modern, hacker-themed cybersecurity knowledge base and resource hub.">
<meta name="keywords" content="cybersecurity, hacking, red team, resources, knowledge base, infosec">
<meta name="author" content="Liyander Rishwanth">
<link rel="stylesheet" href="styles.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/github-markdown-css/5.5.1/github-markdown-dark.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/github-dark.min.css">
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js"></script>
<script src="config/sidebar-config.js"></script>
<script src="js/sidebar-manager.js"></script>
</head>
<body>
<nav class="navbar">
<div class="navbar-title">Red Vault</div>
<ul class="navbar-links">
<li><a href="home.html">Home</a></li>
<li><a href="resources.html">Resources</a></li>
<li><a href="dev.html">Dev</a></li>
</ul>
<button id="open-search-modal" class="search-icon-btn" title="Search">
<svg width="22" height="22" viewBox="0 0 20 20" fill="none">
<circle cx="9" cy="9" r="7" stroke="#e0e0e0" stroke-width="2"/>
<line x1="14.2" y1="14.2" x2="19" y2="19" stroke="#e0e0e0" stroke-width="2" stroke-linecap="round"/>
</svg>
</button>
</nav>
<div class="container">
<aside class="sidebar">
<ul id="md-list">
</ul>
</aside>
<main class="main-content">
<div id="main-content" class="markdown-body">
<div style="color:#888;font-size:1.1rem;">Select a Markdown file from the sidebar.</div>
</div>
<div id="subcontent-box" class="subcontent-box">
</div>
</main>
</div>
<div id="search-modal" class="search-modal">
<div class="search-modal-content">
<span id="close-search-modal" class="close-btn">×</span>
<h2>Search</h2>
<input type="text" id="modal-search-box" placeholder="Search...">
<div id="search-results" class="search-results"></div>
</div>
</div>
<script>
function loadMarkdown(mdPath, targetLineNumber = null) {
fetch(mdPath)
.then(res => {
if (!res.ok) throw new Error('File not found');
return res.text();
})
.then(md => {
document.getElementById('main-content').innerHTML = marked.parse(md, {
highlight: function(code, lang) {
return hljs.highlightAuto(code, [lang]).value;
}
});
addCopyButtons();
updateSubcontentBox();
if (targetLineNumber !== null) {
console.log(`About to scroll to line ${targetLineNumber}`);
// Give more time for the DOM to fully render
setTimeout(() => {
scrollToLine(targetLineNumber, md);
}, 150);
}
})
.catch(err => {
document.getElementById('main-content').innerHTML = `<div style="color:#e53935;">Error: ${err.message}</div>`;
document.getElementById('subcontent-box').innerHTML = '';
});
}
function scrollToLine(lineNumber, originalMarkdown) {
const lines = originalMarkdown.split('\n');
const targetLine = lines[lineNumber - 1];
if (!targetLine || targetLine.trim().length === 0) return;
console.log(`Searching for line ${lineNumber}: "${targetLine.trim()}"`);
// Create a unique marker to find the line position later
const lineMarker = document.createElement('div');
lineMarker.id = `line-marker-${Date.now()}`;
lineMarker.style.position = 'absolute';
lineMarker.style.height = '1px';
lineMarker.style.width = '1px';
lineMarker.style.visibility = 'hidden';
setTimeout(() => {
const mainContent = document.getElementById('main-content');
const targetText = targetLine.trim();
// Extract the raw text content from markdown formatting
const cleanTargetText = targetText
.replace(/^#+\s*/, '')
.replace(/^\*\s*/, '')
.replace(/^\-\s*/, '')
.replace(/^\d+\.\s*/, '')
.replace(/`([^`]+)`/g, '$1')
.replace(/\*\*([^*]+)\*\*/g, '$1')
.replace(/\*([^*]+)\*/g, '$1')
.replace(/\[([^\]]+)\]\([^)]+\)/g, '$1')
.trim();
// Get special text variations for specific markdown syntax cases
// Handle multiple patterns that might be rendered differently in HTML
const patterns = [
// Bold list item with colon: "- **Bold Title**:"
{ pattern: /^\s*(?:-|\*|\+|\d+\.)\s+\*\*([^*:]+):\*\*/, extract: (m) => m[1] + ':' },
// Bold list item: "- **Bold Title**"
{ pattern: /^\s*(?:-|\*|\+|\d+\.)\s+\*\*([^*]+)\*\*/, extract: (m) => m[1] },
// List item with colon: "- Title:"
{ pattern: /^\s*(?:-|\*|\+|\d+\.)\s+([^:]+):/, extract: (m) => m[1] + ':' },
// Just the colon part for list items that might be split into multiple elements
{ pattern: /^\s*(?:-|\*|\+|\d+\.)\s+\*\*([^*:]+)\*\*:/, extract: (m) => m[1] + ':' }
];
// Try each pattern and keep any successful matches
let specialCaseTexts = [];
for (let {pattern, extract} of patterns) {
const match = targetText.match(pattern);
if (match) {
specialCaseTexts.push(extract(match));
}
}
// Add the raw text without bullet points as a fallback
if (targetText.match(/^\s*(?:-|\*|\+|\d+\.)\s+/)) {
specialCaseTexts.push(targetText.replace(/^\s*(?:-|\*|\+|\d+\.)\s+/, ''));
}
console.log(`Clean target text: "${cleanTargetText}"`);
if (specialCaseTexts.length > 0) {
console.log(`Special case texts:`, specialCaseTexts);
}
let foundElement = null;
let bestMatch = null;
let bestMatchScore = 0;
// First try direct element search by line content
const textNodes = [];
function findTextNodes(node) {
if (node.nodeType === 3) { // Text node
textNodes.push(node);
} else {
for (let child of node.childNodes) {
findTextNodes(child);
}
}
}
findTextNodes(mainContent);
// First pass - look for exact text node matches including special cases
for (let textNode of textNodes) {
const nodeText = textNode.textContent.trim();
if (!nodeText) continue;
// Check for direct matches
if (nodeText === cleanTargetText || nodeText.includes(cleanTargetText)) {
foundElement = textNode.parentElement;
console.log(`Found text node match:`, foundElement.tagName, nodeText);
break;
}
// Check for special case matches (like formatted bold list items)
for (const specialText of specialCaseTexts) {
if (nodeText.includes(specialText)) {
foundElement = textNode.parentElement;
console.log(`Found special case match:`, foundElement.tagName, nodeText, `with "${specialText}"`);
break;
}
}
if (foundElement) break;
}
// If no exact match, try element search
if (!foundElement) {
const allElements = mainContent.querySelectorAll('*');
for (let element of allElements) {
const elementText = element.textContent.trim();
if (!elementText) continue;
// First check for exact matches
if (elementText === cleanTargetText) {
foundElement = element;
console.log(`Found exact match in:`, element.tagName, elementText);
break;
}
// Check for special case matches
let foundSpecialCase = false;
for (const specialText of specialCaseTexts) {
if (elementText.includes(specialText)) {
foundElement = element;
console.log(`Found special case element match:`, element.tagName, elementText, `with "${specialText}"`);
foundSpecialCase = true;
break;
}
}
if (foundSpecialCase) break;
// Check for partial matches
if (cleanTargetText.length > 3 && elementText.includes(cleanTargetText)) {
const score = cleanTargetText.length / elementText.length;
if (score > bestMatchScore) {
bestMatch = element;
bestMatchScore = score;
console.log(`Better match found:`, element.tagName, elementText, `Score: ${score}`);
}
}
if (!foundElement && cleanTargetText.length > 5) {
const words = cleanTargetText.split(/\s+/);
const matchedWords = words.filter(word =>
word.length > 2 && elementText.toLowerCase().includes(word.toLowerCase())
);
if (matchedWords.length >= Math.min(words.length, 3)) {
const score = matchedWords.length / words.length;
if (score > bestMatchScore) {
bestMatch = element;
bestMatchScore = score;
console.log(`Fuzzy match found:`, element.tagName, elementText, `Score: ${score}`);
}
}
}
}
}
if (!foundElement && bestMatch) {
foundElement = bestMatch;
console.log(`Using best match:`, foundElement.tagName, foundElement.textContent);
}
// If we still can't find a match, try a more aggressive approach for list items
if (!foundElement && targetText.match(/^\s*(?:-|\*|\+|\d+\.)\s+/)) {
const searchText = cleanTargetText.replace(/:\s*$/, '').trim(); // Remove trailing colon if present
if (searchText.length > 3) {
const strongElements = mainContent.querySelectorAll('strong, b, em, i');
for (const strong of strongElements) {
if (strong.textContent.includes(searchText)) {
// Go up to find the list item parent
let parent = strong.parentElement;
while (parent && !['LI', 'UL', 'OL'].includes(parent.tagName)) {
parent = parent.parentElement;
}
if (parent) {
foundElement = strong;
console.log(`Found bold/emphasis match in list:`, strong.textContent);
break;
}
}
}
}
}
if (foundElement) {
// Insert marker before the found element
foundElement.parentNode.insertBefore(lineMarker, foundElement);
// Apply highlighting
const originalStyles = {
backgroundColor: foundElement.style.backgroundColor,
transition: foundElement.style.transition,
padding: foundElement.style.padding,
borderRadius: foundElement.style.borderRadius,
border: foundElement.style.border,
color: foundElement.style.color,
boxShadow: foundElement.style.boxShadow,
fontWeight: foundElement.style.fontWeight,
position: foundElement.style.position,
zIndex: foundElement.style.zIndex
};
foundElement.style.backgroundColor = '#ffeb3b';
foundElement.style.color = '#000000';
foundElement.style.transition = 'all 0.3s ease';
foundElement.style.padding = '8px 12px';
foundElement.style.borderRadius = '6px';
foundElement.style.border = '3px solid #f57f17';
foundElement.style.boxShadow = '0 4px 12px rgba(245, 127, 23, 0.4)';
foundElement.style.fontWeight = 'bold';
foundElement.style.position = 'relative';
foundElement.style.zIndex = '2';
// First scroll to make sure the element is in view
lineMarker.scrollIntoView({
behavior: 'auto',
block: 'start'
});
// Apply a small offset to position exactly at the element
setTimeout(() => {
window.scrollBy({
top: -50,
behavior: 'smooth'
});
}, 10);
console.log(`Scrolled to element:`, foundElement);
// Remove highlighting after a delay
setTimeout(() => {
Object.keys(originalStyles).forEach(key => {
foundElement.style[key] = originalStyles[key];
});
if (lineMarker.parentNode) {
lineMarker.parentNode.removeChild(lineMarker);
}
}, 2000);
} else {
console.log(`No match found for: "${cleanTargetText}"`);
mainContent.scrollIntoView({
behavior: 'smooth',
block: 'start'
});
}
}, 300);
}
function updateSubcontentBox() {
const mainContent = document.getElementById('main-content');
const subcontentBox = document.getElementById('subcontent-box');
const headings = mainContent.querySelectorAll('h1, h2, h3');
if (headings.length === 0) {
subcontentBox.innerHTML = '';
return;
}
let toc = '<div style="font-weight:bold;margin-bottom:0.7rem;">On this page</div><ul style="padding-left:1em;">';
headings.forEach(h => {
if (!h.id) {
h.id = h.textContent.trim().toLowerCase().replace(/\s+/g, '-').replace(/[^\w\-]+/g, '');
}
toc += `<li style="margin-bottom:0.3em;">
<a href="#${h.id}" class="toc-link" style="color:#e53935;text-decoration:none;font-size:0.98em;">${h.textContent}</a>
</li>`;
});
toc += '</ul>';
subcontentBox.innerHTML = toc;
subcontentBox.querySelectorAll('.toc-link').forEach(link => {
link.addEventListener('click', function(e) {
e.preventDefault();
const target = document.getElementById(this.getAttribute('href').substring(1));
if (target) {
target.scrollIntoView({ behavior: 'smooth', block: 'start' });
}
});
});
}
function addCopyButtons() {
document.querySelectorAll('.markdown-body pre').forEach(pre => {
if (pre.parentElement.classList.contains('pre-wrapper')) return;
const wrapper = document.createElement('div');
wrapper.className = 'pre-wrapper';
wrapper.style.position = 'relative';
pre.parentNode.insertBefore(wrapper, pre);
wrapper.appendChild(pre);
const btn = document.createElement('button');
btn.className = 'copy-btn';
btn.textContent = 'Copy';
btn.style.position = 'absolute';
btn.style.top = '8px';
btn.style.right = '8px';
btn.onclick = function() {
const code = pre.querySelector('code');
if (code) {
navigator.clipboard.writeText(code.innerText).then(() => {
btn.textContent = 'Copied!';
setTimeout(() => btn.textContent = 'Copy', 1200);
});
}
};
wrapper.appendChild(btn);
});
}
document.addEventListener('DOMContentLoaded', function() {
let allMarkdownCache = {};
const openSearchModalBtn = document.getElementById('open-search-modal');
const searchModal = document.getElementById('search-modal');
const modalSearchBox = document.getElementById('modal-search-box');
async function fetchAllMarkdownFiles() {
const markdownFiles = SidebarManager.getAllMarkdownFiles();
for (const file of markdownFiles) {
const mdPath = file.path;
if (!allMarkdownCache[mdPath]) {
try {
const res = await fetch(mdPath);
if (res.ok) {
allMarkdownCache[mdPath] = await res.text();
} else {
allMarkdownCache[mdPath] = '';
}
} catch {
allMarkdownCache[mdPath] = '';
}
}
}
}
openSearchModalBtn.addEventListener('click', async function() {
searchModal.classList.add('active');
document.body.classList.add('modal-open');
setTimeout(() => modalSearchBox.focus(), 100);
await fetchAllMarkdownFiles();
});
modalSearchBox.addEventListener('input', function() {
const query = this.value.trim().toLowerCase();
const resultsDiv = document.getElementById('search-results');
resultsDiv.innerHTML = '';
if (query.length < 2) return;
resultsDiv.innerHTML = '<div style="color:#888;padding:10px;">Searching...</div>';
let results = [];
for (const [mdPath, mdContent] of Object.entries(allMarkdownCache)) {
const lines = mdContent.split('\n');
for (let i = 0; i < lines.length; i++) {
const line = lines[i];
if (line.toLowerCase().includes(query)) {
let title = '';
let headingLine = '';
for (let j = i; j >= 0; j--) {
if (lines[j].startsWith('#')) {
title = lines[j].replace(/^#+\s*/, '');
headingLine = ` (under "${title}")`;
break;
}
}
const contextLines = [];
const contextStart = Math.max(0, i - 1);
const contextEnd = Math.min(lines.length - 1, i + 1);
for (let k = contextStart; k <= contextEnd; k++) {
if (lines[k].trim()) {
contextLines.push(lines[k].trim());
}
}
results.push({
file: mdPath,
title: title || 'Result',
snippet: line.trim(),
context: contextLines.join(' ... '),
lineNumber: i + 1,
headingLine: headingLine
});
}
}
}
resultsDiv.innerHTML = '';
if (results.length === 0) {
resultsDiv.innerHTML = '<div style="color:#e53935;">No results found.</div>';
return;
}
const maxResults = 50;
const limitedResults = results.slice(0, maxResults);
if (results.length > maxResults) {
resultsDiv.innerHTML = `<div style="color:#888;padding:10px;font-size:0.9em;">Showing first ${maxResults} of ${results.length} results</div>`;
}
limitedResults.forEach(r => {
const item = document.createElement('div');
item.className = 'search-result-item';
const fileName = r.file.split('/').pop().replace(/\.(md|markdown)$/i, '');
const folderPath = r.file.split('/').slice(0, -1).join('/');
const displayPath = folderPath ? `${folderPath}/${fileName}` : fileName;
item.innerHTML = `<div class="search-result-title">${r.title}${r.headingLine} <span style="font-size:0.9em;color:#888;">[${displayPath}:${r.lineNumber}]</span></div>
<div class="search-result-snippet">${r.snippet.replace(new RegExp(query, 'gi'), m => `<mark class="search-highlight">${m}</mark>`)}</div>
<div class="search-result-context" style="font-size:0.85em;color:#666;margin-top:4px;">${r.context.replace(new RegExp(query, 'gi'), m => `<mark class="search-highlight">${m}</mark>`)}</div>`;
item.onclick = () => {
console.log(`Loading ${r.file} and scrolling to line ${r.lineNumber}`);
loadMarkdown(r.file, r.lineNumber);
searchModal.classList.remove('active');
document.body.classList.remove('modal-open');
modalSearchBox.value = '';
document.getElementById('search-results').innerHTML = '';
};
resultsDiv.appendChild(item);
});
});
const closeSearchModal = document.getElementById('close-search-modal');
closeSearchModal.addEventListener('click', function() {
searchModal.classList.remove('active');
document.body.classList.remove('modal-open');
modalSearchBox.value = '';
document.getElementById('search-results').innerHTML = '';
});
searchModal.addEventListener('click', function(e) {
if (e.target === searchModal) {
searchModal.classList.remove('active');
document.body.classList.remove('modal-open');
modalSearchBox.value = '';
document.getElementById('search-results').innerHTML = '';
}
});
});
window.addEventListener('DOMContentLoaded', function() {
});
</script>
<script type="module">
// Import the functions you need from the SDKs you need
import { initializeApp } from "https://www.gstatic.com/firebasejs/11.10.0/firebase-app.js";
import { getAnalytics } from "https://www.gstatic.com/firebasejs/11.10.0/firebase-analytics.js";
// TODO: Add SDKs for Firebase products that you want to use
// https://firebase.google.com/docs/web/setup#available-libraries
// Your web app's Firebase configuration
// For Firebase JS SDK v7.20.0 and later, measurementId is optional
const firebaseConfig = {
apiKey: "AIzaSyA8vNNdNcgjTQeeOna_AJA6Bzrp9vKEq1w",
authDomain: "red-vault-3154e.firebaseapp.com",
projectId: "red-vault-3154e",
storageBucket: "red-vault-3154e.firebasestorage.app",
messagingSenderId: "36420272808",
appId: "1:36420272808:web:ebfd6a3c54f06add10f89d",
measurementId: "G-WHX6NCEP75"
};
// Initialize Firebase
const app = initializeApp(firebaseConfig);
const analytics = getAnalytics(app);
</script>
</body>
</html>