sicario-red-team 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sicario-red-team",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Autonomous Agentic Red-Teaming Swarm Protocol",
5
5
  "type": "module",
6
6
  "files": [
@@ -76,48 +76,92 @@ export async function hitCommand(target, options) {
76
76
  // 5. [Breacher] Analysis
77
77
  log.step('[Breacher] : Analyzing DOM for logic flaws via Cerebras...');
78
78
  if (client && missionId) await client.mutation('handler:logMessage', { missionId, type: 'Breacher', message: 'Analyzing DOM for logic flaws via Cerebras...' });
79
+
79
80
  try {
80
- breachReport = await runBreacher(elements);
81
- log.success('[Breacher] : Analysis complete.');
82
- if (client && missionId) await client.mutation('handler:logMessage', { missionId, type: 'Breacher', message: 'Analysis complete.' });
81
+ let breachReports = [];
82
+
83
+ if (options.swarm) {
84
+ log.info(pc.magenta('šŸ›ø [System] : Deploying Specialized Task Force Swarm...'));
85
+ const results = await Promise.all([
86
+ runBreacher(elements, 'ACCOUNTANT'),
87
+ runBreacher(elements, 'ADMIN'),
88
+ runBreacher(elements, 'CHAOS_MONKEY')
89
+ ]);
90
+ breachReports = results.filter(r => r.vulnerabilityFound);
91
+ } else {
92
+ const singleReport = await runBreacher(elements);
93
+ if (singleReport.vulnerabilityFound) breachReports.push(singleReport);
94
+ }
83
95
 
84
- if (breachReport.vulnerabilityFound) {
85
- console.log('\n' + theme.exploit(`${breachReport.title} locked on ${breachReport.targetElement}`));
86
- console.log(pc.red(`Vector: ${breachReport.vector}`));
87
- console.log(pc.red(`Severity: ${breachReport.severity}\n`));
96
+ log.success(`[Breacher] : Analysis complete. ${breachReports.length} vulnerabilities isolated.`);
97
+ if (client && missionId) await client.mutation('handler:logMessage', { missionId, type: 'Breacher', message: `Analysis complete. Found ${breachReports.length} vectors.` });
98
+
99
+ for (const breachReport of breachReports) {
100
+ // 6. Sanitization Layer (The Anti-Crash Upgrade)
101
+ const sanitize = (raw) => ({
102
+ title: raw.title || "Unknown Logic Flaw",
103
+ vector: raw.vector || "Vector analysis inconclusive.",
104
+ severity: raw.severity || "MEDIUM",
105
+ targetElement: raw.targetElement || "General DOM Context",
106
+ mitigation: raw.mitigation || "Implement standard server-side validation guards.",
107
+ thoughtProcess: raw.thoughtProcess || "Reasoning engine offline."
108
+ });
109
+
110
+ const clean = sanitize(breachReport);
111
+
112
+ console.log('\n' + theme.exploit(`${clean.title} locked on ${clean.targetElement}`));
113
+ console.log(pc.red(`Vector: ${clean.vector}`));
114
+ console.log(pc.red(`Severity: ${clean.severity}\n`));
88
115
 
89
116
  if (client && missionId) {
90
117
  await client.mutation('handler:logExploit', {
91
118
  missionId,
92
- title: breachReport.title,
93
- vector: breachReport.vector,
94
- severity: breachReport.severity,
95
- target: breachReport.targetElement,
96
- mitigation: breachReport.mitigation // Ensure backend supports this
119
+ ...clean
97
120
  });
98
121
  }
99
122
 
100
- if (breachReport.mitigation) {
101
- note(pc.cyan(breachReport.mitigation), 'FIX RECOMMENDATION');
123
+ const mitigation = clean.mitigation;
124
+ const thoughtProcess = clean.thoughtProcess;
125
+
126
+ if (clean.mitigation) {
127
+ const boxWidth = 60;
128
+ const wrap = (str, width) => str.match(new RegExp(`.{1,${width}}(\\s|$)`, 'g')) || [str];
129
+
130
+ const drawBoxRow = (content, width) => `│ ${content.trim().padEnd(width - 4)} │`;
131
+
132
+ const thoughtLines = wrap(thoughtProcess, boxWidth - 4);
133
+ const mitLines = wrap(mitigation, boxWidth - 4);
134
+
135
+ console.log(pc.cyan(`ā—‡ SICARIO REASONING [${breachReport.title}] ${'─'.repeat(boxWidth - 21 - breachReport.title.length)}ā•®`));
136
+ thoughtLines.forEach(line => console.log(pc.cyan(drawBoxRow(line, boxWidth))));
137
+ console.log(pc.cyan(`ā”œ${'─'.repeat(boxWidth - 2)}┤`));
138
+ console.log(pc.cyan(`│ ${pc.bold('FIX RECOMMENDATION').padEnd(boxWidth - 4)} │`));
139
+ mitLines.forEach(line => console.log(pc.cyan(drawBoxRow(line, boxWidth))));
140
+ console.log(pc.cyan(`ā”œ${'─'.repeat(boxWidth - 2)}╯`) + '\n');
102
141
  }
103
- } else {
142
+ }
143
+
144
+ if (breachReports.length === 0) {
104
145
  log.info(theme.dim('No high-value business logic targets identified.'));
105
146
  }
147
+
148
+ // 6. Mission Dossier
149
+ const summaryLines = [
150
+ `${theme.dim('Target')} ${theme.bold(finalTarget)}`,
151
+ `${theme.dim('Nodes Recalled')} ${theme.bold(options.swarm ? '5 (Scout, Ghost, Accountant, Admin, Chaos)' : '3 (Scout, Ghost, Breacher)')}`,
152
+ `${theme.dim('Breaches Found')} ${breachReports.length > 0 ? pc.red(pc.bold(breachReports.length)) : theme.bold('0')}`,
153
+ `${theme.dim('Status')} ${theme.success('MISSION SUCCESSFUL')}`
154
+ ];
155
+
156
+ console.log(pc.green('\nā”Œ MISSION DOSSIER ───────────────────────────────────────╮'));
157
+ summaryLines.forEach(line => console.log(pc.green(`│ ${line.padEnd(54)} │`)));
158
+ console.log(pc.green(`ā”” Mission complete. Trace extraction successful. ╯`));
159
+
106
160
  } catch (error) {
107
161
  log.error('[Breacher] : Analysis node failure.');
108
162
  log.error(error.message);
109
163
  }
110
164
 
111
- // 6. Mission Dossier
112
- const summaryLines = [
113
- `${theme.dim('Target')} ${theme.bold(finalTarget)}`,
114
- `${theme.dim('Nodes Recalled')} ${theme.bold('3 (Scout, Ghost, Breacher)')}`,
115
- `${theme.dim('Breaches Found')} ${breachReport.vulnerabilityFound ? pc.red(pc.bold('1')) : theme.bold('0')}`,
116
- `${theme.dim('Status')} ${theme.success('MISSION SUCCESSFUL')}`
117
- ];
118
-
119
- note(summaryLines.join('\n'), 'MISSION DOSSIER');
120
-
121
165
  } catch (error) {
122
166
  log.error(`Mission failed: ${error.message}`);
123
167
  } finally {
@@ -1,41 +1,55 @@
1
1
  import Cerebras from '@cerebras/cerebras_cloud_sdk';
2
2
  import 'dotenv/config';
3
3
 
4
+ const PERSONAS = {
5
+ ACCOUNTANT: `
6
+ You are 'The Accountant' node. Your primary focus is on financial logic, pricing, and quantities.
7
+ Look for: Negative value injections, Scientific notation (1e10) bypasses, Currency-decimal manipulation, and Action Limit overruns in financial flows.
8
+ `,
9
+ ADMIN: `
10
+ You are 'The Admin' node. Your focus is on Privilege Escalation and Access Control.
11
+ Look for: Hidden /admin navigation links, accessible settings panels meant for high-privilege users, IDOR vectors in the DOM structure, and authentication bypass hints.
12
+ `,
13
+ CHAOS_MONKEY: `
14
+ You are 'The Chaos Monkey'. Your focus is on Input Resilience and Error Handling bypasses.
15
+ Look for: Fields that lack character limits, unhandled edge-case inputs (emojis, 1GB strings), and state-manipulation vectors that could lead to crashes or unhandled server-side exceptions.
16
+ `
17
+ };
18
+
4
19
  /**
5
- * Breacher Node: Analyzes interactive elements for OWASP Business Logic Abuse vectors.
6
- * Uses Cerebras AI to hypothesize vulnerabilities.
7
- * @param {Array} domElements - Array of extracted DOM elements.
20
+ * Breacher Node: Analyzes the context and attempts to identify business logic flaws.
21
+ * @param {Array} elements - Array of extracted DOM elements.
22
+ * @param {string} [personaType='GENERAL'] - The type of persona to use (e.g., 'ACCOUNTANT', 'ADMIN', 'CHAOS_MONKEY', or 'GENERAL').
8
23
  * @returns {Promise<Object>} - A strict JSON report of findings.
9
24
  */
10
- export async function runBreacher(domElements) {
25
+ export async function runBreacher(elements, personaType = 'GENERAL') {
11
26
  const client = new Cerebras({
12
27
  apiKey: process.env.CEREBRAS_API_KEY,
13
28
  });
14
29
 
15
- const systemPrompt = `
16
- You are 'The Breacher', an elite, autonomous SecOps AI. Your sole objective is to analyze a JSON array of web elements (DOM) and identify critical OWASP Business Logic vulnerabilities.
30
+ const personaContext = PERSONAS[personaType] || "Evaluate the DOM for general business logic vulnerabilities.";
17
31
 
18
- ### YOUR RULES OF ENGAGEMENT:
19
- 1. FOCUS ONLY ON BUSINESS LOGIC: Look for vectors allowing Action Limit Overruns (using coupons multiple times), Concurrent Workflow Bypassing (skipping checkout steps), or Price/State Manipulation.
20
- 2. NO BASIC FLAWS: DO NOT report standard XSS, SQLi, or CSRF vulnerabilities.
21
- 3. GROUNDED REALITY: You may only formulate an attack if the specific elements required (e.g., a checkout button, a promo code input) exist in the provided JSON array.
22
- 4. ZERO HALLUCINATIONS: If the DOM array does not contain high-value business logic targets (e.g., it is just a simple blog or static page), you MUST report no vulnerabilities.
32
+ const systemPrompt = `
33
+ You are a specialized node in the Sicario Autonomous Swarm.
34
+ ${personaContext}
23
35
 
24
- ### MANDATORY OUTPUT FORMAT:
25
- You must respond ONLY with a valid, raw JSON object. Do not include markdown formatting, conversational text, or explanations outside the JSON structure.
36
+ ### PHASE 1: REASONING (THINK OUT LOUD)
37
+ Before providing JSON, analyze the DOM elements according to your specific persona.
26
38
 
27
- Use this exact schema:
39
+ ### PHASE 2: DATA STRUCTURE
40
+ Return a VALID JSON object. DO NOT use "null".
28
41
  {
29
42
  "vulnerabilityFound": boolean,
30
- "title": string | null,
31
- "targetElement": string | null, // The ID or Name of the exploited element
32
- "vector": string | null, // A strict, 1-sentence technical explanation of the logic flaw
33
- "severity": "LOW" | "MEDIUM" | "HIGH" | "CRITICAL" | null,
34
- "mitigation": string | null // A brief, 2-sentence technical recommendation for fixing the logic flaw
43
+ "thoughtProcess": "Your specialized step-by-step reasoning",
44
+ "title": "Persona-specific flaw name",
45
+ "vector": "Technical path",
46
+ "severity": "LOW|MEDIUM|HIGH|CRITICAL",
47
+ "targetElement": "CSS selector or name",
48
+ "mitigation": "Code-level fix"
35
49
  }
36
50
  `;
37
51
 
38
- const userPrompt = `DOM Elements: ${JSON.stringify(domElements)}`;
52
+ const userPrompt = `DOM Elements: ${JSON.stringify(elements)}`;
39
53
 
40
54
  try {
41
55
  const completion = await client.chat.completions.create({