-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
305 lines (258 loc) · 8.64 KB
/
app.js
File metadata and controls
305 lines (258 loc) · 8.64 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
// Global state
let currentDomain = '';
let activeTechFilter = 'all';
let activeVulnFilter = 'all';
let searchTerm = '';
// Initialize the application
document.addEventListener('DOMContentLoaded', function() {
initializeApp();
setupEventListeners();
renderDorks();
updateStats();
});
// Initialize application
function initializeApp() {
// Check if there's a saved domain in localStorage
const savedDomain = localStorage.getItem('targetDomain');
if (savedDomain) {
document.getElementById('domain').value = savedDomain;
currentDomain = savedDomain;
}
}
// Setup all event listeners
function setupEventListeners() {
// Domain input handlers
document.getElementById('applyDomain').addEventListener('click', applyDomain);
document.getElementById('clearDomain').addEventListener('click', clearDomain);
document.getElementById('domain').addEventListener('keypress', function(e) {
if (e.key === 'Enter') {
applyDomain();
}
});
// Tech filter handler (dropdown)
document.getElementById('techFilter').addEventListener('change', function() {
activeTechFilter = this.value;
filterDorks();
updateStats();
});
// Vuln filter handler (dropdown)
document.getElementById('vulnFilter').addEventListener('change', function() {
activeVulnFilter = this.value;
filterDorks();
updateStats();
});
// Search handler
document.getElementById('searchDorks').addEventListener('input', function() {
searchTerm = this.value.toLowerCase();
filterDorks();
updateStats();
});
}
// Apply domain to all dorks
function applyDomain() {
const domainInput = document.getElementById('domain').value.trim();
if (!domainInput) {
showToast('Please enter a domain', 'error');
return;
}
// Clean the domain (remove http://, https://, www., trailing slash)
let cleanDomain = domainInput
.replace(/^https?:\/\//, '')
.replace(/^www\./, '')
.replace(/\/$/, '');
currentDomain = cleanDomain;
localStorage.setItem('targetDomain', cleanDomain);
renderDorks();
showToast(`Domain applied: ${cleanDomain}`);
}
// Clear domain
function clearDomain() {
document.getElementById('domain').value = '';
currentDomain = '';
localStorage.removeItem('targetDomain');
renderDorks();
showToast('Domain cleared');
}
// Render all dorks
function renderDorks() {
const container = document.getElementById('dorksContainer');
container.innerHTML = '';
dorksDatabase.forEach((dork, index) => {
const dorkCard = createDorkCard(dork, index);
container.appendChild(dorkCard);
});
filterDorks();
updateStats();
// Restore last-searched state if it exists
const lastSearchedIndex = localStorage.getItem('lastSearchedDork');
if (lastSearchedIndex !== null) {
const cards = document.querySelectorAll('.dork-card');
if (cards[lastSearchedIndex]) {
cards[lastSearchedIndex].classList.add('last-searched');
}
}
}
// Create a dork card element
function createDorkCard(dork, index) {
const card = document.createElement('div');
card.className = 'dork-card';
card.style.position = 'relative';
card.dataset.index = index;
// Replace {DOMAIN} with actual domain
const query = currentDomain
? dork.query.replace(/{DOMAIN}/g, currentDomain)
: dork.query;
// Build tags
const techTags = dork.tech.map(t =>
`<span class="tag tech">${t.toUpperCase()}</span>`
).join('');
const vulnTags = dork.vuln.map(v =>
`<span class="tag vuln">${formatVulnName(v)}</span>`
).join('');
const allTags = techTags + vulnTags;
card.innerHTML = `
<div class="dork-content">
<div class="dork-title">${dork.title}</div>
<div class="dork-query">${escapeHtml(query)}</div>
<div class="dork-tags">
${allTags || '<span class="tag">General</span>'}
</div>
</div>
<div class="dork-actions">
<button class="btn-copy" onclick="copyDork(${index})">Copy</button>
<button class="btn-search" onclick="searchGoogle(${index})">Search</button>
</div>
`;
return card;
}
// Filter dorks based on active filters and search term
function filterDorks() {
const cards = document.querySelectorAll('.dork-card');
cards.forEach((card, index) => {
const dork = dorksDatabase[index];
let shouldShow = true;
// Tech filter
if (activeTechFilter !== 'all') {
shouldShow = shouldShow && dork.tech.includes(activeTechFilter);
}
// Vuln filter
if (activeVulnFilter !== 'all') {
shouldShow = shouldShow && dork.vuln.includes(activeVulnFilter);
}
// Search filter
if (searchTerm) {
const searchableText = (
dork.title + ' ' +
dork.query + ' ' +
dork.tech.join(' ') + ' ' +
dork.vuln.join(' ')
).toLowerCase();
shouldShow = shouldShow && searchableText.includes(searchTerm);
}
if (shouldShow) {
card.classList.remove('hidden');
} else {
card.classList.add('hidden');
}
});
}
// Update statistics
function updateStats() {
const totalDorks = dorksDatabase.length;
const visibleDorks = document.querySelectorAll('.dork-card:not(.hidden)').length;
document.getElementById('totalDorks').textContent = totalDorks;
document.getElementById('visibleDorks').textContent = visibleDorks;
}
// Copy a single dork
function copyDork(index) {
const dork = dorksDatabase[index];
const query = currentDomain
? dork.query.replace(/{DOMAIN}/g, currentDomain)
: dork.query;
copyToClipboard(query);
showToast('Dork copied to clipboard!');
}
// Search on Google
function searchGoogle(index) {
const dork = dorksDatabase[index];
let query = dork.query;
if (!currentDomain && query.includes('{DOMAIN}')) {
showToast('Please set a domain first!', 'error');
return;
}
query = currentDomain
? query.replace(/{DOMAIN}/g, currentDomain)
: query;
// Mark this card as last searched
markLastSearched(index);
const googleUrl = `https://www.google.com/search?q=${encodeURIComponent(query)}`;
window.open(googleUrl, '_blank');
}
// Mark a dork card as last searched
function markLastSearched(index) {
// Remove last-searched class from all cards
document.querySelectorAll('.dork-card').forEach(card => {
card.classList.remove('last-searched');
});
// Add last-searched class to the clicked card
const cards = document.querySelectorAll('.dork-card');
if (cards[index]) {
cards[index].classList.add('last-searched');
// Store in localStorage
localStorage.setItem('lastSearchedDork', index);
}
}
// Copy to clipboard utility
function copyToClipboard(text) {
if (navigator.clipboard && navigator.clipboard.writeText) {
navigator.clipboard.writeText(text);
} else {
// Fallback for older browsers
const textarea = document.createElement('textarea');
textarea.value = text;
textarea.style.position = 'fixed';
textarea.style.opacity = '0';
document.body.appendChild(textarea);
textarea.select();
document.execCommand('copy');
document.body.removeChild(textarea);
}
}
// Show toast notification
function showToast(message, type = 'success') {
const toast = document.getElementById('toast');
toast.textContent = message;
toast.style.background = type === 'error' ? '#ef4444' : '#10b981';
toast.classList.add('show');
setTimeout(() => {
toast.classList.remove('show');
}, 3000);
}
// Format vulnerability name
function formatVulnName(vuln) {
const names = {
'sqli': 'SQL Injection',
'xss': 'XSS',
'lfi': 'LFI/RFI',
'openredirect': 'Open Redirect',
'ssrf': 'SSRF',
'rce': 'RCE',
'idor': 'IDOR',
'disclosure': 'Info Disclosure',
'upload': 'File Upload',
'backup': 'Backup Files',
'config': 'Config Files',
'login': 'Login Pages',
'admin': 'Admin Panels',
'api': 'API',
'subdomain': 'Subdomains',
'filetype': 'File Types'
};
return names[vuln] || vuln.toUpperCase();
}
// Escape HTML to prevent XSS
function escapeHtml(text) {
const div = document.createElement('div');
div.textContent = text;
return div.innerHTML;
}