Elffuss BraidHub

kikocis/osiris public

master · 56.0 KiBRawPermalink
1'use client';
2
3import { useState, useCallback, useEffect, memo } from 'react';
4import { motion, AnimatePresence } from 'framer-motion';
5import {
6 Search, Radar, Globe, Shield, FileText, Radio,
7 ChevronDown, ChevronUp, Loader2, AlertTriangle, Server,
8 Wifi, Lock, MapPin, Bug, Code, Layers, Network, Fingerprint,
9 CheckCircle, XCircle, Clock, ExternalLink, Crosshair,
10 Maximize2, Minimize2, Gavel, Bitcoin, Phone, Terminal, ShieldAlert
11} from 'lucide-react';
12import { ipToNumber, numberToIp, calculateSubnetStart, classifyDevice, assessRisk, batchFetch, ShodanInternetDBResponse, SweepDevice } from '@/lib/osint-utils';
13
14const TABS = [
15 { id: 'scanner', label: 'PORT SCAN', icon: Radar, placeholder: 'IP or hostname', color: '#00E5FF' },
16 { id: 'vuln', label: 'VULN SWEEP', icon: Bug, placeholder: 'IP or hostname', color: '#FF3D3D' },
17
18 { id: 'dns', label: 'DNS', icon: Server, placeholder: 'Domain name', color: '#448AFF' },
19 { id: 'whois', label: 'WHOIS', icon: FileText, placeholder: 'Domain name', color: '#FFD700' },
20 { id: 'certs', label: 'CERTS', icon: Lock, placeholder: 'Domain name', color: '#E040FB' },
21 { id: 'threats', label: 'THREATS', icon: AlertTriangle, placeholder: 'IP, domain, or hash', color: '#FF9500' },
22 { id: 'headers', label: 'HEADERS', icon: Code, placeholder: 'URL to inspect', color: '#87CEEB' },
23 { id: 'ssl', label: 'SSL/TLS', icon: Shield, placeholder: 'Domain name', color: '#76FF03' },
24 { id: 'subdomains', label: 'SUBDOMAINS', icon: Layers, placeholder: 'Domain to enumerate', color: '#00BCD4' },
25 { id: 'tech', label: 'TECH DETECT', icon: Code, placeholder: 'URL to fingerprint', color: '#9C27B0' },
26 { id: 'shodan', label: 'SHODAN IOT', icon: Network, placeholder: 'IP address', color: '#FF3D3D' },
27 { id: 'bgp', label: 'BGP ROUTE', icon: Globe, placeholder: 'IP or ASN', color: '#00E5FF' },
28 { id: 'mac', label: 'MAC ADDR', icon: Fingerprint, placeholder: 'MAC address', color: '#FFD700' },
29 { id: 'phone', label: 'PHONE INTEL', icon: Phone, placeholder: 'Phone number (e.g. +1...)', color: '#FF9500' },
30 { id: 'leaks', label: 'DATA LEAKS', icon: ShieldAlert, placeholder: 'Email address', color: '#E040FB' },
31 { id: 'github', label: 'GITHUB RECON', icon: Terminal, placeholder: 'GitHub username', color: '#87CEEB' },
32 { id: 'sweep', label: 'IP SWEEP', icon: Crosshair, placeholder: 'Enter IP address (e.g. 8.8.8.8)', color: '#FF3D3D' },
33];
34
35interface OsintPanelProps { isOpen?: boolean; onClose?: () => void; isMobile?: boolean; onSweepVisualize?: (data: any) => void; onScanGeolocate?: (target: string, data: any) => void; }
36
37function OsintPanelInner({ isMobile, onSweepVisualize, onScanGeolocate }: OsintPanelProps) {
38 const [activeTab, setActiveTab] = useState('scanner');
39 const [isFullScreen, setIsFullScreen] = useState(false);
40 const [query, setQuery] = useState('');
41 const [results, setResults] = useState<any>(null);
42 const [loading, setLoading] = useState(false);
43 const [error, setError] = useState('');
44 const [scanType, setScanType] = useState('quick');
45 const [expanded, setExpanded] = useState(true);
46 const [history, setHistory] = useState<{tab:string;query:string;time:string}[]>([]);
47 const [sweepResult, setSweepResult] = useState<any>(null);
48 const [sweepProgress, setSweepProgress] = useState<{ current: number; total: number } | null>(null);
49 const [sweepCidr, setSweepCidr] = useState(24);
50 const [cveCache, setCveCache] = useState<Record<string, any>>({});
51 const [expandedDevice, setExpandedDevice] = useState<string | null>(null);
52
53 // Fetch CVE details when a device is expanded in full-screen mode
54 const fetchCveDetails = useCallback(async (cveIds: string[]) => {
55 const missing = cveIds.filter(id => !cveCache[id]);
56 if (missing.length === 0) return;
57 // Mark as loading
58 setCveCache(prev => {
59 const next = { ...prev };
60 for (const id of missing) next[id] = { loading: true };
61 return next;
62 });
63 // Fetch in parallel
64 const results = await Promise.allSettled(
65 missing.map(id => fetch(`/api/osint/cve?cve=${encodeURIComponent(id)}`).then(r => r.json()).then(data => ({ id, data })))
66 );
67 setCveCache(prev => {
68 const next = { ...prev };
69 for (const r of results) {
70 if (r.status === 'fulfilled') {
71 next[r.value.id] = r.value.data;
72 }
73 }
74 return next;
75 });
76 }, [cveCache]);
77
78 const runLookup = useCallback(async () => {
79 if (!query.trim() || loading) return;
80 setLoading(true); setError(''); setResults(null);
81
82 // IP Sweep / Vuln Scan — separate flow
83 if (activeTab === 'sweep' || activeTab === 'vuln') {
84 setSweepResult(null);
85 const cidr = sweepCidr;
86 const totalHosts = Math.pow(2, 32 - cidr);
87 setSweepProgress({ current: 0, total: totalHosts });
88 try {
89 const t0 = Date.now();
90 const res = await fetch(`/api/osint/sweep?ip=${encodeURIComponent(query)}&cidr=${cidr}`);
91 if (!res.ok) { const e = await res.json().catch(() => ({})); throw new Error(e.error || `Sweep failed (${res.status})`); }
92 const initData = await res.json();
93
94 const ipParts = initData.target_ip.split('.').map(Number) as [number, number, number, number];
95 const ipNum = ipToNumber(ipParts);
96 const subnetStart = calculateSubnetStart(ipNum, cidr);
97 const subnet = numberToIp(subnetStart);
98
99 const urls: string[] = [];
100 for (let i = 0; i < totalHosts; i++) {
101 urls.push(`https://internetdb.shodan.io/${numberToIp((subnetStart + i) >>> 0)}`);
102 }
103
104 const shodanResults = await batchFetch<ShodanInternetDBResponse>(urls, 15, async (u) => {
105 try {
106 const r = await fetch(u, { cache: 'no-store' });
107 if (r.status === 404) return null;
108 if (!r.ok) return null;
109 return await r.json();
110 } catch {
111 return null;
112 }
113 }, (done) => setSweepProgress({ current: done, total: totalHosts }));
114
115 const devices: SweepDevice[] = [];
116 const deviceBreakdown: Record<string, number> = {};
117 for (const sr of shodanResults) {
118 if (!sr) continue;
119 const classification = classifyDevice(sr.ports, sr.cpes, sr.tags);
120 const risk = assessRisk({ ports: sr.ports, vulns: sr.vulns });
121 devices.push({
122 ip: sr.ip, ports: sr.ports, hostnames: sr.hostnames,
123 cpes: sr.cpes, vulns: sr.vulns, tags: sr.tags,
124 device_type: classification.device_type,
125 device_icon: classification.device_icon,
126 device_color: classification.device_color,
127 risk_level: risk
128 });
129 deviceBreakdown[classification.device_type] = (deviceBreakdown[classification.device_type] || 0) + 1;
130 }
131
132 setSweepResult({
133 center: initData.center,
134 subnet: `${subnet}/${cidr}`,
135 cidr,
136 target_ip: initData.target_ip,
137 devices,
138 summary: { total_hosts: totalHosts, total_responsive: devices.length, device_breakdown: deviceBreakdown },
139 sweep_time_ms: Date.now() - t0
140 });
141 setSweepProgress(null);
142 setHistory(prev => [{ tab: activeTab, query, time: new Date().toLocaleTimeString() }, ...prev.slice(0, 9)]);
143 } catch (err: any) {
144 setError(err.message);
145 setSweepProgress(null);
146 } finally {
147 setLoading(false);
148 }
149 return;
150 }
151
152 try {
153 let url = '';
154 switch (activeTab) {
155
156 case 'dns': url = `/api/osint/dns?domain=${encodeURIComponent(query)}`; break;
157 case 'certs': url = `/api/osint/certs?domain=${encodeURIComponent(query)}`; break;
158 case 'whois': url = `/api/osint/whois?domain=${encodeURIComponent(query)}`; break;
159 case 'threats': url = `/api/osint/threats?query=${encodeURIComponent(query)}`; break;
160 case 'bgp': url = `/api/osint/bgp?query=${encodeURIComponent(query)}`; break;
161 case 'mac': url = `/api/osint/mac?mac=${encodeURIComponent(query)}`; break;
162 case 'phone': url = `/api/osint/phone?number=${encodeURIComponent(query)}`; break;
163 case 'leaks': url = `/api/osint/leaks?email=${encodeURIComponent(query)}`; break;
164 case 'crypto': url = `/api/osint/crypto?address=${encodeURIComponent(query)}`; break;
165 case 'github': url = `/api/osint/github?user=${encodeURIComponent(query)}`; break;
166 case 'scanner': url = `/api/scanner?target=${encodeURIComponent(query)}&type=${scanType}`; break;
167 case 'headers': url = `/api/scanner?target=${encodeURIComponent(query)}&type=headers`; break;
168 case 'ssl': url = `/api/scanner?target=${encodeURIComponent(query)}&type=ssl`; break;
169 case 'subdomains': url = `/api/scanner?target=${encodeURIComponent(query)}&type=subdomains`; break;
170 case 'tech': url = `/api/scanner?target=${encodeURIComponent(query)}&type=tech`; break;
171 case 'shodan': url = `https://internetdb.shodan.io/${encodeURIComponent(query)}`; break;
172 }
173 const res = await fetch(url, activeTab === 'shodan' ? { cache: 'no-store' } : undefined);
174 if (activeTab === 'shodan' && res.status === 404) {
175 setResults({ ip: query, status: 'No Shodan InternetDB records found', ports: [], cpes: [], hostnames: [], tags: [], vulns: [] });
176 setLoading(false);
177 return;
178 }
179 const data = await res.json();
180 if (res.ok) {
181 setResults(data);
182 setHistory(prev => [{ tab: activeTab, query, time: new Date().toLocaleTimeString() }, ...prev.slice(0, 9)]);
183
184 // Geolocate the target in the background
185 if (activeTab === 'phone') {
186 if (data.lat && data.lng && onScanGeolocate) {
187 onScanGeolocate(query, { lat: data.lat, lng: data.lng, type: 'phone', region: data.region });
188 }
189 } else if (activeTab !== 'sweep' && activeTab !== 'vuln' && activeTab !== 'crypto' && activeTab !== 'mac' && activeTab !== 'bgp' && activeTab !== 'github' && activeTab !== 'leaks' && activeTab !== 'phone') {
190 fetch(`/api/osint/ip?ip=${encodeURIComponent(query)}`)
191 .then(r => r.json())
192 .then(locData => {
193 if (locData && locData.geo && locData.geo.lat && locData.geo.lon && onScanGeolocate) {
194 // ip-api returns lat/lon, we pass it up
195 onScanGeolocate(query, { lat: locData.geo.lat, lng: locData.geo.lon, ...locData, type: activeTab });
196 }
197 })
198 .catch(() => {});
199 }
200 } else {
201 setError(data.error || 'Lookup failed');
202 }
203 } catch { setError('Network error'); }
204 finally { setLoading(false); }
205 }, [query, activeTab, scanType, loading, sweepCidr]);
206
207 const currentTab = TABS.find(t => t.id === activeTab);
208
209 // ── Shodan-style structured result renderers ──
210
211 const ResultRow = ({ label, value, color, mono = true }: { label: string; value: any; color?: string; mono?: boolean }) => {
212 if (value === undefined || value === null || value === '') return null;
213 return (
214 <div className="flex items-start gap-3 py-1.5 border-b border-[var(--border-secondary)]/20 last:border-0">
215 <span className="text-[9px] font-mono text-[var(--text-muted)] uppercase tracking-wider w-[90px] flex-shrink-0 pt-0.5">{label}</span>
216 <span className={`text-[10px] ${mono ? 'font-mono' : ''} break-all flex-1`} style={{ color: color || 'var(--text-primary)' }}>
217 {String(value)}
218 </span>
219 </div>
220 );
221 };
222
223 const StatusBadge = ({ ok, label }: { ok: boolean; label: string }) => (
224 <span className={`inline-flex items-center gap-1 px-2 py-0.5 rounded text-[9px] font-mono font-bold ${ok ? 'bg-green-500/15 text-green-400 border border-green-500/30' : 'bg-red-500/15 text-red-400 border border-red-500/30'}`}>
225 {ok ? <CheckCircle className="w-2.5 h-2.5" /> : <XCircle className="w-2.5 h-2.5" />}
226 {label}
227 </span>
228 );
229
230 // Surfaces an inline OFAC-SDN hit (used by the WHOIS and IP-intel routes
231 // when their cross-check finds a sanctioned registrant / ASN owner).
232 const SanctionsBadge = ({ match }: { match: any }) => {
233 if (!match || !Array.isArray(match.hits) || match.hits.length === 0) return null;
234 return (
235 <div className="mb-2 px-2 py-2 rounded border border-red-500/40 bg-red-500/15">
236 <div className="flex items-center gap-2 mb-1.5">
237 <AlertTriangle className="w-3.5 h-3.5 text-red-400" />
238 <span className="text-[10px] font-mono font-bold text-red-400 tracking-wider">
239 SANCTIONED — {match.source || 'OFAC SDN'}
240 </span>
241 </div>
242 {match.hits.slice(0, 5).map((h: any, i: number) => (
243 <div key={i} className="text-[9px] font-mono text-red-200 break-all leading-tight">
244 <span className="text-[var(--text-muted)]">↳ {h.matched_value}:</span>{' '}
245 {(h.entries || []).slice(0, 2).map((e: any) => e.name).join('; ')}
246 </div>
247 ))}
248 </div>
249 );
250 };
251
252 const SectionHeader = ({ title, icon: Icon, color }: { title: string; icon: any; color: string }) => (
253 <div className="flex items-center gap-2 mt-3 mb-1.5 first:mt-0">
254 <Icon className="w-3.5 h-3.5" style={{ color }} />
255 <span className="text-[10px] font-mono font-bold tracking-widest" style={{ color }}>{title}</span>
256 <div className="flex-1 h-px" style={{ background: `${color}30` }} />
257 </div>
258 );
259
260 const PortRow = ({ port, state, service, version }: { port: number; state: string; service?: string; version?: string }) => (
261 <div className="flex items-center gap-2 py-1 px-2 rounded hover:bg-[var(--hover-accent)] transition-colors">
262 <span className="text-[11px] font-mono font-bold text-[var(--cyan-primary)] w-[60px]">{port}</span>
263 <StatusBadge ok={state === 'open'} label={state.toUpperCase()} />
264 <span className="text-[10px] font-mono text-[var(--text-secondary)] flex-1">{service || 'unknown'}</span>
265 {version && <span className="text-[9px] font-mono text-[var(--text-muted)]">{version}</span>}
266 </div>
267 );
268
269 const renderStructuredResults = () => {
270 if (!results) return null;
271 const r = results;
272
273 // ── PORT SCAN ──
274 if (activeTab === 'scanner') {
275 const ports = r.ports || r.open_ports || r.results || [];
276 const host = r.host || r.target || query;
277 return (
278 <div>
279 <SectionHeader title="HOST INFO" icon={Server} color="#00E5FF" />
280 <ResultRow label="Target" value={host} color="#00E5FF" />
281 <ResultRow label="Scan Type" value={r.scan_type || scanType} />
282 <ResultRow label="Duration" value={r.duration || r.scan_time} />
283 {Array.isArray(ports) && ports.length > 0 && (
284 <>
285 <SectionHeader title={`OPEN PORTS (${ports.length})`} icon={Wifi} color="#00E676" />
286 <div className="space-y-0.5">
287 {ports.map((p: any, i: number) => (
288 <PortRow key={i} port={p.port || p} state={p.state || 'open'} service={p.service || p.name} version={p.version} />
289 ))}
290 </div>
291 </>
292 )}
293 {(!Array.isArray(ports) || ports.length === 0) && renderFallback()}
294 </div>
295 );
296 }
297
298 // ── VULN SCAN ──
299 if (activeTab === 'vuln') {
300 const vulns = r.vulnerabilities || r.vulns || r.cves || [];
301 const exploits = vulns.filter((v: any) => v.is_exploit);
302 const regularVulns = vulns.filter((v: any) => !v.is_exploit);
303
304 return (
305 <div>
306 <SectionHeader title="VULNERABILITY ASSESSMENT" icon={Bug} color="#FF3D3D" />
307 <ResultRow label="Target" value={r.target || query} color="#FF3D3D" />
308 <ResultRow label="Total CVEs" value={Array.isArray(vulns) ? vulns.length : 0} color={Array.isArray(vulns) && vulns.length > 0 ? '#FF3D3D' : '#00E676'} />
309 <ResultRow label="Risk Level" value={r.risk_level || r.severity} />
310 {Array.isArray(regularVulns) && regularVulns.length > 0 && (
311 <div className="mt-2 space-y-1">
312 {regularVulns.slice(0, 20).map((v: any, i: number) => (
313 <div key={i} className="p-2 rounded-lg border border-red-500/20 bg-red-500/5 flex flex-col">
314 <div className="flex items-center justify-between">
315 <span className="text-[10px] font-mono font-bold text-red-400">{v.id || v.cve || v.name}</span>
316 {v.severity && <span className={`text-[8px] font-mono font-bold px-1.5 py-0.5 rounded ${v.severity === 'CRITICAL' ? 'bg-red-500/20 text-red-400' : v.severity === 'HIGH' ? 'bg-orange-500/20 text-orange-400' : 'bg-yellow-500/20 text-yellow-400'}`}>{v.severity}</span>}
317 </div>
318 {v.cvss && <div className="text-[9px] font-mono text-[var(--text-muted)] mt-1">CVSS: {v.cvss} ({v.type || 'cve'})</div>}
319 {v.description && <p className="text-[9px] font-mono text-[var(--text-muted)] mt-1 line-clamp-2">{v.description}</p>}
320 </div>
321 ))}
322 </div>
323 )}
324
325 {exploits.length > 0 && (
326 <div className="mt-4">
327 <SectionHeader title={`POSSIBLE EXPLOITS (${exploits.length})`} icon={AlertTriangle} color="#FF9500" />
328 <div className="mt-2 space-y-1">
329 {exploits.slice(0, 10).map((e: any, i: number) => (
330 <div key={i} className="p-2 rounded-lg border border-orange-500/30 bg-orange-500/10 flex flex-col">
331 <div className="flex items-center justify-between">
332 <span className="text-[10px] font-mono font-bold text-orange-400">{e.id}</span>
333 <span className="text-[8px] font-mono font-bold px-1.5 py-0.5 rounded bg-orange-500/20 text-orange-400">EXPLOIT</span>
334 </div>
335 <div className="text-[9px] font-mono text-[var(--text-muted)] mt-1 flex justify-between">
336 <span>Source: {e.type?.toUpperCase() || 'UNKNOWN'}</span>
337 {e.cvss && <span>CVSS: {e.cvss}</span>}
338 </div>
339 </div>
340 ))}
341 </div>
342 </div>
343 )}
344
345 {(!Array.isArray(vulns) || vulns.length === 0) && renderFallback()}
346 </div>
347 );
348 }
349
350
351
352 // ── DNS ──
353 if (activeTab === 'dns') {
354 return (
355 <div>
356 <SectionHeader title="DNS RECORDS" icon={Server} color="#448AFF" />
357 <ResultRow label="Domain" value={r.domain || query} color="#448AFF" />
358 {r.A && <ResultRow label="A Records" value={Array.isArray(r.A) ? r.A.join(', ') : r.A} />}
359 {r.AAAA && <ResultRow label="AAAA" value={Array.isArray(r.AAAA) ? r.AAAA.join(', ') : r.AAAA} />}
360 {r.MX && <ResultRow label="MX" value={Array.isArray(r.MX) ? r.MX.map((m:any) => m.exchange || m).join(', ') : r.MX} />}
361 {r.NS && <ResultRow label="NS" value={Array.isArray(r.NS) ? r.NS.join(', ') : r.NS} />}
362 {r.TXT && <ResultRow label="TXT" value={Array.isArray(r.TXT) ? r.TXT.join(' | ') : r.TXT} />}
363 {r.CNAME && <ResultRow label="CNAME" value={Array.isArray(r.CNAME) ? r.CNAME.join(', ') : r.CNAME} />}
364 {r.SOA && <ResultRow label="SOA" value={typeof r.SOA === 'object' ? `${r.SOA.nsname} (${r.SOA.hostmaster})` : r.SOA} />}
365 {renderFallbackExcluding(['domain','A','AAAA','MX','NS','TXT','CNAME','SOA','timestamp','cached'])}
366 </div>
367 );
368 }
369
370 // ── WHOIS ──
371 if (activeTab === 'whois') {
372 return (
373 <div>
374 <SectionHeader title="WHOIS INTELLIGENCE" icon={FileText} color="#FFD700" />
375 <SanctionsBadge match={r.sanctions_match} />
376 <ResultRow label="Domain" value={r.domain_name || r.domainName || query} color="#FFD700" />
377 <ResultRow label="Registrar" value={r.registrar} />
378 <ResultRow label="Created" value={r.creation_date || r.createdDate} />
379 <ResultRow label="Expires" value={r.expiration_date || r.expiresDate} />
380 <ResultRow label="Updated" value={r.updated_date || r.updatedDate} />
381 <ResultRow label="Status" value={Array.isArray(r.status) ? r.status.join(', ') : r.status} />
382 <ResultRow label="Nameservers" value={Array.isArray(r.name_servers || r.nameServers) ? (r.name_servers || r.nameServers).join(', ') : r.name_servers} />
383 {renderFallbackExcluding(['domain_name','domainName','registrar','creation_date','createdDate','expiration_date','expiresDate','updated_date','updatedDate','status','name_servers','nameServers','timestamp','cached','raw','sanctions_match'])}
384 </div>
385 );
386 }
387
388 // ── SHODAN ──
389 if (activeTab === 'shodan') {
390 return (
391 <div>
392 <SectionHeader title="SHODAN IOT INTELLIGENCE" icon={Network} color="#FF3D3D" />
393 <ResultRow label="Target IP" value={r.ip || query} color="#FF3D3D" />
394 {r.hostnames?.length > 0 && <ResultRow label="Hostnames" value={r.hostnames.join(', ')} />}
395 {r.ports?.length > 0 && <ResultRow label="Open Ports" value={r.ports.join(', ')} color="#00E5FF" />}
396 {r.tags?.length > 0 && <ResultRow label="Tags" value={r.tags.join(', ')} color="#FF9500" />}
397 {r.vulns?.length > 0 && (
398 <div className="mt-2 p-2 border border-red-500/30 bg-red-500/10 rounded">
399 <span className="text-[10px] font-mono text-red-400 font-bold mb-1 block">VULNERABILITIES ({r.vulns.length})</span>
400 <div className="flex flex-wrap gap-1">
401 {r.vulns.slice(0, 10).map((v: string) => (
402 <a key={v} href={`https://nvd.nist.gov/vuln/detail/${v}`} target="_blank" rel="noreferrer" className="text-[9px] font-mono px-1.5 py-0.5 rounded bg-[#1A1A18] text-[#8A8880] hover:text-[#FF3D3D]">{v}</a>
403 ))}
404 {r.vulns.length > 10 && <span className="text-[9px] font-mono text-[#8A8880]">+{r.vulns.length - 10} more</span>}
405 </div>
406 </div>
407 )}
408 {renderFallbackExcluding(['ip','hostnames','ports','tags','vulns','cpes'])}
409 </div>
410 );
411 }
412
413 // ── BGP ──
414 if (activeTab === 'bgp') {
415 return (
416 <div>
417 <SectionHeader title="BGP ROUTING INTELLIGENCE" icon={Globe} color="#00E5FF" />
418 <ResultRow label="Query" value={r.query} color="#00E5FF" />
419 {r.type === 'ip' && r.ip && (
420 <>
421 {r.ip.prefixes?.map((p: any, i: number) => (
422 <div key={i} className="mt-2 p-2 border border-[#00E5FF]/20 bg-[#00E5FF]/5 rounded">
423 <ResultRow label="ASN" value={`AS${p.asn.asn} - ${p.asn.name}`} color="#00E5FF" />
424 <ResultRow label="Prefix" value={p.prefix} />
425 <ResultRow label="Country" value={p.asn.country_code} />
426 <ResultRow label="Description" value={p.asn.description} />
427 </div>
428 ))}
429 </>
430 )}
431 {r.type === 'asn' && r.asn && (
432 <div className="mt-2 p-2 border border-[#00E5FF]/20 bg-[#00E5FF]/5 rounded">
433 <ResultRow label="ASN" value={`AS${r.asn.asn}`} color="#00E5FF" />
434 <ResultRow label="Name" value={r.asn.name} />
435 <ResultRow label="Description" value={r.asn.description} />
436 <ResultRow label="Country" value={r.asn.country_code} />
437 {r.prefixes && <ResultRow label="Prefixes" value={`IPv4: ${r.prefixes.total_v4} | IPv6: ${r.prefixes.total_v6}`} />}
438 {r.peers && <ResultRow label="Peers" value={r.peers.total} />}
439 </div>
440 )}
441 {renderFallbackExcluding(['query', 'type', 'ip', 'asn', 'prefixes', 'peers', 'timestamp'])}
442 </div>
443 );
444 }
445
446 // ── MAC ──
447 if (activeTab === 'mac') {
448 return (
449 <div>
450 <SectionHeader title="MAC VENDOR LOOKUP" icon={Fingerprint} color="#FFD700" />
451 <ResultRow label="MAC Address" value={r.mac} color="#FFD700" />
452 <ResultRow label="Vendor" value={r.vendor} color={r.vendor === 'Not Found' ? '#FF3D3D' : '#00E676'} />
453 </div>
454 );
455 }
456
457 // ── PHONE ──
458 if (activeTab === 'phone') {
459 return (
460 <div>
461 <SectionHeader title="PHONE INTELLIGENCE" icon={Phone} color="#FF9500" />
462 <ResultRow label="Query" value={r.query} color="#FF9500" />
463 <ResultRow label="Valid" value={r.valid ? 'YES' : 'NO'} color={r.valid ? '#00E676' : '#FF3D3D'} />
464 {r.valid && (
465 <>
466 <ResultRow label="E.164 Format" value={r.number} />
467 <ResultRow label="Intl Format" value={r.international} />
468 <ResultRow label="Nat Format" value={r.national} />
469 <ResultRow label="Country" value={`${r.region} (${r.country_code})`} />
470 <ResultRow label="Line Type" value={r.line_type} color={r.line_type === 'MOBILE' ? '#00E5FF' : r.line_type === 'VOIP' ? '#FF9500' : undefined} />
471 </>
472 )}
473 </div>
474 );
475 }
476
477 // ── GITHUB ──
478 if (activeTab === 'github') {
479 return (
480 <div>
481 <SectionHeader title="GITHUB RECON" icon={Terminal} color="#87CEEB" />
482 <div className="flex items-center gap-3 mb-2">
483 {r.avatar_url && <img src={r.avatar_url} alt="avatar" className="w-10 h-10 rounded-full border border-[#87CEEB]/30" />}
484 <div>
485 <div className="text-[12px] font-mono font-bold text-[#87CEEB]">{r.name || r.username}</div>
486 <div className="text-[9px] font-mono text-[var(--text-muted)]">@{r.username} • {r.followers} followers</div>
487 </div>
488 </div>
489 <ResultRow label="Company" value={r.company} />
490 <ResultRow label="Location" value={r.location} />
491 <ResultRow label="Email" value={r.email} color="#00E676" />
492 <ResultRow label="Twitter" value={r.twitter} color="#448AFF" />
493 <ResultRow label="Website" value={r.blog} />
494 <ResultRow label="Bio" value={r.bio} />
495 {r.recent_repos?.length > 0 && (
496 <div className="mt-2 p-2 border border-[#87CEEB]/20 bg-[#87CEEB]/5 rounded">
497 <span className="text-[9px] font-mono text-[#87CEEB] block mb-1">RECENT REPOS</span>
498 {r.recent_repos.map((repo: any, i: number) => (
499 <div key={i} className="flex justify-between text-[9px] font-mono mb-0.5">
500 <span className="text-[#E8E6E0]">{repo.name}</span>
501 <span className="text-[var(--text-muted)]">{repo.language || 'Unknown'}</span>
502 </div>
503 ))}
504 </div>
505 )}
506 </div>
507 );
508 }
509
510 // ── LEAKS ──
511 if (activeTab === 'leaks') {
512 return (
513 <div>
514 <SectionHeader title="DATA LEAK SWEEP" icon={ShieldAlert} color="#E040FB" />
515 <ResultRow label="Email Target" value={r.email} color="#E040FB" />
516 <ResultRow label="Status" value={r.breached ? 'COMPROMISED' : 'SECURE'} color={r.breached ? '#FF1744' : '#00E676'} />
517
518 {r.breached && r.data_exposed?.length > 0 && (
519 <div className="mt-2 p-2 border border-[#E040FB]/30 bg-[#E040FB]/10 rounded">
520 <span className="text-[10px] font-mono text-[#E040FB] font-bold mb-1 block">EXPOSED DATA POINTS</span>
521 <div className="flex flex-wrap gap-1">
522 {r.data_exposed.map((dc: string) => (
523 <span key={dc} className="text-[9px] font-mono px-1.5 py-0.5 rounded bg-[#1A1A18] text-[#E8E6E0] border border-[#E040FB]/20">{dc}</span>
524 ))}
525 </div>
526 </div>
527 )}
528
529 {r.breached && r.breaches?.length > 0 && (
530 <div className="mt-2 p-2 border border-red-500/30 bg-red-500/10 rounded">
531 <span className="text-[10px] font-mono text-red-400 font-bold mb-1 block">KNOWN BREACHES ({r.breaches.length})</span>
532 <div className="flex flex-col gap-1">
533 {r.breaches.map((b: string) => (
534 <a key={b} href={`https://haveibeenpwned.com/PwnedWebsites#${b}`} target="_blank" rel="noreferrer" className="text-[9px] font-mono px-2 py-1 rounded bg-[#1A1A18] text-red-300 hover:text-white hover:bg-red-500/30 flex items-center justify-between transition-colors">
535 <span>{b}</span>
536 <ExternalLink className="w-2.5 h-2.5" />
537 </a>
538 ))}
539 </div>
540 </div>
541 )}
542 </div>
543 );
544 }
545
546 // ── CERTS ──
547 if (activeTab === 'certs') {
548 const certs = r.certificates || r.certs || (Array.isArray(r) ? r : []);
549 return (
550 <div>
551 <SectionHeader title="CERTIFICATE TRANSPARENCY" icon={Lock} color="#E040FB" />
552 <ResultRow label="Domain" value={query} color="#E040FB" />
553 <ResultRow label="Certificates" value={Array.isArray(certs) ? certs.length : 0} />
554 {Array.isArray(certs) && certs.slice(0, 15).map((c: any, i: number) => (
555 <div key={i} className="mt-1.5 p-2 rounded border border-[var(--border-secondary)]/30 bg-[var(--bg-tertiary)]/30">
556 <ResultRow label="Issuer" value={c.issuer_name || c.issuer} />
557 <ResultRow label="Common Name" value={c.common_name || c.name_value} />
558 <ResultRow label="Not Before" value={c.not_before} />
559 <ResultRow label="Not After" value={c.not_after} />
560 </div>
561 ))}
562 {(!Array.isArray(certs) || certs.length === 0) && renderFallback()}
563 </div>
564 );
565 }
566
567 // ── THREATS ──
568 if (activeTab === 'threats') {
569 return (
570 <div>
571 <SectionHeader title="THREAT INTELLIGENCE" icon={AlertTriangle} color="#FF9500" />
572 <ResultRow label="Query" value={query} color="#FF9500" />
573 <ResultRow label="Risk Score" value={r.risk_score || r.score} color={
574 (r.risk_score || r.score || 0) > 70 ? '#FF3D3D' : (r.risk_score || r.score || 0) > 40 ? '#FF9500' : '#00E676'
575 } />
576 <ResultRow label="Malicious" value={r.malicious !== undefined ? (r.malicious ? 'YES' : 'NO') : undefined} color={r.malicious ? '#FF3D3D' : '#00E676'} />
577 <ResultRow label="Category" value={r.category || r.type} />
578 <ResultRow label="Reports" value={r.total_reports || r.reports} />
579 <ResultRow label="Last Seen" value={r.last_seen || r.last_analysis} />
580 {r.tags && <ResultRow label="Tags" value={Array.isArray(r.tags) ? r.tags.join(', ') : r.tags} />}
581 {renderFallbackExcluding(['risk_score','score','malicious','category','type','total_reports','reports','last_seen','last_analysis','tags','timestamp','cached','query'])}
582 </div>
583 );
584 }
585
586 // ── SSL ──
587 if (activeTab === 'ssl') {
588 return (
589 <div>
590 <SectionHeader title="SSL/TLS ANALYSIS" icon={Shield} color="#76FF03" />
591 <ResultRow label="Target" value={query} color="#76FF03" />
592 <ResultRow label="Protocol" value={r.protocol || r.tls_version} />
593 <ResultRow label="Cipher" value={r.cipher || r.cipher_suite} />
594 <ResultRow label="Valid" value={r.valid !== undefined ? (r.valid ? 'YES' : 'NO') : undefined} color={r.valid ? '#00E676' : '#FF3D3D'} />
595 <ResultRow label="Issuer" value={r.issuer} />
596 <ResultRow label="Subject" value={r.subject} />
597 <ResultRow label="Expires" value={r.expires || r.not_after} />
598 <ResultRow label="SANs" value={Array.isArray(r.sans) ? r.sans.join(', ') : r.sans} />
599 {renderFallback()}
600 </div>
601 );
602 }
603
604
605
606 // Fallback for other tools
607 return renderFallback();
608 };
609
610 const renderFallback = () => {
611 if (!results) return null;
612 return (
613 <div className="space-y-1">
614 {Object.entries(results).filter(([k]) => !['timestamp','cached'].includes(k)).map(([key, value]) => (
615 <ResultRow key={key} label={key.replace(/_/g, ' ')} value={typeof value === 'object' ? JSON.stringify(value, null, 1) : String(value)} />
616 ))}
617 </div>
618 );
619 };
620
621 const renderFallbackExcluding = (exclude: string[]) => {
622 if (!results) return null;
623 const extra = Object.entries(results).filter(([k]) => !exclude.includes(k));
624 if (extra.length === 0) return null;
625 return (
626 <div className="mt-2 space-y-1">
627 {extra.map(([key, value]) => (
628 <ResultRow key={key} label={key.replace(/_/g, ' ')} value={typeof value === 'object' ? JSON.stringify(value, null, 1) : String(value)} />
629 ))}
630 </div>
631 );
632 };
633
634 const renderContent = () => (
635 <div className="flex flex-col gap-2.5">
636 {/* Tool Grid */}
637 <div className="flex flex-col gap-1">
638 {/* Sweep - Main Action */}
639 {TABS.filter(t => t.id === 'sweep').map(tab => (
640 <button key={tab.id} onClick={() => { setActiveTab(tab.id); setQuery(''); setResults(null); setError(''); }}
641 className={`flex items-center justify-center gap-2 px-3 py-3 rounded-lg text-[12px] font-mono tracking-widest font-bold transition-all border ${activeTab === tab.id ? 'border-opacity-60 bg-opacity-20' : 'border-[var(--border-secondary)] hover:bg-[var(--hover-accent)]'}`}
642 style={{
643 borderColor: activeTab === tab.id ? tab.color : 'rgba(255,61,61,0.3)',
644 backgroundColor: activeTab === tab.id ? `${tab.color}20` : 'rgba(255,61,61,0.05)',
645 color: activeTab === tab.id ? tab.color : tab.color,
646 boxShadow: activeTab === tab.id ? `0 0 15px ${tab.color}30` : 'none'
647 }}>
648 <tab.icon className="w-5 h-5" />
649 <span>GLOBAL {tab.label}</span>
650 </button>
651 ))}
652 {/* Other Tools */}
653 <div className="grid grid-cols-5 gap-1 mt-1">
654 {TABS.filter(t => t.id !== 'sweep').map(tab => (
655 <button key={tab.id} onClick={() => { setActiveTab(tab.id); setQuery(''); setResults(null); setError(''); }}
656 className={`flex flex-col items-center gap-1 px-1 py-2 rounded-lg text-[8px] font-mono tracking-wider transition-all border ${activeTab === tab.id ? 'border-opacity-40 bg-opacity-15' : 'border-transparent hover:bg-[var(--hover-accent)]'}`}
657 style={{ borderColor: activeTab === tab.id ? tab.color : 'transparent', backgroundColor: activeTab === tab.id ? `${tab.color}15` : undefined, color: activeTab === tab.id ? tab.color : 'var(--text-muted)' }}>
658 <tab.icon className="w-3.5 h-3.5" />
659 <span className="leading-none text-center truncate w-full">{tab.label}</span>
660 </button>
661 ))}
662 </div>
663 </div>
664
665 {/* Input Area */}
666 <div className="flex flex-col gap-1.5">
667 <div className="flex gap-1.5">
668 <div className="flex-1 relative">
669 <Search className="absolute left-2.5 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-[var(--text-muted)]" />
670 <input type="text" value={query} onChange={e => setQuery(e.target.value)} onKeyDown={e => e.key === 'Enter' && runLookup()}
671 placeholder={currentTab?.placeholder}
672 className="w-full bg-[var(--bg-primary)]/60 border border-[var(--border-primary)] rounded-lg pl-8 pr-3 py-2.5 text-[11px] font-mono text-[var(--text-primary)] placeholder:text-[var(--text-muted)]/40 focus:outline-none transition-colors"
673 style={{ borderColor: query ? `${currentTab?.color}40` : undefined }} />
674 </div>
675 <button onClick={runLookup} disabled={loading || !query.trim()}
676 className="px-4 py-2 rounded-lg text-[10px] font-mono font-bold tracking-wider disabled:opacity-30 transition-all flex items-center justify-center min-w-[70px]"
677 style={{ backgroundColor: `${currentTab?.color}20`, border: `1px solid ${currentTab?.color}40`, color: currentTab?.color }}>
678 {loading ? <Loader2 className="w-3.5 h-3.5 animate-spin" /> : 'SCAN'}
679 </button>
680 </div>
681
682 {/* Secondary Controls */}
683 {activeTab === 'scanner' && (
684 <select value={scanType} onChange={e => setScanType(e.target.value)}
685 className="bg-[var(--bg-primary)]/60 border border-[var(--border-primary)] rounded-lg px-2 py-1.5 text-[10px] font-mono text-[var(--text-muted)] outline-none w-full">
686 <option value="quick">QUICK SCAN</option><option value="deep">DEEP SCAN</option><option value="ports">TOP 1000 PORTS</option>
687 </select>
688 )}
689 {(activeTab === 'sweep' || activeTab === 'vuln') && (
690 <div className="flex items-center justify-between bg-[var(--bg-primary)]/60 border border-[var(--border-primary)] rounded-lg p-1">
691 <span className="text-[9px] font-mono text-[var(--text-muted)] pl-2">SUBNET MASK:</span>
692 <div className="flex items-center gap-0.5">
693 {[24, 25, 26, 27, 28].map(c => (
694 <button key={c} onClick={() => setSweepCidr(c)}
695 className={`px-2 py-1 text-[10px] font-mono rounded transition-all ${
696 sweepCidr === c ? 'bg-[#FF3D3D]/20 text-[#FF3D3D]' : 'text-[var(--text-muted)] hover:bg-[var(--bg-tertiary)]'
697 }`}
698 >/{c}</button>
699 ))}
700 </div>
701 </div>
702 )}
703 </div>
704
705 {error && (
706 <div className="p-2.5 rounded-lg border border-red-500/30 bg-red-500/10 text-[11px] font-mono text-red-400 flex items-center gap-2">
707 <AlertTriangle className="w-3.5 h-3.5 flex-shrink-0" />{error}
708 </div>
709 )}
710
711 {/* Sweep Progress */}
712 {sweepProgress && loading && (
713 <div className="p-3 rounded-lg border border-[#FF3D3D]/30 bg-[#FF3D3D]/5">
714 <div className="flex items-center justify-between mb-2">
715 <span className="text-[10px] font-mono tracking-wider text-[#FF3D3D]">SWEEPING SUBNET...</span>
716 <span className="text-[10px] font-mono text-[#E8E6E0]">{sweepProgress.total} hosts</span>
717 </div>
718 <div className="w-full h-1.5 bg-[#1A1A18] rounded-full overflow-hidden">
719 <div className="h-full rounded-full" style={{ width: '100%', background: 'linear-gradient(90deg, #FF3D3D, #FF6B00, #FFD700)', animation: 'sweep-pulse 1.5s ease-in-out infinite' }} />
720 </div>
721 </div>
722 )}
723
724 {/* Sweep Results */}
725 {sweepResult && !loading && (
726 <div className="bg-[var(--bg-primary)]/40 border border-[var(--border-primary)] rounded-lg overflow-hidden max-h-[55vh] overflow-y-auto styled-scrollbar">
727 {/* Summary */}
728 <div className="p-3 border-b border-[#2A2A28]">
729 <div className="flex items-center justify-between mb-3">
730 <div>
731 <div className="text-[11px] font-mono tracking-wider text-[#E8E6E0]">{sweepResult.subnet}</div>
732 <div className="text-[9px] font-mono text-[#5C5A54]">{sweepResult.center.city}, {sweepResult.center.country} · {sweepResult.center.isp}</div>
733 </div>
734 <div className="text-right">
735 <div className="text-[18px] font-mono font-bold text-[#FF3D3D]">{sweepResult.summary.total_responsive}</div>
736 <div className="text-[8px] font-mono text-[#5C5A54] tracking-wider">DEVICES FOUND</div>
737 </div>
738 </div>
739 {/* Breakdown Bar */}
740 <div className="flex h-2 rounded-full overflow-hidden bg-[#1A1A18] mb-2">
741 {Object.entries(sweepResult.summary.device_breakdown).map(([type, count]: [string, any]) => {
742 const device = sweepResult.devices.find((d: any) => d.device_type === type);
743 return <div key={type} style={{ width: `${(count / sweepResult.summary.total_responsive) * 100}%`, backgroundColor: device?.device_color || '#666' }} title={`${type}: ${count}`} />;
744 })}
745 </div>
746 <div className="flex flex-wrap gap-x-3 gap-y-1">
747 {Object.entries(sweepResult.summary.device_breakdown).map(([type, count]: [string, any]) => {
748 const device = sweepResult.devices.find((d: any) => d.device_type === type);
749 return (
750 <div key={type} className="flex items-center gap-1">
751 <div className="w-2 h-2 rounded-full" style={{ backgroundColor: device?.device_color || '#666' }} />
752 <span className="text-[9px] font-mono text-[#8A8880]">{type}</span>
753 <span className="text-[9px] font-mono text-[#E8E6E0] font-bold">{String(count)}</span>
754 </div>
755 );
756 })}
757 </div>
758 </div>
759 {/* Visualize Button */}
760 <div className="p-3 border-b border-[#2A2A28]">
761 <button onClick={() => onSweepVisualize?.(sweepResult)}
762 className="w-full py-2.5 rounded-lg font-mono text-[11px] tracking-wider font-bold transition-all hover:scale-[1.02] active:scale-[0.98] flex items-center justify-center gap-2"
763 style={{ background: 'linear-gradient(135deg, rgba(255,61,61,0.2), rgba(255,107,0,0.2))', border: '1px solid rgba(255,61,61,0.5)', color: '#FF3D3D', textShadow: '0 0 10px rgba(255,61,61,0.5)' }}
764 >
765 <Globe className="w-4 h-4" /> VISUALIZE ON GLOBE
766 </button>
767 </div>
768 {/* Device List */}
769 <div className={isFullScreen ? "flex flex-col gap-3 p-4" : "divide-y divide-[#2A2A28]"}>
770 {sweepResult.devices.map((device: any) => {
771 const isExpanded = expandedDevice === device.ip;
772 return (
773 <div key={device.ip} className={isFullScreen
774 ? "bg-[#0D0D0C] border border-[#2A2A28] rounded-lg overflow-hidden hover:border-[#3A3A38] transition-colors"
775 : "px-3 py-2.5 hover:bg-[rgba(255,255,255,0.02)] transition-colors"
776 }>
777 {/* Device Header */}
778 <div
779 className={isFullScreen
780 ? "flex items-center justify-between px-4 py-3 cursor-pointer hover:bg-[#151514] transition-colors"
781 : "flex items-center justify-between mb-1"
782 }
783 onClick={() => {
784 if (!isFullScreen) return;
785 const next = isExpanded ? null : device.ip;
786 setExpandedDevice(next);
787 if (next && device.vulns.length > 0) fetchCveDetails(device.vulns);
788 }}
789 >
790 <div className="flex items-center gap-3">
791 <div className="w-2.5 h-2.5 rounded-full flex-shrink-0" style={{ backgroundColor: device.device_color }} />
792 <span className={isFullScreen ? "text-[14px] font-mono font-bold text-[#E8E6E0]" : "text-[11px] font-mono text-[#E8E6E0]"}>{device.ip}</span>
793 {device.hostnames.length > 0 && (
794 <span className={`${isFullScreen ? "text-[11px]" : "text-[9px]"} font-mono text-[#5C5A54]`}>{device.hostnames[0]}</span>
795 )}
796 </div>
797 <div className="flex items-center gap-2">
798 {device.vulns.length > 0 && (
799 <span className={`${isFullScreen ? "text-[10px]" : "text-[8px]"} font-mono px-1.5 py-0.5 rounded bg-red-500/15 text-red-400 border border-red-500/30`}>
800 {device.vulns.length} CVEs
801 </span>
802 )}
803 <span className={`${isFullScreen ? "text-[10px]" : "text-[8px]"} font-mono px-1.5 py-0.5 rounded`} style={{ backgroundColor: device.device_color + '20', color: device.device_color, border: `1px solid ${device.device_color}40` }}>{device.device_type}</span>
804 {isFullScreen && (
805 <ChevronDown className={`w-4 h-4 text-[#5C5A54] transition-transform ${isExpanded ? 'rotate-180' : ''}`} />
806 )}
807 </div>
808 </div>
809
810 {/* Compact info (sidebar mode) */}
811 {!isFullScreen && (
812 <>
813 <div className="flex items-center gap-2 text-[9px] font-mono text-[#5C5A54]">
814 <span>Ports: {device.ports.slice(0, 8).join(', ')}{device.ports.length > 8 ? ` +${device.ports.length - 8}` : ''}</span>
815 {device.vulns.length > 0 && (
816 <div className="group relative flex items-center gap-1 cursor-help">
817 <span className="text-[#FF3D3D] flex items-center gap-1">
818 <AlertTriangle className="w-2.5 h-2.5" /> {device.vulns.length} CVEs
819 </span>
820 <div className="absolute bottom-full left-0 mb-1 hidden group-hover:block z-50 p-2 bg-[#1A1A18] border border-[#FF3D3D50] rounded-md shadow-xl min-w-[140px] max-w-[220px] max-h-[150px] overflow-y-auto styled-scrollbar">
821 <div className="text-[8px] font-mono text-[#FF3D3D] mb-1 tracking-wider uppercase border-b border-[#FF3D3D30] pb-1">Identified Vulnerabilities</div>
822 <div className="flex flex-col gap-0.5">
823 {device.vulns.map((cve: string) => (
824 <a key={cve} href={`https://nvd.nist.gov/vuln/detail/${cve}`} target="_blank" rel="noreferrer" className="text-[9px] font-mono text-[#E8E6E0] hover:text-[#FF3D3D] transition-colors truncate">
825 {cve}
826 </a>
827 ))}
828 </div>
829 </div>
830 </div>
831 )}
832 </div>
833 {device.hostnames.length > 0 && <div className="text-[9px] font-mono text-[#8A8880] mt-0.5 truncate">{device.hostnames[0]}</div>}
834 </>
835 )}
836
837 {/* Full-Screen Expanded Detail */}
838 {isFullScreen && isExpanded && (
839 <div className="border-t border-[#2A2A28]">
840 {/* Ports + Hostnames Row */}
841 <div className="grid grid-cols-1 md:grid-cols-2 gap-px bg-[#2A2A28]">
842 <div className="bg-[#0D0D0C] p-4">
843 <div className="text-[10px] font-mono text-[#5C5A54] tracking-widest uppercase mb-2">Open Ports</div>
844 <div className="flex flex-wrap gap-1.5">
845 {device.ports.map((port: number) => (
846 <span key={port} className="px-2 py-1 bg-[#1A1A18] border border-[#2A2A28] rounded text-[11px] font-mono text-[var(--cyan-primary)]">{port}</span>
847 ))}
848 </div>
849 </div>
850 <div className="bg-[#0D0D0C] p-4">
851 <div className="text-[10px] font-mono text-[#5C5A54] tracking-widest uppercase mb-2">Hostnames</div>
852 {device.hostnames.length > 0 ? (
853 <div className="flex flex-col gap-1">
854 {device.hostnames.map((h: string) => (
855 <span key={h} className="text-[11px] font-mono text-[#E8E6E0]">{h}</span>
856 ))}
857 </div>
858 ) : (
859 <span className="text-[11px] font-mono text-[#3A3A38]">No reverse DNS</span>
860 )}
861 </div>
862 </div>
863
864 {/* CVE Intelligence */}
865 {device.vulns.length > 0 && (
866 <div className="p-4 border-t border-[#2A2A28]">
867 <div className="text-[10px] font-mono text-[#5C5A54] tracking-widest uppercase mb-3">Vulnerabilities ({device.vulns.length})</div>
868 <div className="flex flex-col gap-2">
869 {device.vulns.map((cveId: string) => {
870 const info = cveCache[cveId];
871 const isLoading = !info || info.loading;
872 const severityColor = !info?.severity ? '#5C5A54'
873 : info.severity === 'CRITICAL' ? '#FF3D3D'
874 : info.severity === 'HIGH' ? '#FF6B00'
875 : info.severity === 'MEDIUM' ? '#FFD700'
876 : '#76FF03';
877 return (
878 <div key={cveId} className="bg-[#111] border border-[#2A2A28] rounded-lg p-3">
879 <div className="flex items-center justify-between mb-2">
880 <div className="flex items-center gap-2">
881 <span className="text-[12px] font-mono font-bold text-[#E8E6E0]">{cveId}</span>
882 {info?.cvss != null && (
883 <span className="text-[10px] font-mono px-1.5 py-0.5 rounded" style={{ backgroundColor: severityColor + '15', color: severityColor, border: `1px solid ${severityColor}40` }}>CVSS {info.cvss}</span>
884 )}
885 </div>
886 <div className="flex items-center gap-2">
887 {info?.severity && (
888 <span className="text-[9px] font-mono font-bold px-2 py-0.5 rounded" style={{ backgroundColor: severityColor + '15', color: severityColor, border: `1px solid ${severityColor}40` }}>{info.severity}</span>
889 )}
890 <a href={`https://nvd.nist.gov/vuln/detail/${cveId}`} target="_blank" rel="noreferrer" className="text-[#5C5A54] hover:text-[#E8E6E0] transition-colors">
891 <ExternalLink className="w-3.5 h-3.5" />
892 </a>
893 </div>
894 </div>
895 {isLoading ? (
896 <div className="flex items-center gap-2 py-1">
897 <Loader2 className="w-3 h-3 animate-spin text-[#5C5A54]" />
898 <span className="text-[10px] font-mono text-[#5C5A54]">Fetching vulnerability intelligence...</span>
899 </div>
900 ) : (
901 <>
902 <p className="text-[11px] font-mono text-[#8A8880] leading-relaxed">{info.description}</p>
903 {info.cwe && <div className="text-[10px] font-mono text-[#5C5A54] mt-2">Weakness: {info.cwe}</div>}
904 {info.affected && info.affected.length > 0 && (
905 <div className="mt-2 flex flex-wrap gap-1.5">
906 {info.affected.map((a: any, i: number) => (
907 <span key={i} className="text-[9px] font-mono px-1.5 py-0.5 bg-[#1A1A18] border border-[#2A2A28] rounded text-[#8A8880]">
908 {a.vendor}/{a.product}
909 </span>
910 ))}
911 </div>
912 )}
913 </>
914 )}
915 </div>
916 );
917 })}
918 </div>
919 </div>
920 )}
921 </div>
922 )}
923 </div>
924 );
925 })}
926 </div>
927 <div className="px-3 py-2 border-t border-[#2A2A28]">
928 <div className="text-[8px] font-mono text-[#5C5A54] tracking-wider">SWEPT {sweepResult.summary.total_hosts} HOSTS IN {(sweepResult.sweep_time_ms / 1000).toFixed(1)}s · ASN {sweepResult.center.asn}</div>
929 </div>
930 </div>
931 )}
932
933 {results && !(sweepResult && !loading) && (
934 <div className="bg-[var(--bg-primary)]/40 border border-[var(--border-primary)] rounded-lg p-3 max-h-[50vh] overflow-y-auto styled-scrollbar">
935 <div className="flex items-center justify-between mb-2">
936 <span className="text-[9px] font-mono tracking-widest" style={{ color: currentTab?.color }}>{currentTab?.label} RESULTS</span>
937 <span className="text-[8px] font-mono text-[var(--text-muted)] flex items-center gap-1"><Clock className="w-2.5 h-2.5" />{new Date().toLocaleTimeString()}</span>
938 </div>
939 {renderStructuredResults()}
940 </div>
941 )}
942
943 {history.length > 0 && !results && (
944 <div className="space-y-1">
945 <span className="text-[9px] font-mono tracking-widest text-[var(--text-muted)]">RECENT SCANS</span>
946 {history.slice(0, 5).map((h, i) => (
947 <button key={i} onClick={() => { setActiveTab(h.tab); setQuery(h.query); }}
948 className="w-full flex items-center justify-between px-2.5 py-1.5 rounded-lg hover:bg-[var(--hover-accent)] transition-colors text-left">
949 <div className="flex items-center gap-2">
950 <span className="text-[9px] font-mono" style={{ color: TABS.find(t => t.id === h.tab)?.color }}>{TABS.find(t => t.id === h.tab)?.label}</span>
951 <span className="text-[10px] font-mono text-[var(--text-secondary)]">{h.query}</span>
952 </div>
953 <span className="text-[8px] font-mono text-[var(--text-muted)]">{h.time}</span>
954 </button>
955 ))}
956 </div>
957 )}
958 </div>
959 );
960
961 if (isMobile) return renderContent();
962
963 if (isFullScreen) {
964 return (
965 <div className="fixed inset-4 z-[999] glass-panel bg-[#0a0a09]/95 backdrop-blur-2xl border border-[var(--cyan-primary)]/40 rounded-xl flex flex-col overflow-hidden shadow-2xl shadow-[var(--cyan-primary)]/20">
966 <div className="flex items-center justify-between px-6 py-4 border-b border-[var(--border-secondary)] bg-[#111]">
967 <div className="flex items-center gap-3">
968 <Radar className="w-5 h-5 text-[var(--cyan-primary)]" />
969 <span className="hud-text text-[16px] text-[var(--text-primary)]">OSIRIS RECON TOOLKIT</span>
970 <span className="gotham-tag gotham-tag--info" style={{ fontSize: '9px' }}>FULL SCREEN</span>
971 <span className="gotham-tag gotham-tag--classified" style={{ fontSize: '8px' }}>{TABS.length} MODULES</span>
972 </div>
973 <button onClick={() => setIsFullScreen(false)} className="p-2 hover:bg-white/5 rounded transition-colors text-[var(--text-muted)] hover:text-white">
974 <Minimize2 className="w-5 h-5" />
975 </button>
976 </div>
977 <div className="flex-1 overflow-y-auto p-6 styled-scrollbar">
978 {/* We wrap renderContent in a container that forces wider layouts if we want to target it with CSS */}
979 <div className="max-w-[1400px] mx-auto w-full full-screen-mode-content">
980 {renderContent()}
981 </div>
982 </div>
983 </div>
984 );
985 }
986
987 return (
988 <motion.div initial={{ opacity: 0, x: 20 }} animate={{ opacity: 1, x: 0 }} transition={{ delay: 0.3, duration: 0.6 }} className="glass-panel flex flex-col overflow-hidden pointer-events-auto shrink-0">
989 <div className="flex items-center justify-between px-4 py-3 border-b border-transparent hover:bg-[var(--hover-accent)] transition-colors">
990 <button onClick={() => setExpanded(!expanded)} className="flex items-center gap-2 flex-1">
991 <Radar className="w-3.5 h-3.5 text-[var(--cyan-primary)]" />
992 <span className="hud-text text-[12px] text-[var(--text-primary)]">RECON TOOLKIT</span>
993 <span className="gotham-tag gotham-tag--info" style={{ fontSize: '7px', padding: '1px 5px' }}>{TABS.length} TOOLS</span>
994 </button>
995 <div className="flex items-center gap-3">
996 <button onClick={() => setIsFullScreen(true)} className="text-[var(--text-muted)] hover:text-[var(--text-primary)] transition-colors" title="Full Screen">
997 <Maximize2 className="w-3.5 h-3.5" />
998 </button>
999 <div className="w-1.5 h-1.5 rounded-full bg-[var(--cyan-primary)] animate-osiris-pulse" />
1000 <button onClick={() => setExpanded(!expanded)}>
1001 {expanded ? <ChevronUp className="w-3.5 h-3.5 text-[var(--text-muted)]" /> : <ChevronDown className="w-3.5 h-3.5 text-[var(--text-muted)]" />}
1002 </button>
1003 </div>
1004 </div>
1005 <AnimatePresence>
1006 {expanded && (
1007 <motion.div initial={{ height: 0, opacity: 0 }} animate={{ height: 'auto', opacity: 1 }} exit={{ height: 0, opacity: 0 }} transition={{ duration: 0.2 }} className="overflow-hidden px-3 pb-3">
1008 {renderContent()}
1009 </motion.div>
1010 )}
1011 </AnimatePresence>
1012 </motion.div>
1013 );
1014}
1015
1016const OsintPanel = memo(OsintPanelInner);
1017export default OsintPanel;