Repository navigation
Expand file tree
/
Copy pathserver.js
More file actions
524 lines (467 loc) · 20.9 KB
/
Copy pathserver.js
File metadata and controls
524 lines (467 loc) · 20.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
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
/**
* JamberSec v3.0 — AI-Powered Security Platform
*
* Main server — Express + WebSocket + SQLite
*
* GitHub: https://github.com/OfficialTech-X-JT/jambersec
* License: MIT
*
* âš ï¸ Configure via .env file — see .env.example
*/
require('dotenv').config();
const express = require('express');
const http = require('http');
const WebSocket = require('ws');
const session = require('express-session');
const { spawn } = require('child_process');
const path = require('path');
const fs = require('fs');
const { v4: uuidv4 } = require('uuid');
const cron = require('node-cron');
const PDFDocument = require('pdfkit');
const app = express();
const server = http.createServer(app);
const wss = new WebSocket.Server({ server });
// ── Configuration (from environment variables) ──────────────
const PORT = process.env.PORT || 3501;
const PASSWORD = process.env.ACCESS_PASSWORD || 'changeme';
const DB_PATH = process.env.DB_PATH || path.join(__dirname, 'jambersec.db');
const GO_BIN = process.env.GO_BIN_PATH || `${process.env.HOME}/go/bin`;
const STRIX_PATH = process.env.STRIX_PATH || `${process.env.HOME}/.local/bin/strix`;
const LLM_API_KEY = process.env.LLM_API_KEY || '';
const LLM_MODEL = process.env.LLM_MODEL || 'groq/llama-3.3-70b-versatile';
const LOGS_DIR = process.env.LOGS_DIR || path.join(__dirname, 'scan-logs');
// Ensure logs directory exists
if (!fs.existsSync(LOGS_DIR)) fs.mkdirSync(LOGS_DIR, { recursive: true });
// ── SQLite setup ──
let db;
try {
const Database = require('better-sqlite3');
db = new Database(DB_PATH);
db.exec(`
CREATE TABLE IF NOT EXISTS scans (
id TEXT PRIMARY KEY, tool TEXT, target TEXT,
status TEXT DEFAULT 'running', started_at TEXT,
ended_at TEXT, log_file TEXT, findings INTEGER DEFAULT 0
);
CREATE TABLE IF NOT EXISTS targets (
id TEXT PRIMARY KEY, name TEXT, url TEXT,
notes TEXT, created_at TEXT
);
CREATE TABLE IF NOT EXISTS schedules (
id TEXT PRIMARY KEY, name TEXT, tool TEXT, target TEXT,
cron_expr TEXT, enabled INTEGER DEFAULT 1,
last_run TEXT, next_run TEXT, created_at TEXT, run_count INTEGER DEFAULT 0
);
`);
} catch(e) {
console.warn('SQLite not available:', e.message);
db = null;
}
// ── ELITE TOOL CONFIGURATIONS ──
// All tools use environment-configurable paths
// No hardcoded credentials — use .env file
const TOOLS = {
// 🔴 PORT SCANNING — ELITE TIER (2000x / 100x / 50x faster)
masscan: {
name:'Masscan', cmd:'masscan',
buildArgs:(t) => {
const host = t.replace(/https?:\/\//,'').split('/')[0];
return [host, '-p', '1-65535', '--rate=10000', '--open-only'];
},
env:{}, note:'2000x faster than Nmap — 25 Gbps packet rate'
},
rustscan: {
name:'RustScan', cmd:'rustscan',
buildArgs:(t) => ['-a', t.replace(/https?:\/\//,'').split('/')[0], '--ulimit', '10000', '-b', '1500', '--', '-sV', '--open'],
env:{}, note:'100x faster than Nmap — async Rust engine'
},
naabu: {
name:'Naabu', cmd:`${GO_BIN}/naabu`,
buildArgs:(t) => ['-host', t.replace(/https?:\/\//,'').split('/')[0], '-p', '-', '-rate', '1000', '-silent'],
env:{}, note:'ProjectDiscovery fast port scanner'
},
// 🟠RECON & OSINT — ELITE TIER
bbot: {
name:'BBOT', cmd:'bbot',
buildArgs:(t) => ['-t', t.replace(/https?:\/\//,'').split('/')[0], '-m', 'subdomain-enum', 'httpx', 'nuclei', '--yes', '-o', '/tmp'],
env:{}, note:'50+ recon modules — replaces 10 tools at once'
},
amass: {
name:'Amass', cmd:`${GO_BIN}/amass`,
buildArgs:(t) => ['enum', '-passive', '-d', t.replace(/https?:\/\//,'').split('/')[0], '-timeout', '5'],
env:{}, note:'Most thorough subdomain enumeration (OWASP)'
},
subfinder: {
name:'Subfinder', cmd:`${GO_BIN}/subfinder`,
buildArgs:(t) => ['-d', t.replace(/https?:\/\//,'').split('/')[0], '-all', '-recursive'],
env:{}, note:'Passive subdomain discovery'
},
dnsx: {
name:'dnsx', cmd:`${GO_BIN}/dnsx`,
buildArgs:(t) => ['-d', t.replace(/https?:\/\//,'').split('/')[0], '-resp', '-a', '-aaaa', '-cname', '-mx', '-ns'],
env:{}, note:'Fast DNS resolver & brute-forcer'
},
gau: {
name:'gau', cmd:`${GO_BIN}/gau`,
buildArgs:(t) => [t.replace(/https?:\/\//,'').split('/')[0], '--threads', '20'],
env:{}, note:'Get ALL historical URLs from Wayback/OTX/CommonCrawl'
},
// 🌠WEB INTELLIGENCE — ELITE TIER
httpx: {
name:'httpx', cmd:`${GO_BIN}/httpx`,
buildArgs:(t) => ['-u', t, '-title', '-tech-detect', '-status-code', '-content-length', '-ip', '-cdn', '-probe'],
env:{}, note:'HTTP probing — tech stack, CDN, IPs'
},
katana: {
name:'Katana', cmd:`${GO_BIN}/katana`,
buildArgs:(t) => ['-u', t, '-depth', '5', '-js-crawl', '-automatic-form-fill', '-no-color', '-concurrency', '20'],
env:{}, note:'Next-gen crawler — JS rendering, form filling'
},
tlsx: {
name:'tlsx', cmd:`${GO_BIN}/tlsx`,
buildArgs:(t) => ['-u', t.replace(/https?:\/\//,'').split('/')[0], '-san', '-cn', '-so', '-tls-version', '-cipher'],
env:{}, note:'TLS/SSL analysis — certs, ciphers, versions'
},
// ⚡ VULNERABILITY — ELITE TIER
nuclei: {
name:'Nuclei v3', cmd:`${GO_BIN}/nuclei`,
buildArgs:(t) => ['-u', t, '-severity', 'critical,high,medium', '-stats', '-no-color', '-rate-limit', '150', '-bulk-size', '25'],
env:{}, note:'50,000+ CVE templates — fastest vuln scanner'
},
jaeles: {
name:'Jaeles', cmd:`${GO_BIN}/jaeles`,
buildArgs:(t) => ['scan', '-u', t, '--no-output'],
env:{}, note:'Signature-based web app scanner'
},
// 💥 EXPLOITATION — ELITE TIER
dalfox: {
name:'Dalfox', cmd:`${GO_BIN}/dalfox`,
buildArgs:(t) => ['url', t, '--skip-bav', '--no-color', '--timeout', '30'],
env:{}, note:'Fastest XSS scanner — smart param analysis'
},
ghauri: {
name:'Ghauri', cmd:'python3',
buildArgs:(t) => ['/opt/ghauri/ghauri.py', '-u', t, '--batch', '--level', '3', '--threads', '10', '--dbs'],
env:{}, note:'Modern SQLi — WAF bypass, faster than SQLMap'
},
feroxbuster: {
name:'Feroxbuster', cmd:'feroxbuster',
buildArgs:(t) => ['-u', t, '-w', '/usr/share/wordlists/dirb/common.txt', '-t', '200', '-q', '--no-state', '--auto-tune'],
env:{}, note:'50x faster dir fuzzer — Rust engine, recursive'
},
// 🤖 AI — AUTONOMOUS (requires STRIX_PATH and LLM_API_KEY in .env)
strix: {
name:'Strix AI', cmd:STRIX_PATH,
buildArgs:(t) => ['--target', t],
env:{ LLM_API_KEY, STRIX_LLM: LLM_MODEL },
note:'AI-powered autonomous pentesting'
}
};
// ── Elite Pipeline — 5 Phases ──
const PIPELINE_PHASES = [
{ name:'🌠Phase 1: OSINT & Recon', tools:['bbot','amass','subfinder','gau'], parallel:true },
{ name:'🔴 Phase 2: Port Blast', tools:['masscan','rustscan','naabu'], parallel:true },
{ name:'🌊 Phase 3: Web Intelligence', tools:['httpx','katana','tlsx','dnsx'], parallel:true },
{ name:'âš¡ Phase 4: Vulnerability Hunt', tools:['nuclei','dalfox','ghauri','feroxbuster'], parallel:true },
{ name:'🤖 Phase 5: AI Deep Analysis', tools:['strix'], parallel:false }
];
const activeScans = new Map();
const activeCrons = new Map();
// ── Middleware ──
app.use(express.json());
app.use(express.static(path.join(__dirname, 'public')));
app.use(session({
secret: process.env.SESSION_SECRET || uuidv4(),
resave: false,
saveUninitialized: false,
cookie: { secure: false, maxAge: 24 * 60 * 60 * 1000 }
}));
const requireAuth = (req, res, next) => {
if (req.session?.authenticated) return next();
res.status(401).json({ error: 'Unauthorized' });
};
// ── Auth endpoints ──
app.post('/api/login', (req, res) => {
if (req.body.password === PASSWORD) {
req.session.authenticated = true;
res.json({ success: true });
} else {
res.status(401).json({ error: 'Invalid password' });
}
});
app.post('/api/logout', (req, res) => { req.session.destroy(); res.json({ success: true }); });
app.get('/api/auth', (req, res) => res.json({ authenticated: !!req.session?.authenticated }));
// ── Tool execution engine ──
function executeScan(tool, target, scanId) {
const toolDef = TOOLS[tool];
if (!toolDef) throw new Error(`Unknown tool: ${tool}`);
const logFile = path.join(LOGS_DIR, `${scanId}.log`);
const logStream = fs.createWriteStream(logFile, { flags: 'a' });
const env = { ...process.env, ...toolDef.env, PATH: `${process.env.PATH}:${GO_BIN}` };
const args = toolDef.buildArgs(target);
const proc = spawn(toolDef.cmd, args, { env, shell: false });
activeScans.set(scanId, { proc, logFile, tool, target, startedAt: new Date().toISOString() });
if (db) {
db.prepare(`INSERT OR REPLACE INTO scans (id,tool,target,status,started_at,log_file) VALUES (?,?,?,?,?,?)`)
.run(scanId, tool, target, 'running', new Date().toISOString(), logFile);
}
const onData = (data) => {
const text = data.toString();
logStream.write(text);
wss.clients.forEach(client => {
if (client.readyState === WebSocket.OPEN && client.scanId === scanId)
client.send(JSON.stringify({ type: 'log', data: text }));
});
};
proc.stdout.on('data', onData);
proc.stderr.on('data', onData);
proc.on('close', (code) => {
logStream.end();
activeScans.delete(scanId);
const logContent = fs.existsSync(logFile) ? fs.readFileSync(logFile, 'utf8') : '';
const findings = (logContent.match(/\[critical\]|\[high\]|\[medium\]|VULNERABLE|Found|found/gi) || []).length;
if (db) {
db.prepare(`UPDATE scans SET status=?, ended_at=?, findings=? WHERE id=?`)
.run('completed', new Date().toISOString(), findings, scanId);
}
wss.clients.forEach(client => {
if (client.readyState === WebSocket.OPEN && client.scanId === scanId)
client.send(JSON.stringify({ type: 'done', scanId, findings, code }));
});
});
proc.on('error', (err) => {
logStream.write(`\n[ERROR] ${err.message}\n`);
logStream.end();
activeScans.delete(scanId);
if (db) db.prepare(`UPDATE scans SET status=? WHERE id=?`).run('error', scanId);
});
return scanId;
}
// ── API Routes ──
app.post('/api/scan/start', requireAuth, (req, res) => {
const { tool, target } = req.body;
if (!tool || !target) return res.status(400).json({ error: 'Tool and target required' });
try {
const scanId = uuidv4();
executeScan(tool, target, scanId);
res.json({ success: true, scanId });
} catch(e) { res.status(500).json({ error: e.message }); }
});
// ── Full Pipeline Scan ──
app.post('/api/pipeline/start', requireAuth, (req, res) => {
const { target } = req.body;
if (!target) return res.status(400).json({ error: 'Target required' });
const pipelineId = uuidv4();
const scanIds = {};
const broadcastPipeline = (msg) => {
wss.clients.forEach(client => {
if (client.readyState === WebSocket.OPEN && client.pipelineId === pipelineId)
client.send(JSON.stringify(msg));
});
};
(async () => {
broadcastPipeline({ type:'pipeline_start', pipelineId, target, phases: PIPELINE_PHASES.map(p=>p.name) });
for (let phaseIdx = 0; phaseIdx < PIPELINE_PHASES.length; phaseIdx++) {
const phase = PIPELINE_PHASES[phaseIdx];
broadcastPipeline({ type:'phase_start', phase: phase.name, phaseIdx });
const phaseScans = [];
for (const tool of phase.tools) {
const scanId = uuidv4();
scanIds[tool] = scanId;
broadcastPipeline({ type:'tool_start', tool, scanId });
try { executeScan(tool, target, scanId); phaseScans.push(scanId); }
catch(e) { broadcastPipeline({ type:'tool_error', tool, error:e.message }); }
}
await new Promise(resolve => {
let completed = 0;
const checkDone = () => { if (++completed >= phaseScans.length) resolve(); };
phaseScans.forEach(sid => {
const check = setInterval(() => {
if (!activeScans.has(sid)) { clearInterval(check); checkDone(); }
}, 2000);
});
if (phaseScans.length === 0) resolve();
});
broadcastPipeline({ type:'phase_done', phase:phase.name, phaseIdx });
}
broadcastPipeline({ type:'pipeline_done', pipelineId, scanIds });
})();
res.json({ success:true, pipelineId, message:'Pipeline started' });
});
app.post('/api/scan/stop', requireAuth, (req, res) => {
const scan = activeScans.get(req.body.scanId);
if (!scan) return res.status(404).json({ error:'Not found' });
scan.proc.kill('SIGTERM');
activeScans.delete(req.body.scanId);
res.json({ success:true });
});
app.get('/api/scans', requireAuth, (req, res) => {
if (!db) return res.json([]);
const scans = db.prepare('SELECT * FROM scans ORDER BY started_at DESC LIMIT 100').all();
res.json(scans);
});
app.get('/api/scan/:id/log', requireAuth, (req, res) => {
const scan = db?.prepare('SELECT log_file FROM scans WHERE id=?').get(req.params.id);
if (!scan || !fs.existsSync(scan.log_file)) return res.status(404).send('Not found');
res.sendFile(scan.log_file);
});
// ── PDF Report ──
app.get('/api/scan/:id/report', requireAuth, (req, res) => {
const scan = db?.prepare('SELECT * FROM scans WHERE id=?').get(req.params.id);
if (!scan) return res.status(404).json({ error:'Scan not found' });
const doc = new PDFDocument({ margin:50 });
res.setHeader('Content-Type', 'application/pdf');
res.setHeader('Content-Disposition', `attachment; filename="jambersec-report-${scan.id.slice(0,8)}.pdf"`);
doc.pipe(res);
// Header
doc.rect(0, 0, doc.page.width, 80).fill('#0a0a10');
doc.fillColor('#c084fc').fontSize(24).font('Helvetica-Bold')
.text('ðŸ›¡ï¸ JamberSec', 50, 25);
doc.fillColor('#94a3b8').fontSize(11).font('Helvetica')
.text('Security Scan Report', 50, 52);
doc.fillColor('#333');
doc.moveDown(3);
// Scan info
doc.fontSize(13).font('Helvetica-Bold').fillColor('#1a1a2e').text('Scan Details', 50, 100);
doc.moveTo(50, 118).lineTo(550, 118).strokeColor('#7c3aed').stroke();
doc.moveDown(0.5);
doc.fontSize(11).font('Helvetica').fillColor('#333');
[
['Tool', scan.tool],
['Target', scan.target],
['Status', scan.status],
['Started', new Date(scan.started_at).toLocaleString()],
['Completed', scan.ended_at ? new Date(scan.ended_at).toLocaleString() : 'In progress'],
['Findings', String(scan.findings || 0)],
].forEach(([label, value]) => {
doc.font('Helvetica-Bold').text(`${label}:`, 50, doc.y, { continued: true, width: 100 });
doc.font('Helvetica').text(` ${value}`);
});
// Output
doc.moveDown();
doc.fontSize(13).font('Helvetica-Bold').fillColor('#1a1a2e').text('Scan Output');
doc.moveTo(50, doc.y+4).lineTo(550, doc.y+4).strokeColor('#7c3aed').stroke();
doc.moveDown(0.5);
const logContent = scan.log_file && fs.existsSync(scan.log_file)
? fs.readFileSync(scan.log_file, 'utf8').replace(/\x1B\[[0-9;]*m/g, '') : 'No output';
doc.fontSize(8).font('Helvetica').fillColor('#222')
.text(logContent.slice(0, 8000), 50, doc.y, { width: 500, lineGap: 1 });
// Footer
const footerY = doc.page.height - 50;
doc.fillColor('#7c3aed').rect(0, footerY-10, doc.page.width, 1).fill();
doc.fillColor('#888').fontSize(9).font('Helvetica')
.text(`JamberSec v3.0 | github.com/OfficialTech-X-JT/jambersec | Generated: ${new Date().toLocaleString()}`, 50, footerY);
doc.end();
});
// ── Stats ──
app.get('/api/stats', requireAuth, (req, res) => {
let totalScans = 0, runningScans = activeScans.size, totalFindings = 0, scheduledScans = 0;
if (db) {
try {
totalScans = db.prepare('SELECT COUNT(*) as c FROM scans').get().c;
totalFindings = db.prepare('SELECT SUM(findings) as s FROM scans').get().s || 0;
scheduledScans = db.prepare('SELECT COUNT(*) as c FROM schedules WHERE enabled=1').get().c;
} catch(e) {}
}
res.json({ totalScans, runningScans, totalFindings, toolsAvailable: Object.keys(TOOLS).length, scheduledScans });
});
// ── Targets ──
app.get('/api/targets', requireAuth, (req, res) => {
if (!db) return res.json([]);
res.json(db.prepare('SELECT * FROM targets ORDER BY created_at DESC').all());
});
app.post('/api/targets', requireAuth, (req, res) => {
if (!db) return res.status(503).json({ error:'DB not available' });
const { name, url, notes } = req.body;
if (!name || !url) return res.status(400).json({ error:'Name and URL required' });
const id = uuidv4();
db.prepare('INSERT INTO targets (id,name,url,notes,created_at) VALUES (?,?,?,?,?)').run(id, name, url, notes||'', new Date().toISOString());
res.json({ success:true, id });
});
app.delete('/api/targets/:id', requireAuth, (req, res) => {
if (db) db.prepare('DELETE FROM targets WHERE id=?').run(req.params.id);
res.json({ success:true });
});
// ── Schedules ──
function startCronJob(id, name, tool, target, cronExpr) {
if (activeCrons.has(id)) activeCrons.get(id).stop();
const task = cron.schedule(cronExpr, () => {
const scanId = uuidv4();
try {
executeScan(tool, target, scanId);
if (db) db.prepare('UPDATE schedules SET last_run=?, run_count=run_count+1 WHERE id=?').run(new Date().toISOString(), id);
console.log(`[CRON] Schedule "${name}" triggered → scanId: ${scanId}`);
} catch(e) { console.error(`[CRON] Error running ${tool}:`, e.message); }
}, { scheduled: true, timezone: 'UTC' });
activeCrons.set(id, task);
}
app.get('/api/schedules', requireAuth, (req, res) => {
if (!db) return res.json([]);
res.json(db.prepare('SELECT * FROM schedules ORDER BY created_at DESC').all());
});
app.post('/api/schedules', requireAuth, (req, res) => {
if (!db) return res.status(503).json({ error:'DB not available' });
const { name, tool, target, cron_expr } = req.body;
if (!name||!tool||!target||!cron_expr) return res.status(400).json({ error:'All fields required' });
if (!cron.validate(cron_expr)) return res.status(400).json({ error:'Invalid cron expression' });
const id = uuidv4();
db.prepare('INSERT INTO schedules (id,name,tool,target,cron_expr,enabled,created_at,run_count) VALUES (?,?,?,?,?,1,?,0)')
.run(id, name, tool, target, cron_expr, new Date().toISOString());
startCronJob(id, name, tool, target, cron_expr);
res.json({ success:true, id });
});
app.patch('/api/schedules/:id/toggle', requireAuth, (req, res) => {
if (!db) return res.status(503).json({ error:'DB not available' });
const s = db.prepare('SELECT * FROM schedules WHERE id=?').get(req.params.id);
if (!s) return res.status(404).json({ error:'Not found' });
const newEnabled = s.enabled ? 0 : 1;
db.prepare('UPDATE schedules SET enabled=? WHERE id=?').run(newEnabled, req.params.id);
if (newEnabled) startCronJob(s.id, s.name, s.tool, s.target, s.cron_expr);
else { activeCrons.get(s.id)?.stop(); activeCrons.delete(s.id); }
res.json({ success:true, enabled: newEnabled });
});
app.delete('/api/schedules/:id', requireAuth, (req, res) => {
activeCrons.get(req.params.id)?.stop(); activeCrons.delete(req.params.id);
if (db) db.prepare('DELETE FROM schedules WHERE id=?').run(req.params.id);
res.json({ success:true });
});
// ── WebSocket ──
wss.on('connection', (ws) => {
ws.on('message', (msg) => {
try {
const data = JSON.parse(msg);
if (data.type === 'subscribe' && data.scanId) {
ws.scanId = data.scanId;
const scan = activeScans.get(data.scanId);
if (scan && fs.existsSync(scan.logFile)) {
const existing = fs.readFileSync(scan.logFile, 'utf8');
if (existing) ws.send(JSON.stringify({ type:'log', data:existing }));
}
}
if (data.type === 'pipeline_subscribe' && data.pipelineId) {
ws.pipelineId = data.pipelineId;
ws.send(JSON.stringify({ type:'ack', message:'Subscribed to pipeline: '+data.pipelineId }));
}
} catch(e) {}
});
ws.on('error', () => {});
});
// ── Load active schedules on startup ──
function loadSchedules() {
if (!db) return;
try {
const schedules = db.prepare('SELECT * FROM schedules WHERE enabled=1').all();
schedules.forEach(s => {
if (cron.validate(s.cron_expr)) startCronJob(s.id, s.name, s.tool, s.target, s.cron_expr);
});
console.log(`[CRON] Loaded ${schedules.length} active schedules`);
} catch(e) {}
}
loadSchedules();
server.listen(PORT, () => {
console.log(`\nðŸ›¡ï¸ JamberSec v3.0 — Elite Security Platform`);
console.log(` Running on: http://localhost:${PORT}`);
console.log(` Tools available: ${Object.keys(TOOLS).length}`);
console.log(` Database: ${DB_PATH}\n`);
});