-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
1634 lines (1485 loc) · 77.6 KB
/
script.js
File metadata and controls
1634 lines (1485 loc) · 77.6 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
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* ── CANVAS PARTICLE BG ── */
(function () {
const c = document.getElementById('bg-canvas');
const ctx = c.getContext('2d');
let W, H, particles = [], lines = [];
function resize() { W = c.width = innerWidth; H = c.height = innerHeight; }
resize(); window.addEventListener('resize', resize);
class Particle {
constructor() {
this.x = Math.random() * W; this.y = Math.random() * H;
this.vx = (Math.random() - .5) * .25; this.vy = (Math.random() - .5) * .25;
this.r = Math.random() * 1.5 + .5;
this.alpha = Math.random() * .5 + .1;
}
update() {
this.x += this.vx; this.y += this.vy;
if (this.x < 0 || this.x > W) this.vx *= -1;
if (this.y < 0 || this.y > H) this.vy *= -1;
}
draw() {
ctx.beginPath(); ctx.arc(this.x, this.y, this.r, 0, Math.PI * 2);
ctx.fillStyle = `rgba(99,179,255,${this.alpha})`; ctx.fill();
}
}
for (let i = 0; i < 90; i++) particles.push(new Particle());
function drawLines() {
for (let i = 0; i < particles.length; i++) {
for (let j = i + 1; j < particles.length; j++) {
const dx = particles[i].x - particles[j].x, dy = particles[i].y - particles[j].y;
const dist = Math.sqrt(dx * dx + dy * dy);
if (dist < 130) {
ctx.beginPath();
ctx.moveTo(particles[i].x, particles[i].y);
ctx.lineTo(particles[j].x, particles[j].y);
ctx.strokeStyle = `rgba(99,179,255,${.06 * (1 - dist / 130)})`;
ctx.lineWidth = .6; ctx.stroke();
}
}
}
}
function loop() {
ctx.clearRect(0, 0, W, H);
particles.forEach(p => { p.update(); p.draw(); });
drawLines();
requestAnimationFrame(loop);
}
loop();
})();
/* ── STATE ── */
let allResults = [];
let currentPage = 0;
let sources = { hackertarget: true, urlscan: true, crtsh: true, jldc: true, certspotter: true, rapiddns: true, dnsrepo: true };
let sourceCounts = { hackertarget: 0, urlscan: 0, crtsh: 0, jldc: 0, certspotter: 0, rapiddns: 0, dnsrepo: 0 };
/* ── ENDPOINT RECON STATE ── */
let epResults = [];
let epCurrentPage = 0;
const EP_PAGE_SIZE = 100;
/* ── TAB SWITCHING ── */
function switchTab(tab) {
const isSub = tab === 'subdomain';
document.getElementById('tab-subdomain').style.display = isSub ? '' : 'none';
document.getElementById('tab-endpoint').style.display = isSub ? 'none' : '';
// Sync desktop nav
document.getElementById('pill-subdomain').classList.toggle('active', isSub);
document.getElementById('pill-endpoint').classList.toggle('active', !isSub);
// Sync mobile nav (if elements exist)
const mSub = document.getElementById('mobileSubdomainBtn');
const mEp = document.getElementById('mobileEndpointBtn');
if (mSub) mSub.classList.toggle('active', isSub);
if (mEp) mEp.classList.toggle('active', !isSub);
// Update Hero Content
const badge = document.getElementById('hero-badge-text');
const title = document.getElementById('page-title-text');
const sub = document.getElementById('page-subtitle-text');
if (badge) {
badge.innerHTML = isSub ?
'<span class="hero-badge-dot"></span> Passive Subdomain Discovery' :
'<span class="hero-badge-dot"></span> Passive Endpoint Harvesting';
}
if (title) {
title.textContent = isSub ? 'Subdomain Reconnaissance' : 'Endpoint Discovery';
}
if (sub) {
sub.textContent = isSub ?
'Map your target\'s entire infrastructure footprint using aggregated certificate transparency logs and public DNS archives — zero contact with the target server.' :
'Extract API routes, parameters, and hidden paths from web archives like Wayback Machine and Common Crawl — pure passive recon, no packets sent directly.';
}
}
/* ── CORS PROXY — try multiple, return first success ── */
const PROXY_LIST = [
url => `https://corsproxy.io/?url=${encodeURIComponent(url)}`,
url => `https://cors.eu.org/${url}`,
url => `https://api.allorigins.win/raw?url=${encodeURIComponent(url)}`,
url => `https://api.codetabs.com/v1/proxy?quest=${encodeURIComponent(url)}`,
url => `https://thingproxy.freeboard.io/fetch/${url}`,
];
// Large-response proxy list — skips corsproxy.io which has a payload size cap (413)
const PROXY_LIST_LARGE = [
url => `https://cors.eu.org/${url}`,
url => `https://api.allorigins.win/raw?url=${encodeURIComponent(url)}`,
url => `https://api.codetabs.com/v1/proxy?quest=${encodeURIComponent(url)}`,
url => `https://thingproxy.freeboard.io/fetch/${url}`,
url => `https://corsproxy.io/?url=${encodeURIComponent(url)}`,
];
async function proxyFetch(targetUrl, timeoutMs = 13000, large = false) {
const list = large ? PROXY_LIST_LARGE : PROXY_LIST;
let lastErr;
for (const make of list) {
try {
const res = await fetch(make(targetUrl), { signal: AbortSignal.timeout(timeoutMs) });
if (res.ok) return res;
lastErr = new Error('HTTP ' + res.status);
} catch (e) { lastErr = e; }
}
throw lastErr || new Error('All proxies failed');
}
/* ── SOURCE TOGGLE ── */
function toggleSource(el, name) {
sources[name] = el.checked;
const label = document.getElementById('toggle-' + name);
label.classList.toggle('active', el.checked);
}
/* ── ENDPOINT SOURCE TOGGLE ── */
const epSources = { wayback: true, commoncrawl: true, otx: true, urlscan: true };
function toggleEpSource(el, name) {
epSources[name] = el.checked;
document.getElementById('ep-toggle-' + name).classList.toggle('active', el.checked);
}
function updateEpToggleCount(name, count) {
const toggle = document.getElementById('ep-toggle-' + name);
if (!toggle) return;
let countEl = toggle.querySelector('.toggle-count');
if (!countEl) {
countEl = document.createElement('span');
countEl.className = 'toggle-count';
toggle.appendChild(countEl);
}
countEl.textContent = count.toLocaleString();
}
/* ── SUBDOMAIN VALIDATOR — strips false positives ── */
function isValidSubdomain(raw, domain) {
if (!raw) return false;
const s = raw.trim().toLowerCase();
// reject emails, paths, protocols, ports, wildcards
if (s.includes('@') || s.includes('/') || s.includes(':') || s.startsWith('*')) return false;
// must only contain valid hostname chars
if (!/^[a-z0-9][a-z0-9.\-]*[a-z0-9]$/.test(s) && s !== domain) return false;
// must end with .domain (actual subdomain) or equal domain itself
if (s !== domain && !s.endsWith('.' + domain)) return false;
// must have at least one label before the registered domain
if (s === domain) return false;
// no label longer than 63 chars
if (s.split('.').some(l => l.length > 63)) return false;
return true;
}
/* ── SCAN ── */
async function startScan() {
const domain = document.getElementById('domain-input').value.trim().toLowerCase()
.replace(/^https?:\/\//, '').replace(/\/.*$/, '').replace(/\/$/, '');
if (!domain || !/^[a-z0-9][a-z0-9.\-]*\.[a-z]{2,}$/.test(domain)) {
showToast('Please enter a valid domain name.', 'error'); return;
}
if (!sources.hackertarget && !sources.urlscan && !sources.crtsh) {
showToast('Enable at least one source.', 'error'); return;
}
const btn = document.getElementById('scan-btn');
btn.disabled = true;
btn.querySelector('.btn-text').innerHTML = '<span class="spinner"></span> Scanning…';
allResults = [];
currentPage = 0;
sourceCounts = { hackertarget: 0, urlscan: 0, crtsh: 0, jldc: 0, certspotter: 0, rapiddns: 0, dnsrepo: 0 };
['hackertarget', 'urlscan', 'crtsh', 'jldc', 'certspotter', 'rapiddns', 'dnsrepo'].forEach(s => { const el = document.querySelector(`#toggle-${s} .toggle-count`); if (el) el.remove(); });
setStats(0, 0, 0, 0);
document.getElementById('stats-row').style.display = 'grid';
clearTable();
document.getElementById('httpx-tip').classList.remove('visible');
showProgress();
setProgress(0);
const activeSources = [];
if (sources.hackertarget) activeSources.push('hackertarget');
if (sources.urlscan) activeSources.push('urlscan');
if (sources.crtsh) activeSources.push('crtsh');
if (sources.jldc) activeSources.push('jldc');
if (sources.certspotter) activeSources.push('certspotter');
if (sources.rapiddns) activeSources.push('rapiddns');
if (sources.dnsrepo) activeSources.push('dnsrepo');
initSourceStatus(activeSources);
setSourceState('hackertarget', sources.hackertarget ? 'pending' : 'none');
setSourceState('urlscan', sources.urlscan ? 'pending' : 'none');
setSourceState('crtsh', sources.crtsh ? 'pending' : 'none');
setSourceState('jldc', sources.jldc ? 'pending' : 'none');
setSourceState('certspotter', sources.certspotter ? 'pending' : 'none');
setSourceState('rapiddns', sources.rapiddns ? 'pending' : 'none');
setSourceState('dnsrepo', sources.dnsrepo ? 'pending' : 'none');
const promises = [];
if (sources.hackertarget) {
setSourceState('hackertarget', 'loading');
promises.push(
fetchHackerTarget(domain)
.then(r => { sourceCounts.hackertarget = r.length; mergeResults(r, 'hackertarget'); setSourceState('hackertarget', 'done', r.length); updateToggleCount('hackertarget', r.length); renderTable(allResults); updateStats(); })
.catch(e => { if (e.quota) { setSourceState('hackertarget', 'quota'); } else { console.warn('HackerTarget:', e); setSourceState('hackertarget', 'error', 0); } })
);
}
if (sources.urlscan) {
setSourceState('urlscan', 'loading');
promises.push(
fetchURLScan(domain)
.then(r => { sourceCounts.urlscan = r.length; mergeResults(r, 'urlscan'); setSourceState('urlscan', 'done', r.length); updateToggleCount('urlscan', r.length); renderTable(allResults); updateStats(); })
.catch(e => { console.warn('URLScan:', e); setSourceState('urlscan', 'error', 0); })
);
}
if (sources.crtsh) {
setSourceState('crtsh', 'loading');
promises.push(
fetchCrtSh(domain)
.then(r => { sourceCounts.crtsh = r.length; mergeResults(r, 'crtsh'); setSourceState('crtsh', 'done', r.length); updateToggleCount('crtsh', r.length); renderTable(allResults); updateStats(); })
.catch(e => { console.warn('crt.sh:', e); setSourceState('crtsh', 'error', 0); })
);
}
if (sources.jldc) {
setSourceState('jldc', 'loading');
promises.push(
fetchJLDC(domain)
.then(r => { sourceCounts.jldc = r.length; mergeResults(r, 'jldc'); setSourceState('jldc', 'done', r.length); updateToggleCount('jldc', r.length); renderTable(allResults); updateStats(); })
.catch(e => { console.warn('JLDC:', e); setSourceState('jldc', 'error', 0); })
);
}
if (sources.certspotter) {
setSourceState('certspotter', 'loading');
promises.push(
fetchCertSpotter(domain)
.then(r => { sourceCounts.certspotter = r.length; mergeResults(r, 'certspotter'); setSourceState('certspotter', 'done', r.length); updateToggleCount('certspotter', r.length); renderTable(allResults); updateStats(); })
.catch(e => { console.warn('CertSpotter:', e); setSourceState('certspotter', 'error', 0); })
);
}
if (sources.rapiddns) {
setSourceState('rapiddns', 'loading');
promises.push(
fetchRapidDNS(domain)
.then(r => { sourceCounts.rapiddns = r.length; mergeResults(r, 'rapiddns'); setSourceState('rapiddns', 'done', r.length); updateToggleCount('rapiddns', r.length); renderTable(allResults); updateStats(); })
.catch(e => { console.warn('RapidDNS:', e); setSourceState('rapiddns', 'error', 0); })
);
}
if (sources.dnsrepo) {
setSourceState('dnsrepo', 'loading');
promises.push(
fetchDNSRepo(domain)
.then(r => { sourceCounts.dnsrepo = r.length; mergeResults(r, 'dnsrepo'); setSourceState('dnsrepo', 'done', r.length); updateToggleCount('dnsrepo', r.length); renderTable(allResults); updateStats(); })
.catch(e => { console.warn('DNSRepo:', e); setSourceState('dnsrepo', 'error', 0); })
);
}
let done = 0;
const total = promises.length;
promises.forEach(p => p.finally(() => { done++; setProgress(Math.round(done / total * 100)); }));
await Promise.allSettled(promises);
// ── RETRY on 0 results ──────────────────────────────────────────
if (allResults.length === 0) {
document.querySelector('.progress-title').innerHTML =
'<div class="spinner" style="width:14px;height:14px;border-width:2px;margin-right:8px;"></div> No results yet — retrying with longer timeout…';
setProgress(0);
await new Promise(r => setTimeout(r, 2500));
const retry = [];
if (sources.hackertarget) {
setSourceState('hackertarget', 'loading');
retry.push(
fetchHackerTarget(domain, 22000)
.then(r => { mergeResults(r, 'hackertarget'); setSourceState('hackertarget', 'done', r.length); updateToggleCount('hackertarget', r.length); renderTable(allResults); updateStats(); })
.catch(e => { if (e.quota) { setSourceState('hackertarget', 'quota'); } else { setSourceState('hackertarget', 'error', 0); } })
);
}
if (sources.urlscan) {
setSourceState('urlscan', 'loading');
retry.push(
fetchURLScan(domain, 22000)
.then(r => { mergeResults(r, 'urlscan'); setSourceState('urlscan', 'done', r.length); updateToggleCount('urlscan', r.length); renderTable(allResults); updateStats(); })
.catch(() => setSourceState('urlscan', 'error', 0))
);
}
if (sources.crtsh) {
setSourceState('crtsh', 'loading');
retry.push(
fetchCrtSh(domain, 30000)
.then(r => { mergeResults(r, 'crtsh'); setSourceState('crtsh', 'done', r.length); updateToggleCount('crtsh', r.length); renderTable(allResults); updateStats(); })
.catch(() => setSourceState('crtsh', 'error', 0))
);
}
if (sources.jldc) {
setSourceState('jldc', 'loading');
retry.push(
fetchJLDC(domain, 22000)
.then(r => { mergeResults(r, 'jldc'); setSourceState('jldc', 'done', r.length); updateToggleCount('jldc', r.length); renderTable(allResults); updateStats(); })
.catch(() => setSourceState('jldc', 'error', 0))
);
}
if (sources.certspotter) {
setSourceState('certspotter', 'loading');
retry.push(
fetchCertSpotter(domain, 22000)
.then(r => { mergeResults(r, 'certspotter'); setSourceState('certspotter', 'done', r.length); updateToggleCount('certspotter', r.length); renderTable(allResults); updateStats(); })
.catch(() => setSourceState('certspotter', 'error', 0))
);
}
if (sources.rapiddns) {
setSourceState('rapiddns', 'loading');
retry.push(
fetchRapidDNS(domain, 22000)
.then(r => { mergeResults(r, 'rapiddns'); setSourceState('rapiddns', 'done', r.length); updateToggleCount('rapiddns', r.length); renderTable(allResults); updateStats(); })
.catch(() => setSourceState('rapiddns', 'error', 0))
);
}
if (sources.dnsrepo) {
setSourceState('dnsrepo', 'loading');
retry.push(
fetchDNSRepo(domain, 22000)
.then(r => { mergeResults(r, 'dnsrepo'); setSourceState('dnsrepo', 'done', r.length); updateToggleCount('dnsrepo', r.length); renderTable(allResults); updateStats(); })
.catch(() => setSourceState('dnsrepo', 'error', 0))
);
}
let rd = 0;
retry.forEach(p => p.finally(() => { rd++; setProgress(Math.round(rd / retry.length * 100)); }));
await Promise.allSettled(retry);
}
// ────────────────────────────────────────────────────────────────
setProgress(100);
setTimeout(() => hideProgress(), 700);
try { renderTable(allResults); updateStats(); } catch (e) { console.error('render error:', e); }
btn.disabled = false;
btn.querySelector('.btn-text').innerHTML = 'Initiate Scout';
btn.querySelector('.btn-icon').innerHTML = '<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><line x1="5" y1="12" x2="19" y2="12" /><polyline points="12 5 19 12 12 19" /></svg>';
playDoneSound();
showWnToast('subdomain', allResults.length);
}
/* ── FETCH: HackerTarget ── */
async function fetchHackerTarget(domain, timeoutMs = 13000) {
const htUrl = `https://api.hackertarget.com/hostsearch/?q=${domain}`;
let text;
// HackerTarget sends Access-Control-Allow-Origin:* — always try direct first
// (each user's browser IP gets 21 free calls/day; shared proxy IPs are always exhausted)
try {
const res = await fetch(htUrl, { signal: AbortSignal.timeout(timeoutMs) });
text = await res.text();
} catch (e) {
try {
const res2 = await proxyFetch(htUrl, timeoutMs + 5000);
text = await res2.text();
} catch (e2) { return []; }
}
if (!text) return [];
if (text.includes('API count exceeded') || text.includes('API Key Required') || text.includes('Increase Quota')) {
const err = new Error('quota'); err.quota = true; throw err;
}
if (text.startsWith('error') || text.startsWith('<') || !text.includes(',')) return [];
return text.trim().split('\n')
.filter(l => l.includes(','))
.map(l => { const [sub, ip] = l.split(','); return { subdomain: sub.trim().toLowerCase(), ip: ip?.trim() || '', source: 'hackertarget' }; })
.filter(r => isValidSubdomain(r.subdomain, domain));
}
/* ── FETCH: URLScan.io (via CORS proxy) ── */
async function fetchURLScan(domain, timeoutMs = 13000) {
const res = await proxyFetch(`https://urlscan.io/api/v1/search/?q=page.domain:${domain}&size=100`, timeoutMs);
let data;
try { data = await res.json(); } catch (e) { return []; }
const seen = new Set();
const out = [];
for (const r of (data.results || [])) {
const sub = (r?.page?.domain || '').toLowerCase();
if (sub && isValidSubdomain(sub, domain) && !seen.has(sub)) {
seen.add(sub);
out.push({ subdomain: sub, ip: r?.page?.ip || '', source: 'urlscan' });
}
}
return out;
}
/* ── FETCH: crt.sh ── */
async function fetchCrtSh(domain, timeoutMs = 40000) {
// crt.sh is slow (PostgreSQL) — can take 30s+ for large domains
// It sends Access-Control-Allow-Origin: * so direct fetch always works
const directUrl = `https://crt.sh/?q=%.${domain}&output=json`;
const crtUrl = `https://crt.sh/?q=%25.${domain}&output=json`;
let res = null;
// Direct fetch — crt.sh supports CORS natively, no proxy needed
try {
const r = await fetch(directUrl, { signal: AbortSignal.timeout(timeoutMs) });
if (r.ok) res = r;
} catch (e) { }
// Proxy fallback — only corsproxy.io (skip allorigins: 30s cap < crt.sh response time)
if (!res) {
try {
const r = await fetch(`https://corsproxy.io/?url=${encodeURIComponent(crtUrl)}`, { signal: AbortSignal.timeout(timeoutMs) });
if (r.ok) res = r;
} catch (e) { }
}
if (!res) return [];
let text;
try { text = await res.text(); } catch (e) { return []; }
// Ensure we got JSON, not an HTML error page
if (!text || text.trimStart()[0] !== '[') return [];
let data;
try { data = JSON.parse(text); } catch (e) { return []; }
if (!Array.isArray(data)) return [];
const seen = new Set();
const out = [];
for (const entry of data) {
for (const name of (entry.name_value || '').split('\n')) {
const sub = name.trim().replace(/^\*\./, '').toLowerCase();
if (sub && isValidSubdomain(sub, domain) && !seen.has(sub)) {
seen.add(sub);
out.push({ subdomain: sub, ip: '', source: 'crtsh' });
}
}
}
return out;
}
/* ── FETCH: JLDC / Anubis ── */
async function fetchJLDC(domain, timeoutMs = 15000) {
// jldc.me redirects (301) → jonlu.ca → anubisdb.com; no CORS headers at any step → go straight to proxy
const url = `https://anubisdb.com/anubis/subdomains/${domain}`;
let res;
try { res = await proxyFetch(url, timeoutMs); } catch (e) { return []; }
let data;
try { data = await res.json(); } catch (e) { return []; }
if (!Array.isArray(data)) return [];
const seen = new Set();
const out = [];
for (const sub of data) {
const s = String(sub).trim().toLowerCase();
if (s && isValidSubdomain(s, domain) && !seen.has(s)) {
seen.add(s);
out.push({ subdomain: s, ip: '', source: 'jldc' });
}
}
return out;
}
/* ── FETCH: CertSpotter ── */
async function fetchCertSpotter(domain, timeoutMs = 13000) {
const url = `https://api.certspotter.com/v1/issuances?domain=${domain}&include_subdomains=true&expand=dns_names`;
const res = await proxyFetch(url, timeoutMs);
let data;
try { data = await res.json(); } catch (e) { return []; }
if (!Array.isArray(data)) return [];
const seen = new Set();
const out = [];
for (const entry of data) {
for (const name of (entry.dns_names || [])) {
const sub = String(name).trim().replace(/^\*\./, '').toLowerCase();
if (sub && isValidSubdomain(sub, domain) && !seen.has(sub)) {
seen.add(sub);
out.push({ subdomain: sub, ip: '', source: 'certspotter' });
}
}
}
return out;
}
/* ── FETCH: RapidDNS ── */
async function fetchRapidDNS(domain, timeoutMs = 15000) {
const url = `https://rapiddns.io/subdomain/${domain}?full=1`;
let res;
try { res = await proxyFetch(url, timeoutMs); } catch (e) { return []; }
let html;
try { html = await res.text(); } catch (e) { return []; }
const seen = new Set();
const out = [];
const re = new RegExp(`<td>([a-z0-9][a-z0-9\\-\\.]*\\.${domain.replace(/\./g, '\\.')})<\\/td>`, 'gi');
let m;
while ((m = re.exec(html)) !== null) {
const sub = m[1].trim().toLowerCase();
if (isValidSubdomain(sub, domain) && !seen.has(sub)) {
seen.add(sub);
out.push({ subdomain: sub, ip: '', source: 'rapiddns' });
}
}
return out;
}
/* ── FETCH: DNSRepo ── */
async function fetchDNSRepo(domain, timeoutMs = 15000) {
const url = `https://dnsrepo.noc.org/?domain=${domain}`;
let res;
try { res = await proxyFetch(url, timeoutMs); } catch (e) { return []; }
let html;
try { html = await res.text(); } catch (e) { return []; }
const seen = new Set();
const out = [];
const re = new RegExp(`([a-z0-9][a-z0-9\\-\\.]*\\.${domain.replace(/\./g, '\\.')})`, 'gi');
let m;
while ((m = re.exec(html)) !== null) {
const sub = m[1].trim().toLowerCase();
if (isValidSubdomain(sub, domain) && !seen.has(sub)) {
seen.add(sub);
out.push({ subdomain: sub, ip: '', source: 'dnsrepo' });
}
}
return out;
}
/* ── MERGE RESULTS ── */
function mergeResults(incoming, sourceName) {
for (const item of incoming) {
const existing = allResults.find(r => r.subdomain === item.subdomain);
if (existing) {
if (existing.source !== sourceName) existing.source = 'both'; // 'both' = multiple sources
if (!existing.ip && item.ip) existing.ip = item.ip;
} else {
allResults.push({ ...item });
}
}
allResults.sort((a, b) => {
if (!!a.ip !== !!b.ip) return a.ip ? -1 : 1; // resolved first
return a.subdomain.localeCompare(b.subdomain); // then alphabetical within each group
});
}
/* ── PAGINATION ── */
const PAGE_SIZE = 100;
/* ── RENDER TABLE ── */
function renderTable(data) {
const tbody = document.getElementById('results-tbody');
const filter = document.getElementById('filter-input').value.toLowerCase();
const filtered = filter
? data.filter(r => r.subdomain.includes(filter) || (r.ip && r.ip.includes(filter)))
: data;
const shown = filtered.slice(0, (currentPage + 1) * PAGE_SIZE);
const remaining = filtered.length - shown.length;
document.getElementById('result-count').textContent = filtered.length
? `— ${shown.length} of ${filtered.length}` : '';
if (!filtered.length) {
tbody.innerHTML = `<tr class="visible"><td colspan="6"><div style="padding: 3rem 2rem; text-align: center; opacity: 0.4;"><div style="font-size: 3rem; margin-bottom: 1rem;">🛰</div><p>${data.length ? 'No intelligence matches your current filter.' : 'Awaiting target parameters...'}</p></div></td></tr>`;
renderShowMore(0);
return;
}
tbody.innerHTML = shown.map((r, i) => rowHTML(r, i)).join('');
requestAnimationFrame(() => {
tbody.querySelectorAll('tr').forEach((tr, i) => {
setTimeout(() => tr.classList.add('visible'), Math.min(i, 40) * 15);
});
});
renderShowMore(remaining);
}
function rowHTML(r, i) {
const ipContent = r.ip ? `<span class="ip-badge">${r.ip}</span>` : '<span style="opacity:0.2">—</span>';
const statusContent = r.ip
? '<span class="status-badge resolved"><span class="dot"></span>Resolved</span>'
: '<span class="status-badge passive"><span class="dot"></span>Passive</span>';
return `<tr>
<td>${String(i + 1).padStart(2, '0')}</td>
<td>${formatSub(r.subdomain)}</td>
<td>${ipContent}</td>
<td>${sourceBadge(r.source)}</td>
<td>${statusContent}</td>
</tr>`;
}
function renderShowMore(remaining) {
const existing = document.getElementById('show-more-row');
if (existing) existing.remove();
if (remaining <= 0) return;
const tbody = document.getElementById('results-tbody');
const tr = document.createElement('tr');
tr.id = 'show-more-row';
tr.className = 'visible';
tr.innerHTML = `<td colspan="6" style="text-align:center;padding:3rem;">
<button class="btn-secondary" onclick="loadMore()" style="margin:0 auto; padding: 0.8rem 4rem; border-color: var(--primary); color: var(--primary); background: rgba(0,242,255,0.05);">
Load More Intel
<span style="opacity:0.5;font-weight:400;margin-left:0.5rem">(${remaining} remaining)</span>
</button>
</td>`;
tbody.appendChild(tr);
}
function loadMore() {
currentPage++;
renderTable(allResults);
}
/* ── FILTER ── */
function filterTable() { currentPage = 0; renderTable(allResults); }
function formatSub(sub) {
const parts = sub.split('.');
let inner;
if (parts.length <= 2) {
inner = `<span class="highlight">${sub}</span>`;
} else {
const prefix = parts.slice(0, -2).join('.');
const base = parts.slice(-2).join('.');
inner = `<span class="highlight">${prefix}</span> <span class="base">.${base}</span>`;
}
return `<a class="sub-link" href="https://${sub}" target="_blank" rel="noopener noreferrer">${inner}</a>`;
}
function sourceBadge(src) {
const label = SOURCE_LABELS[src] || 'Multiple';
return `<span class="intel-badge">${label.toUpperCase()}</span>`;
}
/* ── STATS ── */
function updateEpStats(domain) {
const total = epResults.length;
const sources = new Set(epResults.map(r => r.source)).size;
animateCount('ep-stat-total', total);
animateCount('ep-stat-sources', sources);
if (domain) document.getElementById('ep-stat-domain').textContent = domain;
}
function updateStats() {
const total = allResults.length;
const resolved = allResults.filter(r => r.ip).length;
const sourcesHit = Object.values(sourceCounts).filter(v => v > 0).length;
const uniqueIPs = new Set(allResults.filter(r => r.ip).map(r => r.ip)).size;
animateCount('stat-total', total);
animateCount('stat-resolved', resolved);
animateCount('stat-sources', sourcesHit);
animateCount('stat-unique-ips', uniqueIPs);
}
function setStats(a, b, c, d) {
document.getElementById('stat-total').textContent = a;
document.getElementById('stat-resolved').textContent = b;
document.getElementById('stat-sources').textContent = c;
document.getElementById('stat-unique-ips').textContent = d;
}
function animateCount(id, target) {
const el = document.getElementById(id);
if (!el) return;
const start = parseInt(el.textContent.replace(/,/g, '')) || 0;
const dur = 800;
const t0 = performance.now();
function step(t) {
const p = Math.min((t - t0) / dur, 1);
const val = Math.round(start + (target - start) * easeOut(p));
el.textContent = val.toLocaleString();
if (p < 1) requestAnimationFrame(step);
}
requestAnimationFrame(step);
}
function easeOut(t) { return 1 - Math.pow(1 - t, 3); }
/* ── PROGRESS ── */
function showProgress() { document.getElementById('progress-wrap').classList.add('visible'); }
function hideProgress() { document.getElementById('progress-wrap').classList.remove('visible'); }
function setProgress(pct) {
document.getElementById('progress-bar').style.width = pct + '%';
document.getElementById('progress-pct').textContent = pct + '%';
}
const SOURCE_LABELS = { hackertarget: 'HackerTarget', urlscan: 'URLScan.io', crtsh: 'crt.sh', jldc: 'JLDC', certspotter: 'CertSpotter', rapiddns: 'RapidDNS', dnsrepo: 'DNSRepo' };
const EP_SOURCE_LABELS = { wayback: 'Wayback Machine', commoncrawl: 'Common Crawl', otx: 'AlienVault OTX', urlscan: 'URLScan.io' };
function initSourceStatus(active) {
const el = document.getElementById('source-status');
el.innerHTML = active.map(s => `
<div class="src-item pending" id="src-${s}">
<div class="src-dot"></div>
<span id="src-label-${s}">${SOURCE_LABELS[s]}</span>
</div>
`).join('');
}
function setSourceState(name, state, count) {
const el = document.getElementById('src-' + name);
if (!el) return;
el.className = 'src-item ' + state;
const lbl = document.getElementById('src-label-' + name);
if (!lbl) return;
if (state === 'done' && count !== undefined)
lbl.textContent = `${SOURCE_LABELS[name]} (${count})`;
else if (state === 'error')
lbl.textContent = `${SOURCE_LABELS[name]} — failed`;
else if (state === 'quota')
lbl.textContent = `${SOURCE_LABELS[name]} — rate limited`;
}
function initEpSourceStatus(active) {
const el = document.getElementById('ep-source-status');
el.innerHTML = active.map(s => `
<div class="src-item pending" id="ep-src-${s}">
<div class="src-dot"></div>
<span id="ep-src-label-${s}">${EP_SOURCE_LABELS[s]}</span>
</div>
`).join('');
}
function setEpSourceState(name, state, count) {
const el = document.getElementById('ep-src-' + name);
if (!el) return;
el.className = 'src-item ' + state;
const lbl = document.getElementById('ep-src-label-' + name);
if (!lbl) return;
if (state === 'done' && count !== undefined)
lbl.textContent = `${EP_SOURCE_LABELS[name]} (${count})`;
else if (state === 'error')
lbl.textContent = `${EP_SOURCE_LABELS[name]} — failed`;
else if (state === 'loading')
lbl.textContent = EP_SOURCE_LABELS[name];
}
function updateToggleCount(name, count) {
const toggle = document.getElementById('toggle-' + name);
if (!toggle) return;
let countEl = toggle.querySelector('.toggle-count');
if (!countEl) {
countEl = document.createElement('span');
countEl.className = 'toggle-count';
toggle.appendChild(countEl);
}
countEl.textContent = count.toLocaleString();
}
/* ── CLEAR TABLE ── */
function clearTable() {
document.getElementById('results-tbody').innerHTML = '';
document.getElementById('result-count').textContent = '';
}
/* ── COPY ── */
function copyAll() {
if (!allResults.length) { showToast('Nothing to copy.', 'error'); return; }
const text = allResults.map(r => `${r.subdomain}${r.ip ? '\t' + r.ip : ''}`).join('\n');
navigator.clipboard.writeText(text).then(() => showToast('Copied to clipboard!', 'success'));
}
/* ── EXPORT TXT ── */
function exportTxt() {
if (!allResults.length) { showToast('Nothing to export.', 'error'); return; }
const domain = document.getElementById('domain-input').value.trim()
.replace(/^https?:\/\//, '').replace(/\/.*$/, '') || 'subdomains';
showExportModal(domain);
}
function doExport(domain, type) {
const list = type === 'resolved' ? allResults.filter(r => r.ip) : allResults;
if (!list.length) { showToast('No resolved subdomains to export.', 'error'); return; }
const filename = type === 'resolved' ? `${domain}_resolved.txt` : `${domain}_subdomains.txt`;
const a = document.createElement('a');
a.href = URL.createObjectURL(new Blob([list.map(r => r.subdomain).join('\n')], { type: 'text/plain' }));
a.download = filename;
a.click();
showToast(`Exported ${list.length} subdomains`, 'success');
}
function openReconModal() {
const domain = document.getElementById('domain-input').value.trim() ||
document.getElementById('ep-domain-input').value.trim() ||
'target.com';
showExportModal(domain.replace(/^https?:\/\//, '').replace(/\/.*$/, ''));
}
function showExportModal(domain) {
const filename = `${domain}_subdomains.txt`;
const live = `${domain}_live.txt`;
const resolvedCount = allResults.filter(r => r.ip).length;
const steps = [
{
num: '1', name: 'Live Host Detection', tool: 'httpx',
desc: 'Filter to only responding hosts',
info: 'httpx probes each subdomain over HTTP/HTTPS and returns status codes, page titles, and tech stacks. Essential first step to reduce attack surface.',
cmd: `httpx -l ${filename} -sc -title -tech-detect -o ${live}`,
art: { label: 'Intigriti — 8 Essential Recon Tools', url: 'https://blog.intigriti.com/hacking-tools/recon-for-bug-bounty-8-essential-tools-for-performing-effective-reconnaissance', src: 'Intigriti' }
},
{
num: '2', name: 'Port Scanning', tool: 'naabu',
desc: 'Find open ports on live hosts',
info: 'naabu fast-scans targets for open ports. Non-standard ports often expose admin panels or debug endpoints.',
cmd: `naabu -list ${live} -top-ports 1000 -o ${domain}_ports.txt`,
art: { label: 'YesWeHack — Port Scanning', url: 'https://www.yeswehack.com/learn-bug-bounty/recon-port-scanning-attack-vectors', src: 'YesWeHack' }
},
{
num: '3', name: 'Directory Fuzzing', tool: 'ffuf',
desc: 'Discover hidden paths & endpoints',
info: 'ffuf brute-forces URL paths to uncover hidden admin panels, backup files, and undocumented API routes.',
cmd: `ffuf -w ~/SecLists/Discovery/Web-Content/common.txt -u https://FUZZ.${domain} -mc 200,301,302,403`,
art: { label: 'Intigriti — ffuf Deep Dive', url: 'https://blog.intigriti.com/hacking-tools/hacker-tools-ffuf-fuzz-faster-u-fool-2', src: 'Intigriti' }
},
{
num: '4', name: 'Vulnerability Scan', tool: 'nuclei',
desc: 'Detect CVEs & misconfigurations',
info: 'nuclei runs thousands of templates against live hosts to catch known CVEs and exposures.',
cmd: `nuclei -list ${live} -severity medium,high,critical -o ${domain}_vulns.txt`,
art: { label: 'Intigriti — nuclei Tool Guide', url: 'https://blog.intigriti.com/hacking-tools/hacker-tools-nuclei', src: 'Intigriti' }
},
];
const copyIcon = `<svg width="11" height="11" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="9" y="9" width="13" height="13" rx="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg>`;
const extIcon = `<svg width="10" height="10" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/><polyline points="15 3 21 3 21 9"/><line x1="10" y1="14" x2="21" y2="3"/></svg>`;
document.querySelector('.rm-body').innerHTML = `
<div style="margin-bottom:24px;">
<div class="rm-steps-label">Data Export</div>
<div class="export-grid">
<button class="export-btn primary" onclick="doExport('${domain}','all')">
Download All
<span class="export-btn-sub">${allResults.length} subdomains</span>
</button>
<button class="export-btn" onclick="doExport('${domain}','resolved')">
Download Resolved
<span class="export-btn-sub">${resolvedCount} with IPs</span>
</button>
</div>
</div>
<div class="rm-steps-label">Post-Recon Workflow</div>
<div class="rm-steps">
${steps.map(s => `
<div class="rm-step" id="rmstep-${s.num}">
<div class="rm-step-header" onclick="toggleStep('${s.num}')">
<div class="rm-step-num">${s.num}</div>
<div class="rm-step-meta">
<div class="rm-step-name">${s.name}<span class="rm-step-tool">${s.tool}</span></div>
<div class="rm-step-desc">${s.desc}</div>
</div>
<span class="rm-chevron">›</span>
</div>
<div class="rm-step-info">
<p>${s.info}</p>
<div class="rm-step-code-wrap">
<div class="rm-step-code" id="rmcode-${s.num}">${s.cmd}</div>
<button class="rm-step-copy" onclick="copyRmCode('${s.num}')" title="Copy command">
${copyIcon}
</button>
</div>
${s.art ? `
<a href="${s.art.url}" target="_blank" class="rm-step-link">
${extIcon}
<span>Reference: ${s.art.label}</span>
</a>` : ''}
</div>
</div>
`).join('')}
</div>
`;
document.getElementById('httpx-tip').classList.add('visible');
}
function toggleStep(num) {
const el = document.getElementById('rmstep-' + num);
const isOpen = el.classList.contains('open');
document.querySelectorAll('.rm-body .rm-step').forEach(s => s.classList.remove('open'));
if (!isOpen) el.classList.add('open');
}
function copyRmCode(num) {
const code = document.getElementById('rmcode-' + num).textContent;
navigator.clipboard.writeText(code).then(() => {
showToast('Command copied');
});
}
function copyCmd(btn) {
const cmd = btn.dataset.cmd;
navigator.clipboard.writeText(cmd).then(() => {
const orig = btn.innerHTML;
btn.innerHTML = 'Copied!';
setTimeout(() => { btn.innerHTML = orig; }, 1800);
});
}
/* ── TOAST ── */
let toastTimer;
function showToast(msg, type = 'success') {
const t = document.getElementById('toast');
const icon = type === 'success' ? '✓' : '✕';
t.innerHTML = `<span style="color:${type === 'success' ? 'var(--green)' : 'var(--red)'}; font-weight:700;">${icon}</span> ${msg}`;
t.className = `toast show ${type}`;
clearTimeout(toastTimer);
toastTimer = setTimeout(() => t.classList.remove('show'), 3000);
}
/* ── WHAT NEXT TOAST + MODAL ── */
let wnToastTimer;
function playDoneSound() {
try {
const ctx = new (window.AudioContext || window.webkitAudioContext)();
const t = ctx.currentTime;
// Three quick ascending chime notes
[[523.25, 0], [659.25, 0.13], [783.99, 0.26]].forEach(([freq, delay]) => {
const osc = ctx.createOscillator();
const gain = ctx.createGain();
osc.connect(gain); gain.connect(ctx.destination);
osc.type = 'sine';
osc.frequency.setValueAtTime(freq, t + delay);
gain.gain.setValueAtTime(0, t + delay);
gain.gain.linearRampToValueAtTime(0.18, t + delay + 0.03);
gain.gain.exponentialRampToValueAtTime(0.001, t + delay + 0.55);
osc.start(t + delay);
osc.stop(t + delay + 0.6);
});
} catch (e) { }
}
let wnCurrentMode = 'subdomain';
function showWnToast(mode = 'subdomain', count = 0) {
wnCurrentMode = mode;
if (mode === 'endpoint') {
document.getElementById('wn-toast-icon').textContent = '🔗';
document.getElementById('wn-toast-title').textContent = 'Endpoint Recon Done!';
document.getElementById('wn-toast-sub').textContent = count > 0
? `${count} endpoint${count > 1 ? 's' : ''} collected — what should you do next?`
: 'Scan complete — see what to do next as a bug bounty hunter.';
} else {
document.getElementById('wn-toast-icon').textContent = '🎯';
document.getElementById('wn-toast-title').textContent = 'Enumeration Done!';
document.getElementById('wn-toast-sub').textContent = count > 0
? `${count} subdomain${count > 1 ? 's' : ''} found — what should you do next?`
: 'Scan complete — see what to do next as a bug bounty hunter.';
}
const el = document.getElementById('wn-toast');
el.classList.add('show');
clearTimeout(wnToastTimer);
wnToastTimer = setTimeout(hideWnToast, 12000);
}
function hideWnToast() {
document.getElementById('wn-toast').classList.remove('show');
clearTimeout(wnToastTimer);
}
function renderWnSteps(steps, intro) {
const copyIcon = `<svg width="11" height="11" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="9" y="9" width="13" height="13" rx="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg>`;
const extIcon = `<svg width="10" height="10" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/><polyline points="15 3 21 3 21 9"/><line x1="10" y1="14" x2="21" y2="3"/></svg>`;
document.getElementById('wn-steps-container').innerHTML = `
${intro ? `<div class="wn-intro">${intro}</div>` : ''}
<div class="rm-steps-label">Post-recon workflow — click a step to expand</div>
<div class="rm-steps">
${steps.map(s => `
<div class="rm-step" id="wnstep-${s.num}">
<div class="rm-step-header" onclick="toggleWnStep('${s.num}')">
<div class="rm-step-num">${s.num}</div>
<div class="rm-step-meta">
<div class="rm-step-name">${s.name}<span class="rm-step-tool">${s.tool}</span></div>
<div class="rm-step-desc">${s.desc}</div>
</div>
<span class="rm-chevron">›</span>
</div>
<div class="rm-step-info">
<p>${s.info}</p>
<div class="rm-step-code-wrap">
<div class="rm-step-code" id="rmcode-${s.num}">${s.cmd}</div>
<button class="rm-step-copy" onclick="copyRmCode('${s.num}')" title="Copy command">
${copyIcon}
</button>
</div>
${s.art ? `