@pensar/apex 0.0.10 → 0.0.11
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/build/swarm.js +65 -47
- package/package.json +1 -1
package/build/swarm.js
CHANGED
|
@@ -42428,43 +42428,51 @@ var TargetSchema = exports_external.array(exports_external.object({
|
|
|
42428
42428
|
objective: exports_external.string().describe("The objective of the pentest")
|
|
42429
42429
|
}));
|
|
42430
42430
|
async function swarm(options) {
|
|
42431
|
-
const { targets, model } = options;
|
|
42431
|
+
const { targets, model, silent } = options;
|
|
42432
42432
|
let targetsArray = [];
|
|
42433
42433
|
if (typeof targets === "string") {
|
|
42434
42434
|
const result = TargetSchema.safeParse(JSON.parse(targets));
|
|
42435
42435
|
if (!result.success) {
|
|
42436
|
-
|
|
42437
|
-
|
|
42436
|
+
if (!silent) {
|
|
42437
|
+
console.error("Invalid targets JSON");
|
|
42438
|
+
console.error(result.error);
|
|
42439
|
+
}
|
|
42438
42440
|
return;
|
|
42439
42441
|
}
|
|
42440
42442
|
targetsArray = result.data;
|
|
42441
42443
|
} else {
|
|
42442
42444
|
targetsArray = targets;
|
|
42443
42445
|
}
|
|
42444
|
-
|
|
42445
|
-
|
|
42446
|
-
|
|
42447
|
-
|
|
42448
|
-
|
|
42449
|
-
|
|
42450
|
-
|
|
42451
|
-
|
|
42452
|
-
|
|
42453
|
-
|
|
42454
|
-
|
|
42455
|
-
|
|
42456
|
-
|
|
42446
|
+
if (!silent) {
|
|
42447
|
+
console.log("=".repeat(80));
|
|
42448
|
+
console.log("PENSAR SWARM PENTEST");
|
|
42449
|
+
console.log("=".repeat(80));
|
|
42450
|
+
console.log(`Model: ${model}`);
|
|
42451
|
+
console.log(`Total Targets: ${targetsArray.length}`);
|
|
42452
|
+
console.log();
|
|
42453
|
+
for (const [idx, target] of targetsArray.entries()) {
|
|
42454
|
+
console.log(` [${idx + 1}] ${target.target}`);
|
|
42455
|
+
console.log(` Objective: ${target.objective}`);
|
|
42456
|
+
}
|
|
42457
|
+
console.log();
|
|
42458
|
+
console.log("=".repeat(80));
|
|
42459
|
+
console.log();
|
|
42460
|
+
}
|
|
42457
42461
|
if (targetsArray.length === 0) {
|
|
42458
|
-
|
|
42462
|
+
if (!silent) {
|
|
42463
|
+
console.error("No targets provided");
|
|
42464
|
+
}
|
|
42459
42465
|
return;
|
|
42460
42466
|
}
|
|
42461
42467
|
const session = createSession("swarm", "Multi-target swarm pentest");
|
|
42462
42468
|
const results = [];
|
|
42463
42469
|
const promises = targetsArray.map(async (target, idx) => {
|
|
42464
|
-
|
|
42465
|
-
|
|
42466
|
-
|
|
42467
|
-
|
|
42470
|
+
if (!silent) {
|
|
42471
|
+
console.log("=".repeat(80));
|
|
42472
|
+
console.log(`[${idx + 1}/${targetsArray.length}] Starting pentest for: ${target.target}`);
|
|
42473
|
+
console.log("=".repeat(80));
|
|
42474
|
+
console.log();
|
|
42475
|
+
}
|
|
42468
42476
|
try {
|
|
42469
42477
|
const { streamResult } = runAgent({
|
|
42470
42478
|
session,
|
|
@@ -42475,18 +42483,22 @@ async function swarm(options) {
|
|
|
42475
42483
|
for await (const delta of streamResult.fullStream) {
|
|
42476
42484
|
if (delta.type === "text-delta") {} else if (delta.type === "tool-call") {} else if (delta.type === "tool-result") {}
|
|
42477
42485
|
}
|
|
42478
|
-
|
|
42479
|
-
|
|
42480
|
-
|
|
42486
|
+
if (!silent) {
|
|
42487
|
+
console.log();
|
|
42488
|
+
console.log(`✓ Pentest completed for: ${target.target}`);
|
|
42489
|
+
console.log();
|
|
42490
|
+
}
|
|
42481
42491
|
results.push({
|
|
42482
42492
|
target: target.target,
|
|
42483
42493
|
success: true,
|
|
42484
42494
|
sessionId: session.id
|
|
42485
42495
|
});
|
|
42486
42496
|
} catch (error46) {
|
|
42487
|
-
|
|
42488
|
-
|
|
42489
|
-
|
|
42497
|
+
if (!silent) {
|
|
42498
|
+
console.error(`✗ Pentest failed for: ${target.target}`);
|
|
42499
|
+
console.error(` Error: ${error46.message}`);
|
|
42500
|
+
console.error();
|
|
42501
|
+
}
|
|
42490
42502
|
results.push({
|
|
42491
42503
|
target: target.target,
|
|
42492
42504
|
success: false,
|
|
@@ -42495,24 +42507,26 @@ async function swarm(options) {
|
|
|
42495
42507
|
}
|
|
42496
42508
|
});
|
|
42497
42509
|
await Promise.all(promises);
|
|
42498
|
-
|
|
42499
|
-
|
|
42500
|
-
|
|
42501
|
-
|
|
42502
|
-
|
|
42503
|
-
|
|
42504
|
-
|
|
42505
|
-
|
|
42506
|
-
|
|
42507
|
-
|
|
42508
|
-
const
|
|
42509
|
-
|
|
42510
|
-
|
|
42511
|
-
|
|
42510
|
+
if (!silent) {
|
|
42511
|
+
console.log("=".repeat(80));
|
|
42512
|
+
console.log("SWARM PENTEST SUMMARY");
|
|
42513
|
+
console.log("=".repeat(80));
|
|
42514
|
+
console.log(`Total targets: ${targetsArray.length}`);
|
|
42515
|
+
console.log(`Successful: ${results.filter((r) => r.success).length}`);
|
|
42516
|
+
console.log(`Failed: ${results.filter((r) => !r.success).length}`);
|
|
42517
|
+
console.log(`Session ID: ${session.id}`);
|
|
42518
|
+
console.log(`Session Path: ${session.rootPath}`);
|
|
42519
|
+
console.log();
|
|
42520
|
+
for (const result of results) {
|
|
42521
|
+
const status = result.success ? "✓" : "✗";
|
|
42522
|
+
console.log(`${status} ${result.target}`);
|
|
42523
|
+
if (result.error) {
|
|
42524
|
+
console.log(` Error: ${result.error}`);
|
|
42525
|
+
}
|
|
42512
42526
|
}
|
|
42527
|
+
console.log();
|
|
42528
|
+
console.log("=".repeat(80));
|
|
42513
42529
|
}
|
|
42514
|
-
console.log();
|
|
42515
|
-
console.log("=".repeat(80));
|
|
42516
42530
|
return session;
|
|
42517
42531
|
}
|
|
42518
42532
|
async function main() {
|
|
@@ -42525,6 +42539,7 @@ async function main() {
|
|
|
42525
42539
|
console.error();
|
|
42526
42540
|
console.error("Options:");
|
|
42527
42541
|
console.error(" --model <model> Specify the AI model to use (default: claude-sonnet-4-5)");
|
|
42542
|
+
console.error(" --silent Suppress all output");
|
|
42528
42543
|
console.error();
|
|
42529
42544
|
console.error("Targets format (JSON array):");
|
|
42530
42545
|
console.error(" [");
|
|
@@ -42541,6 +42556,7 @@ async function main() {
|
|
|
42541
42556
|
console.error("Examples:");
|
|
42542
42557
|
console.error(" pensar swarm targets.json");
|
|
42543
42558
|
console.error(" pensar swarm targets.json --model gpt-4o");
|
|
42559
|
+
console.error(" pensar swarm targets.json --silent");
|
|
42544
42560
|
console.error(` pensar swarm '[{"target":"api.example.com","objective":"Test API"}]'`);
|
|
42545
42561
|
console.error(` pensar swarm '[{"target":"api.example.com","objective":"Test API"}]' --model gpt-4o`);
|
|
42546
42562
|
process.exit(1);
|
|
@@ -42556,6 +42572,7 @@ async function main() {
|
|
|
42556
42572
|
}
|
|
42557
42573
|
model = modelArg;
|
|
42558
42574
|
}
|
|
42575
|
+
const silent = args.includes("--silent");
|
|
42559
42576
|
let targetsJson;
|
|
42560
42577
|
if (targetsInput.startsWith("[") || targetsInput.startsWith("{")) {
|
|
42561
42578
|
targetsJson = targetsInput;
|
|
@@ -42570,14 +42587,15 @@ async function main() {
|
|
|
42570
42587
|
try {
|
|
42571
42588
|
const session = await swarm({
|
|
42572
42589
|
targets: targetsJson,
|
|
42573
|
-
model
|
|
42590
|
+
model,
|
|
42591
|
+
silent
|
|
42574
42592
|
});
|
|
42575
42593
|
if (!session) {
|
|
42576
|
-
|
|
42594
|
+
if (!silent) {
|
|
42595
|
+
console.error("No session was returned");
|
|
42596
|
+
}
|
|
42577
42597
|
process.exit(1);
|
|
42578
42598
|
}
|
|
42579
|
-
console.log();
|
|
42580
|
-
console.log("__PENSAR_SWARM_RESULT__");
|
|
42581
42599
|
console.log(JSON.stringify({
|
|
42582
42600
|
sessionId: session.id,
|
|
42583
42601
|
sessionPath: session.rootPath,
|